Skip to content

Commit

Permalink
Merge pull request #3638 from OSGeo/backport-3636-to-9.2
Browse files Browse the repository at this point in the history
[Backport 9.2] WKT_ESRI export: do not export NAD83 3D as NAD83(HARN)
  • Loading branch information
rouault authored Feb 23, 2023
2 parents db21919 + 01c14c7 commit 861a85d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3422,7 +3422,11 @@ DatabaseContext::getAliasFromOfficialName(const std::string &officialName,
}
sql += " ORDER BY deprecated";
auto res = d->run(sql, {officialName});
if (res.empty()) {
// Sorry for the hack excluding NAD83 + geographic_3D_crs, but otherwise
// EPSG has a weird alias from NAD83 to EPSG:4152 which happens to be
// NAD83(HARN), and that's definitely not desirable.
if (res.empty() &&
!(officialName == "NAD83" && tableName == "geographic_3D_crs")) {
res = d->run(
"SELECT auth_name, code FROM alias_name WHERE table_name = ? AND "
"alt_name = ? AND source IN ('EPSG', 'PROJ')",
Expand Down
25 changes: 25 additions & 0 deletions test/unit/test_crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,31 @@ TEST(crs, geographic3D_crs_as_WKT1_ESRI_database) {

// ---------------------------------------------------------------------------

TEST(crs, geographic3D_NAD83_as_WKT1_ESRI_database) {
auto dbContext = DatabaseContext::create();
auto obj = WKTParser().attachDatabaseContext(dbContext).createFromWKT(
"GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\","
"SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],"
"PRIMEM[\"Greenwich\",0.0],"
"UNIT[\"Degree\",0.0174532925199433]],"
"VERTCS[\"NAD_1983\",DATUM[\"D_North_American_1983\","
"SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],"
"PARAMETER[\"Vertical_Shift\",0.0],"
"PARAMETER[\"Direction\",1.0],UNIT[\"Meter\",1.0]]");
auto crs = nn_dynamic_pointer_cast<GeographicCRS>(obj);
ASSERT_TRUE(crs != nullptr);
WKTFormatterNNPtr f(
WKTFormatter::create(WKTFormatter::Convention::WKT1_ESRI, dbContext));
const auto wkt = "GEOGCS[\"GCS_NAD83\",DATUM[\"D_North_American_1983\","
"SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],"
"PRIMEM[\"Greenwich\",0.0],"
"UNIT[\"Degree\",0.0174532925199433],"
"LINUNIT[\"Meter\",1.0]]";
EXPECT_EQ(crs->exportToWKT(f.get()), wkt);
}

// ---------------------------------------------------------------------------

TEST(crs, GeographicCRS_is2DPartOf3D) {
EXPECT_TRUE(GeographicCRS::EPSG_4326->is2DPartOf3D(
NN_NO_CHECK(GeographicCRS::EPSG_4979.get())));
Expand Down

0 comments on commit 861a85d

Please sign in to comment.