diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-12 10:58:55 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-10-12 10:58:55 +0200 |
| commit | 4387332ea628282570d712d5b4b6dccc2ea5e604 (patch) | |
| tree | 6ee6f4dc7f403fe38479c7eaf915c9e8e61be3c6 /src/iso19111 | |
| parent | 6a877010114b7ccc12d017989500fa5f12f9e39c (diff) | |
| download | PROJ-4387332ea628282570d712d5b4b6dccc2ea5e604.tar.gz PROJ-4387332ea628282570d712d5b4b6dccc2ea5e604.zip | |
Fix export to WKT1:ESRI of CRS, datum, ellipsoids name that don't have a EPSG equivalent and have parentheses in their name
Diffstat (limited to 'src/iso19111')
| -rw-r--r-- | src/iso19111/crs.cpp | 61 | ||||
| -rw-r--r-- | src/iso19111/datum.cpp | 48 |
2 files changed, 98 insertions, 11 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index 6d213bc6..0d157da1 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -1828,15 +1828,16 @@ static bool exportAsESRIWktCompoundCRSWithEllipsoidalHeight( return false; } const auto l_datum = geodCRS->datumNonNull(formatter->databaseContext()); - auto l_alias = dbContext->getAliasFromOfficialName( + auto l_esri_name = dbContext->getAliasFromOfficialName( l_datum->nameStr(), "geodetic_datum", "ESRI"); - if (l_alias.empty()) { - return false; + if (l_esri_name.empty()) { + l_esri_name = l_datum->nameStr(); } auto authFactory = io::AuthorityFactory::create(NN_NO_CHECK(dbContext), std::string()); auto list = authFactory->createObjectsFromName( - l_alias, {io::AuthorityFactory::ObjectType::GEODETIC_REFERENCE_FRAME}, + l_esri_name, + {io::AuthorityFactory::ObjectType::GEODETIC_REFERENCE_FRAME}, false /* approximate=false*/); if (list.empty()) { return false; @@ -1983,6 +1984,18 @@ void GeodeticCRS::_exportToWKT(io::WKTFormatter *formatter) const { aliasFound = true; } } + if (!aliasFound && dbContext) { + auto authFactory = io::AuthorityFactory::create( + NN_NO_CHECK(dbContext), "ESRI"); + aliasFound = + authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType::GEODETIC_CRS}, + false // approximateMatch + ) + .size() == 1; + } if (!aliasFound) { l_name = io::WKTFormatter::morphNameToESRI(l_name); if (!starts_with(l_name, "GCS_")) { @@ -3266,6 +3279,18 @@ void VerticalCRS::_exportToWKT(io::WKTFormatter *formatter) const { aliasFound = true; } } + if (!aliasFound && dbContext) { + auto authFactory = + io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI"); + aliasFound = + authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType::VERTICAL_CRS}, + false // approximateMatch + ) + .size() == 1; + } if (!aliasFound) { l_name = io::WKTFormatter::morphNameToESRI(l_name); } @@ -3966,10 +3991,24 @@ void ProjectedCRS::_exportToWKT(io::WKTFormatter *formatter) const { "Projected 3D CRS can only be exported since WKT2:2019"); } - std::string l_alias; + std::string l_esri_name; if (formatter->useESRIDialect() && dbContext) { - l_alias = dbContext->getAliasFromOfficialName(l_name, "projected_crs", - "ESRI"); + l_esri_name = dbContext->getAliasFromOfficialName( + l_name, "projected_crs", "ESRI"); + if (l_esri_name.empty()) { + auto authFactory = + io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI"); + const bool found = + authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType::PROJECTED_CRS}, + false // approximateMatch + ) + .size() == 1; + if (found) + l_esri_name = l_name; + } } if (!isWKT2 && formatter->useESRIDialect() && !l_identifiers.empty() && @@ -3991,12 +4030,12 @@ void ProjectedCRS::_exportToWKT(io::WKTFormatter *formatter) const { } } catch (const std::exception &) { } - } else if (!isWKT2 && formatter->useESRIDialect() && !l_alias.empty()) { + } else if (!isWKT2 && formatter->useESRIDialect() && !l_esri_name.empty()) { try { auto res = io::AuthorityFactory::create(NN_NO_CHECK(dbContext), "ESRI") ->createObjectsFromName( - l_alias, + l_esri_name, {io::AuthorityFactory::ObjectType::PROJECTED_CRS}, false); if (res.size() == 1) { @@ -4075,10 +4114,10 @@ void ProjectedCRS::_exportToWKT(io::WKTFormatter *formatter) const { !l_identifiers.empty()); if (formatter->useESRIDialect()) { - if (l_alias.empty()) { + if (l_esri_name.empty()) { l_name = io::WKTFormatter::morphNameToESRI(l_name); } else { - l_name = l_alias; + l_name = l_esri_name; } } if (!isWKT2 && !formatter->useESRIDialect() && isDeprecated()) { diff --git a/src/iso19111/datum.cpp b/src/iso19111/datum.cpp index ebef94a2..7c76061e 100644 --- a/src/iso19111/datum.cpp +++ b/src/iso19111/datum.cpp @@ -363,6 +363,18 @@ void PrimeMeridian::_exportToWKT( aliasFound = true; } } + if (!aliasFound && dbContext) { + auto authFactory = io::AuthorityFactory::create( + NN_NO_CHECK(dbContext), "ESRI"); + aliasFound = + authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType::PRIME_MERIDIAN}, + false // approximateMatch + ) + .size() == 1; + } if (!aliasFound) { l_name = io::WKTFormatter::morphNameToESRI(l_name); } @@ -820,6 +832,18 @@ void Ellipsoid::_exportToWKT( aliasFound = true; } } + if (!aliasFound && dbContext) { + auto authFactory = io::AuthorityFactory::create( + NN_NO_CHECK(dbContext), "ESRI"); + aliasFound = authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType:: + ELLIPSOID}, + false // approximateMatch + ) + .size() == 1; + } if (!aliasFound) { l_name = io::WKTFormatter::morphNameToESRI(l_name); } @@ -1247,6 +1271,18 @@ void GeodeticReferenceFrame::_exportToWKT( } } } + if (!aliasFound && dbContext) { + auto authFactory = io::AuthorityFactory::create( + NN_NO_CHECK(dbContext), "ESRI"); + aliasFound = authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType:: + GEODETIC_REFERENCE_FRAME}, + false // approximateMatch + ) + .size() == 1; + } if (!aliasFound) { l_name = io::WKTFormatter::morphNameToESRI(l_name); if (!starts_with(l_name, "D_")) { @@ -1985,6 +2021,18 @@ void VerticalReferenceFrame::_exportToWKT( aliasFound = true; } } + if (!aliasFound && dbContext) { + auto authFactory = io::AuthorityFactory::create( + NN_NO_CHECK(dbContext), "ESRI"); + aliasFound = authFactory + ->createObjectsFromName( + l_name, + {io::AuthorityFactory::ObjectType:: + VERTICAL_REFERENCE_FRAME}, + false // approximateMatch + ) + .size() == 1; + } if (!aliasFound) { l_name = io::WKTFormatter::morphNameToESRI(l_name); } |
