diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-10-06 17:49:14 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-10-08 17:31:56 +0200 |
| commit | fece8a6c6e2e5eebeac6f9b4fc47ca830f2e3a3a (patch) | |
| tree | 22bfeccc0dba39dae899473177ef74e5599cf5e9 | |
| parent | e51a7db2bd5322463f8a7d345fb972bfd91ad921 (diff) | |
| download | PROJ-fece8a6c6e2e5eebeac6f9b4fc47ca830f2e3a3a.tar.gz PROJ-fece8a6c6e2e5eebeac6f9b4fc47ca830f2e3a3a.zip | |
Database: add aliases for 'old' names of WGS84 and ETRS89 datums, and remove one hack
| -rw-r--r-- | data/sql/commit.sql | 9 | ||||
| -rw-r--r-- | data/sql/customizations.sql | 6 | ||||
| -rw-r--r-- | src/iso19111/factory.cpp | 34 |
3 files changed, 33 insertions, 16 deletions
diff --git a/data/sql/commit.sql b/data/sql/commit.sql index 53c571b6..5e1d69ff 100644 --- a/data/sql/commit.sql +++ b/data/sql/commit.sql @@ -58,6 +58,15 @@ FOR EACH ROW BEGIN d.auth_name = ensemble_auth_name AND d.code = ensemble_code) ); + SELECT RAISE(ABORT, 'PROJ defines an alias that exists in EPSG') + WHERE EXISTS ( + SELECT * FROM ( + SELECT count(*) AS count, table_name, auth_name, code, alt_name FROM alias_name + WHERE source in ('EPSG', 'PROJ') + AND NOT (source = 'PROJ' AND alt_name IN ('GGRS87', 'NAD27', 'NAD83')) + GROUP BY table_name, auth_name, code, alt_name) x WHERE count > 1 + ); + -- test to check that our custom grid transformation overrides are really needed SELECT RAISE(ABORT, 'PROJ grid_transformation defined whereas EPSG has one') WHERE EXISTS (SELECT 1 FROM grid_transformation g1 diff --git a/data/sql/customizations.sql b/data/sql/customizations.sql index e7e7b47e..32b3b163 100644 --- a/data/sql/customizations.sql +++ b/data/sql/customizations.sql @@ -374,6 +374,12 @@ INSERT INTO "alias_name" VALUES('geodetic_datum','EPSG','6277','OSGB36','PROJ'); -- to the EPSG:4326 CRS, as this is a common use case (https://github.com/OSGeo/PROJ/issues/2216) INSERT INTO "alias_name" VALUES('geodetic_crs','EPSG','4326','WGS84','PROJ'); +---- Aliases from old datum names to new datum ensemble names ----- + +-- Those have been reported to IOGP and will hopefully be integrated in a later EPSG release +INSERT INTO "alias_name" VALUES('geodetic_datum','EPSG','6326','World Geodetic System 1984','PROJ'); +INSERT INTO "alias_name" VALUES('geodetic_datum','EPSG','6258','European Terrestrial Reference System 1989','PROJ'); + ---- PROJ unit short names ----- -- Linear units diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 5d0ed69a..46657431 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -1064,16 +1064,6 @@ std::string DatabaseContext::getOldProjGridName(const std::string &gridName) { // --------------------------------------------------------------------------- -// FIXME: as we don't support datum ensemble yet, remove it from name -static std::string addEnsembleSuffix(const std::string &name) { - if (name == "World Geodetic System 1984") { - return "World Geodetic System 1984 ensemble"; - } else if (name == "European Terrestrial Reference System 1989") { - return "European Terrestrial Reference System 1989 ensemble"; - } - return name; -} - // FIXME: as we don't support datum ensemble yet, add it from name static std::string removeEnsembleSuffix(const std::string &name) { if (name == "World Geodetic System 1984 ensemble") { @@ -1104,9 +1094,15 @@ DatabaseContext::getAliasFromOfficialName(const std::string &officialName, if (tableName == "geodetic_crs") { sql += " AND type = " GEOG_2D_SINGLE_QUOTED; } - auto res = d->run(sql, {addEnsembleSuffix(officialName)}); + auto res = d->run(sql, {officialName}); if (res.empty()) { - return std::string(); + res = d->run( + "SELECT auth_name, code FROM alias_name WHERE table_name = ? AND " + "alt_name = ? AND source IN ('EPSG', 'PROJ')", + {tableName, officialName}); + if (res.size() != 1) { + return std::string(); + } } const auto &row = res.front(); res = d->run("SELECT alt_name FROM alias_name WHERE table_name = ? AND " @@ -1151,10 +1147,16 @@ std::list<std::string> DatabaseContext::getAliases( if (tableName == "geodetic_crs") { sql += " AND type = " GEOG_2D_SINGLE_QUOTED; } - auto resSql = d->run(sql, {addEnsembleSuffix(officialName)}); + auto resSql = d->run(sql, {officialName}); if (resSql.empty()) { - d->cacheAliasNames_.insert(key, res); - return res; + resSql = d->run("SELECT auth_name, code FROM alias_name WHERE " + "table_name = ? AND " + "alt_name = ? AND source IN ('EPSG', 'PROJ')", + {tableName, officialName}); + if (resSql.size() != 1) { + d->cacheAliasNames_.insert(key, res); + return res; + } } const auto &row = resSql.front(); resolvedAuthName = row[0]; @@ -5613,7 +5615,7 @@ AuthorityFactory::createObjectsFromNameEx( const std::string &searchedName, const std::vector<ObjectType> &allowedObjectTypes, bool approximateMatch, size_t limitResultCount) const { - std::string searchedNameWithoutDeprecated(addEnsembleSuffix(searchedName)); + std::string searchedNameWithoutDeprecated(searchedName); bool deprecated = false; if (ends_with(searchedNameWithoutDeprecated, " (deprecated)")) { deprecated = true; |
