aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-12-09 09:08:13 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-12-09 09:08:13 +0100
commit5cc1095970127f8df5c4f636b1ce782829510fa0 (patch)
tree3635584127530c730223f1b1aec2ee91be9aae73
parentb6f0153e5aa27dc11d2c879dc4a62a0f35a122cb (diff)
downloadPROJ-5cc1095970127f8df5c4f636b1ce782829510fa0.tar.gz
PROJ-5cc1095970127f8df5c4f636b1ce782829510fa0.zip
CRS identification: use case insensitive comparison for authority name (fixes #1779)
-rw-r--r--src/iso19111/factory.cpp14
-rw-r--r--src/iso19111/io.cpp5
-rw-r--r--test/unit/test_crs.cpp32
3 files changed, 44 insertions, 7 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 57850303..0ef07337 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -1433,9 +1433,17 @@ AuthorityFactory::AuthorityFactory(const DatabaseContextNNPtr &context,
AuthorityFactoryNNPtr
AuthorityFactory::create(const DatabaseContextNNPtr &context,
const std::string &authorityName) {
-
- auto factory = AuthorityFactory::nn_make_shared<AuthorityFactory>(
- context, authorityName);
+ const auto getFactory = [&context, &authorityName]() {
+ for (const auto &knownName : {"EPSG", "ESRI", "PROJ"}) {
+ if (ci_equal(authorityName, knownName)) {
+ return AuthorityFactory::nn_make_shared<AuthorityFactory>(
+ context, knownName);
+ }
+ }
+ return AuthorityFactory::nn_make_shared<AuthorityFactory>(
+ context, authorityName);
+ };
+ auto factory = getFactory();
factory->d->setThis(factory);
return factory;
}
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index 2aec5fac..e0e6152a 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -5669,10 +5669,7 @@ static BaseObjectNNPtr createFromUserInput(const std::string &text,
DatabaseContextNNPtr dbContextNNPtr(NN_NO_CHECK(dbContext));
const auto &authName = tokens[0];
const auto &code = tokens[1];
- static const std::string epsg_lowercase("epsg");
- auto factory = AuthorityFactory::create(
- dbContextNNPtr,
- authName == epsg_lowercase ? Identifier::EPSG : authName);
+ auto factory = AuthorityFactory::create(dbContextNNPtr, authName);
try {
return factory->createCoordinateReferenceSystem(code);
} catch (...) {
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 427fd741..e896853f 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -2281,6 +2281,38 @@ TEST(crs, projectedCRS_identify_db) {
// ---------------------------------------------------------------------------
+TEST(crs, projectedCRS_identify_wrong_auth_name_case) {
+ auto dbContext = DatabaseContext::create();
+ auto factoryAnonymous = AuthorityFactory::create(dbContext, std::string());
+ auto obj =
+ WKTParser()
+ .attachDatabaseContext(dbContext)
+ .setStrict(false)
+ .createFromWKT(
+ "PROJCS[\"World_Cylindrical_Equal_Area\","
+ "GEOGCS[\"GCS_WGS_1984\","
+ "DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\","
+ "6378137.0,298.257223563]],"
+ "PRIMEM[\"Greenwich\",0.0],"
+ "UNIT[\"Degree\",0.0174532925199433]],"
+ "PROJECTION[\"Cylindrical_Equal_Area\"],"
+ "PARAMETER[\"False_Easting\",0.0],"
+ "PARAMETER[\"False_Northing\",0.0],"
+ "PARAMETER[\"Central_Meridian\",0.0],"
+ "PARAMETER[\"Standard_Parallel_1\",0.0],UNIT[\"Meter\",1.0],"
+ "AUTHORITY[\"Esri\",54034]]"); // should be ESRI all caps
+ auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ auto res = crs->identify(factoryAnonymous);
+ ASSERT_EQ(res.size(), 1U);
+ const auto &ids = res.front().first->identifiers();
+ ASSERT_EQ(ids.size(), 1U);
+ EXPECT_EQ(*(ids.front()->codeSpace()), "ESRI");
+ EXPECT_EQ(ids.front()->code(), "54034");
+}
+
+// ---------------------------------------------------------------------------
+
TEST(crs, mercator_1SP_as_WKT1_ESRI) {
auto obj = PROJStringParser().createFromPROJString(