diff options
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 2 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 39 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 28 |
3 files changed, 59 insertions, 10 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index 63b11761..33210d24 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -2443,7 +2443,7 @@ bool ParameterValue::_isEquivalentTo(const util::IComparable *other, } switch (type()) { case Type::MEASURE: { - return value()._isEquivalentTo(otherPV->value(), criterion); + return value()._isEquivalentTo(otherPV->value(), criterion, 2e-10); } case Type::STRING: diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index c57014d9..6a1d7e32 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -3689,6 +3689,15 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { auto props = buildProperties(node); + auto &csNode = nodeP->lookForChild(WKTConstants::CS_); + const auto &nodeValue = nodeP->value(); + if (isNull(csNode) && !ci_equal(nodeValue, WKTConstants::PROJCS) && + !ci_equal(nodeValue, WKTConstants::BASEPROJCRS)) { + ThrowMissing(WKTConstants::CS_); + } + auto cs = buildCS(csNode, node, UnitOfMeasure::NONE); + auto cartesianCS = nn_dynamic_pointer_cast<CartesianCS>(cs); + const std::string projCRSName = stripQuotes(nodeP->children()[0]); if (esriStyle_ && dbContext_) { // It is likely that the ESRI definition of EPSG:32661 (UPS North) & @@ -3709,6 +3718,27 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { projCRSName, "projected_crs", "ESRI", false, outTableName, authNameFromAlias, codeFromAlias); if (!officialName.empty()) { + // Special case for https://github.com/OSGeo/PROJ/issues/2086 + // The name of the CRS to identify is + // NAD_1983_HARN_StatePlane_Colorado_North_FIPS_0501 + // whereas it should be + // NAD_1983_HARN_StatePlane_Colorado_North_FIPS_0501_Feet + constexpr double US_FOOT_CONV_FACTOR = 12.0 / 39.37; + if (projCRSName.find("_FIPS_") != std::string::npos && + projCRSName.find("_Feet") == std::string::npos && + std::fabs( + cartesianCS->axisList()[0]->unit().conversionToSI() - + US_FOOT_CONV_FACTOR) < 1e-10 * US_FOOT_CONV_FACTOR) { + auto officialNameFromFeet = + authFactory->getOfficialNameFromAlias( + projCRSName + "_Feet", "projected_crs", "ESRI", + false, outTableName, authNameFromAlias, + codeFromAlias); + if (!officialNameFromFeet.empty()) { + officialName = officialNameFromFeet; + } + } + props.set(IdentifiedObject::NAME_KEY, officialName); } } @@ -3739,15 +3769,6 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { ? buildConversion(conversionNode, linearUnit, angularUnit) : buildProjection(node, projectionNode, linearUnit, angularUnit); - auto &csNode = nodeP->lookForChild(WKTConstants::CS_); - const auto &nodeValue = nodeP->value(); - if (isNull(csNode) && !ci_equal(nodeValue, WKTConstants::PROJCS) && - !ci_equal(nodeValue, WKTConstants::BASEPROJCRS)) { - ThrowMissing(WKTConstants::CS_); - } - auto cs = buildCS(csNode, node, UnitOfMeasure::NONE); - auto cartesianCS = nn_dynamic_pointer_cast<CartesianCS>(cs); - // No explicit AXIS node ? (WKT1) if (isNull(nodeP->lookForChild(WKTConstants::AXIS))) { props.set("IMPLICIT_CS", true); diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index 5f35a5e6..13ddc587 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -2472,6 +2472,34 @@ TEST(crs, projectedCRS_identify_db) { EXPECT_EQ(res.front().first->getEPSGCode(), 2193); EXPECT_EQ(res.front().second, 90); } + { + // Special case for https://github.com/OSGeo/PROJ/issues/2086 + // The name of the CRS to identify is + // NAD_1983_HARN_StatePlane_Colorado_North_FIPS_0501 + // whereas it should be + // NAD_1983_HARN_StatePlane_Colorado_North_FIPS_0501_Feet + auto obj = WKTParser().attachDatabaseContext(dbContext).createFromWKT( + "PROJCS[\"NAD_1983_HARN_StatePlane_Colorado_North_FIPS_0501\"," + "GEOGCS[\"GCS_North_American_1983_HARN\"," + "DATUM[\"D_North_American_1983_HARN\",SPHEROID[\"GRS_1980\"," + "6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0]," + "UNIT[\"Degree\",0.0174532925199433]]," + "PROJECTION[\"Lambert_Conformal_Conic\"]," + "PARAMETER[\"False_Easting\",3000000.000316083]," + "PARAMETER[\"False_Northing\",999999.999996]," + "PARAMETER[\"Central_Meridian\",-105.5]," + "PARAMETER[\"Standard_Parallel_1\",39.71666666666667]," + "PARAMETER[\"Standard_Parallel_2\",40.78333333333333]," + "PARAMETER[\"Latitude_Of_Origin\",39.33333333333334]," + "UNIT[\"Foot_US\",0.3048006096012192]]"); + auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); + ASSERT_TRUE(crs != nullptr); + auto factoryAll = AuthorityFactory::create(dbContext, std::string()); + auto res = crs->identify(factoryAll); + ASSERT_EQ(res.size(), 1U); + EXPECT_EQ(res.front().first->getEPSGCode(), 2876); + EXPECT_EQ(res.front().second, 100); + } } // --------------------------------------------------------------------------- |
