diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-11-23 16:54:48 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-11-23 16:56:44 +0100 |
| commit | b503c2e5ae4b90da5e390be929ab5a37ab534232 (patch) | |
| tree | 50e8944b6e1eefe5d6cf1f4187dc26cb6236264e | |
| parent | 765faba8984aa1e5f2a91853d18f0453e7bed105 (diff) | |
| download | PROJ-b503c2e5ae4b90da5e390be929ab5a37ab534232.tar.gz PROJ-b503c2e5ae4b90da5e390be929ab5a37ab534232.zip | |
GeographicCRS::_isEquivalentTo(EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS): make it work when comparing easting,northing,up and northing,easting,up
| -rw-r--r-- | src/iso19111/crs.cpp | 21 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 47 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp index de882105..5d2c6d7b 100644 --- a/src/iso19111/crs.cpp +++ b/src/iso19111/crs.cpp @@ -2522,6 +2522,27 @@ bool GeographicCRS::_isEquivalentTo( ->GeodeticCRS::_isEquivalentToNoTypeCheck(other, standardCriterion, dbContext); } + if (axisOrder == + cs::EllipsoidalCS::AxisOrder::LONG_EAST_LAT_NORTH_HEIGHT_UP || + axisOrder == + cs::EllipsoidalCS::AxisOrder::LAT_NORTH_LONG_EAST_HEIGHT_UP) { + const auto &angularUnit = coordinateSystem()->axisList()[0]->unit(); + const auto &linearUnit = coordinateSystem()->axisList()[2]->unit(); + return GeographicCRS::create( + util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, + nameStr()), + datum(), datumEnsemble(), + axisOrder == cs::EllipsoidalCS::AxisOrder:: + LONG_EAST_LAT_NORTH_HEIGHT_UP + ? cs::EllipsoidalCS:: + createLatitudeLongitudeEllipsoidalHeight( + angularUnit, linearUnit) + : cs::EllipsoidalCS:: + createLongitudeLatitudeEllipsoidalHeight( + angularUnit, linearUnit)) + ->GeodeticCRS::_isEquivalentToNoTypeCheck(other, standardCriterion, + dbContext); + } return false; } //! @endcond diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index aea72da2..e470a621 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -2107,6 +2107,53 @@ TEST(crs, projectedCRS_as_PROJ_string) { // --------------------------------------------------------------------------- +TEST(crs, projectedCRS_3D_is_WKT1_equivalent_to_WKT2) { + auto dbContext = DatabaseContext::create(); + + // "Illegal" WKT1 with a Projected 3D CRS + auto wkt1 = "PROJCS[\"WGS 84 / UTM zone 16N [EGM08-1]\"," + "GEOGCS[\"WGS 84 / UTM zone 16N [EGM08-1]\"," + "DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.257223563," + "AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]]," + "PRIMEM[\"Greenwich\",0.0000000000000000," + "AUTHORITY[\"EPSG\",\"8901\"]]," + "UNIT[\"Degree\",0.01745329251994329547," + "AUTHORITY[\"EPSG\",\"9102\"]],AUTHORITY[\"EPSG\",\"32616\"]]," + "UNIT[\"Meter\",1.00000000000000000000," + "AUTHORITY[\"EPSG\",\"9001\"]]," + "PROJECTION[\"Transverse_Mercator\"]," + "PARAMETER[\"latitude_of_origin\",0.0000000000000000]," + "PARAMETER[\"central_meridian\",-87.0000000002777938]," + "PARAMETER[\"scale_factor\",0.9996000000000000]," + "PARAMETER[\"false_easting\",500000.000]," + "PARAMETER[\"false_northing\",0.000]," + "AXIS[\"Easting\",EAST]," + "AXIS[\"Northing\",NORTH]," + "AXIS[\"Height\",UP]," + "AUTHORITY[\"EPSG\",\"32616\"]]"; + + auto obj = WKTParser() + .setStrict(false) + .attachDatabaseContext(dbContext) + .createFromWKT(wkt1); + auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); + ASSERT_TRUE(crs != nullptr); + + WKTFormatterNNPtr f( + WKTFormatter::create(WKTFormatter::Convention::WKT2_2019)); + auto wkt2 = crs->exportToWKT(f.get()); + auto obj2 = + WKTParser().attachDatabaseContext(dbContext).createFromWKT(wkt2); + auto crs2 = nn_dynamic_pointer_cast<ProjectedCRS>(obj2); + ASSERT_TRUE(crs2 != nullptr); + + EXPECT_TRUE(crs->isEquivalentTo( + crs2.get(), + IComparable::Criterion::EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS)); +} + +// --------------------------------------------------------------------------- + TEST(crs, projectedCRS_Krovak_EPSG_5221_as_PROJ_string) { auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); auto crs = factory->createProjectedCRS("5221"); |
