diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-03-27 17:23:10 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-03-27 22:36:08 +0100 |
| commit | 238f48fb7cd006296cbd622ab9e4187139af9a8e (patch) | |
| tree | 08487933c418ca9221293333ce6b9a57c4ac6e5a | |
| parent | ec206a4d507d36a082070b53d462753f68711806 (diff) | |
| download | PROJ-238f48fb7cd006296cbd622ab9e4187139af9a8e.tar.gz PROJ-238f48fb7cd006296cbd622ab9e4187139af9a8e.zip | |
Fix identification of projected CRS whose name is close but not strictly equal to a ESRI alias (fixes #2099)
| -rw-r--r-- | src/iso19111/crs.cpp | 11 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 25 |
2 files changed, 31 insertions, 5 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index cff93508..b0f5bcf9 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -3741,7 +3741,8 @@ ProjectedCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { return res; } res.emplace_back(crsNN, eqName ? 90 : 70); - } else if (eqName && CRS::getPrivate()->implicitCS_ && + } else if (objects.size() == 1 && + CRS::getPrivate()->implicitCS_ && coordinateSystem() ->axisList()[0] ->unit() @@ -3759,11 +3760,11 @@ ProjectedCRS::identify(const io::AuthorityFactoryPtr &authorityFactory) const { derivingConversionRef()->_isEquivalentTo( crs->derivingConversionRef().get(), util::IComparable::Criterion::EQUIVALENT, - dbContext) && - objects.size() == 1) { + dbContext)) { res.clear(); - res.emplace_back(crsNN, - crs->nameStr() == thisName ? 100 : 90); + res.emplace_back(crsNN, crs->nameStr() == thisName + ? 100 + : eqName ? 90 : 70); return res; } else { res.emplace_back(crsNN, 25); diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index 4a4c0511..7d6705cb 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -2500,6 +2500,31 @@ TEST(crs, projectedCRS_identify_db) { EXPECT_EQ(res.front().first->getEPSGCode(), 2876); EXPECT_EQ(res.front().second, 100); } + { + // Test case of https://github.com/OSGeo/PROJ/issues/2099 + // The name of the CRS to identify is + // JGD2011_Japan_Zone_2 + // whereas the official ESRI alias is + // JGD_2011_Japan_Zone_2 + auto obj = WKTParser().attachDatabaseContext(dbContext).createFromWKT( + "PROJCS[\"JGD2011_Japan_Zone_2\",GEOGCS[\"GCS_JGD_2011\"," + "DATUM[\"D_JGD_2011\"," + "SPHEROID[\"GRS_1980\",6378137.0,298.257222101]]," + "PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]," + "PROJECTION[\"Transverse_Mercator\"]," + "PARAMETER[\"False_Easting\",0.0]," + "PARAMETER[\"False_Northing\",0.0]," + "PARAMETER[\"Central_Meridian\",131]," + "PARAMETER[\"Scale_Factor\",0.9999]," + "PARAMETER[\"Latitude_Of_Origin\",33],UNIT[\"Meter\",1.0]]"); + auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); + ASSERT_TRUE(crs != nullptr); + auto factoryAll = AuthorityFactory::create(dbContext, std::string()); + auto res = crs->identify(factoryAll); + ASSERT_EQ(res.size(), 1U); + EXPECT_EQ(res.front().first->getEPSGCode(), 6670); + EXPECT_EQ(res.front().second, 70); + } } // --------------------------------------------------------------------------- |
