diff options
Diffstat (limited to 'src/iso19111/io.cpp')
| -rw-r--r-- | src/iso19111/io.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index aa676c3d..6ec0617c 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -3650,13 +3650,13 @@ ConversionNNPtr WKTParser::Private::buildProjectionStandard( // --------------------------------------------------------------------------- -static ProjectedCRSNNPtr createPseudoMercator(const PropertyMap &props) { +static ProjectedCRSNNPtr createPseudoMercator(const PropertyMap &props, + const cs::CartesianCSNNPtr &cs) { auto conversion = Conversion::createPopularVisualisationPseudoMercator( PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), Angle(0), Angle(0), Length(0), Length(0)); - return ProjectedCRS::create( - props, GeographicCRS::EPSG_4326, conversion, - CartesianCS::createEastingNorthing(UnitOfMeasure::METRE)); + return ProjectedCRS::create(props, GeographicCRS::EPSG_4326, conversion, + cs); } // --------------------------------------------------------------------------- @@ -3682,6 +3682,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) & @@ -3707,21 +3716,22 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { } } - if (isNull(conversionNode) && hasWebMercPROJ4String(node, projectionNode)) { + if (isNull(conversionNode) && hasWebMercPROJ4String(node, projectionNode) && + cartesianCS) { toWGS84Parameters_.clear(); - return createPseudoMercator(props); + return createPseudoMercator(props, NN_NO_CHECK(cartesianCS)); } // WGS_84_Pseudo_Mercator: Particular case for corrupted ESRI WKT generated // by older GDAL versions // https://trac.osgeo.org/gdal/changeset/30732 // WGS_1984_Web_Mercator: deprecated ESRI:102113 - if (metadata::Identifier::isEquivalentName(projCRSName.c_str(), - "WGS_84_Pseudo_Mercator") || - metadata::Identifier::isEquivalentName(projCRSName.c_str(), - "WGS_1984_Web_Mercator")) { + if (cartesianCS && (metadata::Identifier::isEquivalentName( + projCRSName.c_str(), "WGS_84_Pseudo_Mercator") || + metadata::Identifier::isEquivalentName( + projCRSName.c_str(), "WGS_1984_Web_Mercator"))) { toWGS84Parameters_.clear(); - return createPseudoMercator(props); + return createPseudoMercator(props, NN_NO_CHECK(cartesianCS)); } auto linearUnit = buildUnitInSubNode(node, UnitOfMeasure::Type::LINEAR); @@ -3733,15 +3743,6 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { : buildProjection(baseGeodCRS, 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); @@ -8597,6 +8598,7 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS( auto axisType = AxisType::REGULAR; bool bWebMercator = false; + std::string webMercatorName("WGS 84 / Pseudo-Mercator"); if (step.name == "tmerc" && ((getParamValue(step, "axis") == "wsu" && iAxisSwap < 0) || @@ -8685,6 +8687,11 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS( getAngularValue(getParamValue(step, "x_0")) == 0.0 && getAngularValue(getParamValue(step, "y_0")) == 0.0) { bWebMercator = true; + if (hasParamValue(step, "units") && + getParamValue(step, "units") != "m") { + webMercatorName += + " (unit " + getParamValue(step, "units") + ')'; + } } } else if (hasParamValue(step, "lat_ts")) { mapping = getMapping(EPSG_CODE_METHOD_MERCATOR_VARIANT_B); @@ -8968,8 +8975,8 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS( CRSNNPtr crs = bWebMercator - ? createPseudoMercator(props.set(IdentifiedObject::NAME_KEY, - "WGS 84 / Pseudo-Mercator")) + ? createPseudoMercator( + props.set(IdentifiedObject::NAME_KEY, webMercatorName), cs) : ProjectedCRS::create(props, geogCRS, NN_NO_CHECK(conv), cs); if (!hasParamValue(step, "geoidgrids") && |
