diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-01 17:29:19 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-01 17:53:15 +0100 |
| commit | 18dbc00dc30db7ca5fa7bd6a00115628324dcd0c (patch) | |
| tree | 79da69c780a09929397179dc1e2bd37a10dfe6ad | |
| parent | fa11a21801ac1f8afaa768390c46f5226089b090 (diff) | |
| download | PROJ-18dbc00dc30db7ca5fa7bd6a00115628324dcd0c.tar.gz PROJ-18dbc00dc30db7ca5fa7bd6a00115628324dcd0c.zip | |
importFromWKT: deal with uncommon formulation of EPSG:3857
| -rw-r--r-- | src/io.cpp | 28 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 38 |
2 files changed, 59 insertions, 7 deletions
@@ -3299,6 +3299,18 @@ ConversionNNPtr WKTParser::Private::buildProjectionStandard( // --------------------------------------------------------------------------- +static ProjectedCRSNNPtr createPseudoMercator(PropertyMap &props) { + auto conversion = Conversion::createPopularVisualisationPseudoMercator( + PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), Angle(0), + Angle(0), Length(0), Length(0)); + props.set(IdentifiedObject::NAME_KEY, "WGS 84 / Pseudo-Mercator"); + return ProjectedCRS::create( + props, GeographicCRS::EPSG_4326, conversion, + CartesianCS::createEastingNorthing(UnitOfMeasure::METRE)); +} + +// --------------------------------------------------------------------------- + ProjectedCRSNNPtr WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { @@ -3312,13 +3324,15 @@ WKTParser::Private::buildProjectedCRS(const WKTNodeNNPtr &node) { auto props = buildProperties(node); if (isNull(conversionNode) && hasWebMercPROJ4String(node, projectionNode)) { - auto conversion = Conversion::createPopularVisualisationPseudoMercator( - PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), Angle(0), - Angle(0), Length(0), Length(0)); - props.set(IdentifiedObject::NAME_KEY, "WGS 84 / Pseudo-Mercator"); - return ProjectedCRS::create( - props, GeographicCRS::EPSG_4326, conversion, - CartesianCS::createEastingNorthing(UnitOfMeasure::METRE)); + return createPseudoMercator(props); + } + + const std::string projectedCRSName = stripQuotes(nodeP->children()[0]); + // Particular case for corrupted ESRI WKT generated by older GDAL versions + // https://trac.osgeo.org/gdal/changeset/30732 + if (metadata::Identifier::isEquivalentName(projectedCRSName.c_str(), + "WGS_84_Pseudo_Mercator")) { + return createPseudoMercator(props); } auto &baseGeodCRSNode = diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index c2e35e89..bb8221fd 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -3187,6 +3187,44 @@ TEST(operation, webmerc_import_from_WKT2_EPSG_3785_deprecated) { // --------------------------------------------------------------------------- +TEST(operation, webmerc_import_from_broken_esri_WGS_84_Pseudo_Mercator) { + + // Likely the result of a broken export of GDAL morphToESRI() + auto wkt1 = "PROJCS[\"WGS_84_Pseudo_Mercator\",GEOGCS[\"GCS_WGS_1984\"," + "DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\"," + "6378137,298.257223563]],PRIMEM[\"Greenwich\",0]," + "UNIT[\"Degree\",0.017453292519943295]]," + "PROJECTION[\"Mercator\"],PARAMETER[\"central_meridian\",0]," + "PARAMETER[\"false_easting\",0]," + "PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]," + "PARAMETER[\"standard_parallel_1\",0.0]]"; + + auto obj = WKTParser().createFromWKT(wkt1); + auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); + ASSERT_TRUE(crs != nullptr); + + auto convGot = crs->derivingConversion(); + + EXPECT_EQ(convGot->exportToWKT(WKTFormatter::create().get()), + "CONVERSION[\"unnamed\",\n" + " METHOD[\"Popular Visualisation Pseudo Mercator\",\n" + " ID[\"EPSG\",1024]],\n" + " PARAMETER[\"Latitude of natural origin\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8801]],\n" + " PARAMETER[\"Longitude of natural origin\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8802]],\n" + " PARAMETER[\"False easting\",0,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8806]],\n" + " PARAMETER[\"False northing\",0,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8807]]]"); +} + +// --------------------------------------------------------------------------- + TEST(operation, mollweide_export) { auto conv = Conversion::createMollweide(PropertyMap(), Angle(1), Length(2), |
