diff options
| -rw-r--r-- | data/sql/alias_name.sql | 1 | ||||
| -rw-r--r-- | data/sql/conversion.sql | 2 | ||||
| -rw-r--r-- | data/sql/metadata.sql | 4 | ||||
| -rw-r--r-- | data/sql/projected_crs.sql | 2 | ||||
| -rw-r--r-- | src/iso19111/operation/concatenatedoperation.cpp | 24 | ||||
| -rw-r--r-- | src/iso19111/operation/projbasedoperation.cpp | 16 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 195 |
7 files changed, 227 insertions, 17 deletions
diff --git a/data/sql/alias_name.sql b/data/sql/alias_name.sql index 68aaf79a..1ad3048d 100644 --- a/data/sql/alias_name.sql +++ b/data/sql/alias_name.sql @@ -7515,3 +7515,4 @@ INSERT INTO "alias_name" VALUES('projected_crs','EPSG','9943','ETRS89 / EBBWV14 INSERT INTO "alias_name" VALUES('compound_crs','EPSG','9944','ETRS89 / EBBWV14 SnakeGrid + Newlyn height','EPSG'); INSERT INTO "alias_name" VALUES('compound_crs','EPSG','6190','BD72 / Belgian Lambert 72 + Oostende height','EPSG'); INSERT INTO "alias_name" VALUES('compound_crs','EPSG','9907','ETRS89 + Oostende height','EPSG'); +INSERT INTO "alias_name" VALUES('projected_crs','EPSG','32159','NAD83 / WyLam','EPSG'); diff --git a/data/sql/conversion.sql b/data/sql/conversion.sql index bc7081fa..ac7cb142 100644 --- a/data/sql/conversion.sql +++ b/data/sql/conversion.sql @@ -2303,6 +2303,8 @@ INSERT INTO "conversion" VALUES('EPSG','14903','Wyoming CS27 West Central zone', INSERT INTO "usage" VALUES('EPSG','11344','conversion','EPSG','14903','EPSG','2272','EPSG','1142'); INSERT INTO "conversion" VALUES('EPSG','14904','Wyoming CS27 West zone','','EPSG','9807','Transverse Mercator','EPSG','8801','Latitude of natural origin',40.4,'EPSG','9110','EPSG','8802','Longitude of natural origin',-110.05,'EPSG','9110','EPSG','8805','Scale factor at natural origin',0.999941177,'EPSG','9201','EPSG','8806','False easting',500000.0,'EPSG','9003','EPSG','8807','False northing',0.0,'EPSG','9003',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0); INSERT INTO "usage" VALUES('EPSG','11345','conversion','EPSG','14904','EPSG','2271','EPSG','1142'); +INSERT INTO "conversion" VALUES('EPSG','14930','Wyoming Lambert','Source originally defining the projection is unclear - possibly the Wyoming GIS Center.','EPSG','9802','Lambert Conic Conformal (2SP)','EPSG','8821','Latitude of false origin',41.0,'EPSG','9110','EPSG','8822','Longitude of false origin',-107.3,'EPSG','9110','EPSG','8823','Latitude of 1st standard parallel',41.0,'EPSG','9110','EPSG','8824','Latitude of 2nd standard parallel',45.0,'EPSG','9110','EPSG','8826','Easting at false origin',500000.0,'EPSG','9001','EPSG','8827','Northing at false origin',200000.0,'EPSG','9001',NULL,NULL,NULL,NULL,NULL,NULL,0); +INSERT INTO "usage" VALUES('EPSG','17408','conversion','EPSG','14930','EPSG','1419','EPSG','1135'); INSERT INTO "conversion" VALUES('EPSG','14931','SPCS83 Wyoming East zone (meters)','See code 14935 for equivalent non-metric definition.','EPSG','9807','Transverse Mercator','EPSG','8801','Latitude of natural origin',40.3,'EPSG','9110','EPSG','8802','Longitude of natural origin',-105.1,'EPSG','9110','EPSG','8805','Scale factor at natural origin',0.9999375,'EPSG','9201','EPSG','8806','False easting',200000.0,'EPSG','9001','EPSG','8807','False northing',0.0,'EPSG','9001',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0); INSERT INTO "usage" VALUES('EPSG','11346','conversion','EPSG','14931','EPSG','2269','EPSG','1142'); INSERT INTO "conversion" VALUES('EPSG','14932','SPCS83 Wyoming East Central zone (meters)','See code 14936 for equivalent non-metric definition.','EPSG','9807','Transverse Mercator','EPSG','8801','Latitude of natural origin',40.3,'EPSG','9110','EPSG','8802','Longitude of natural origin',-107.2,'EPSG','9110','EPSG','8805','Scale factor at natural origin',0.9999375,'EPSG','9201','EPSG','8806','False easting',400000.0,'EPSG','9001','EPSG','8807','False northing',100000.0,'EPSG','9001',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0); diff --git a/data/sql/metadata.sql b/data/sql/metadata.sql index 112d6a0c..e5f14cea 100644 --- a/data/sql/metadata.sql +++ b/data/sql/metadata.sql @@ -9,8 +9,8 @@ INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MAJOR', 1); INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MINOR', 2); -INSERT INTO "metadata" VALUES('EPSG.VERSION', 'v10.054'); -INSERT INTO "metadata" VALUES('EPSG.DATE', '2022-02-13'); +INSERT INTO "metadata" VALUES('EPSG.VERSION', 'v10.055'); +INSERT INTO "metadata" VALUES('EPSG.DATE', '2022-03-09'); -- The value of ${PROJ_VERSION} is substituted at build time by the actual -- value. diff --git a/data/sql/projected_crs.sql b/data/sql/projected_crs.sql index 18d96dea..c436fef9 100644 --- a/data/sql/projected_crs.sql +++ b/data/sql/projected_crs.sql @@ -9925,6 +9925,8 @@ INSERT INTO "projected_crs" VALUES('EPSG','32157','NAD83 / Wyoming West Central' INSERT INTO "usage" VALUES('EPSG','7244','projected_crs','EPSG','32157','EPSG','2272','EPSG','1142'); INSERT INTO "projected_crs" VALUES('EPSG','32158','NAD83 / Wyoming West',NULL,'EPSG','4499','EPSG','4269','EPSG','14934',NULL,0); INSERT INTO "usage" VALUES('EPSG','7245','projected_crs','EPSG','32158','EPSG','2271','EPSG','1142'); +INSERT INTO "projected_crs" VALUES('EPSG','32159','NAD83 / Wyoming Lambert',NULL,'EPSG','4499','EPSG','4269','EPSG','14930',NULL,0); +INSERT INTO "usage" VALUES('EPSG','17409','projected_crs','EPSG','32159','EPSG','1419','EPSG','1135'); INSERT INTO "projected_crs" VALUES('EPSG','32161','NAD83 / Puerto Rico & Virgin Is.',NULL,'EPSG','4499','EPSG','4269','EPSG','15230',NULL,0); INSERT INTO "usage" VALUES('EPSG','7246','projected_crs','EPSG','32161','EPSG','2251','EPSG','1142'); INSERT INTO "projected_crs" VALUES('EPSG','32164','NAD83 / BLM 14N (ftUS)',NULL,'EPSG','4497','EPSG','4269','EPSG','15914',NULL,0); diff --git a/src/iso19111/operation/concatenatedoperation.cpp b/src/iso19111/operation/concatenatedoperation.cpp index 7da561b4..e5728c4c 100644 --- a/src/iso19111/operation/concatenatedoperation.cpp +++ b/src/iso19111/operation/concatenatedoperation.cpp @@ -276,14 +276,28 @@ void ConcatenatedOperation::fixStepsDirection( } } + const auto extractDerivedCRS = + [](const crs::CRS *crs) -> const crs::DerivedCRS * { + auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>(crs); + if (derivedCRS) + return derivedCRS; + auto compoundCRS = dynamic_cast<const crs::CompoundCRS *>(crs); + if (compoundCRS) { + derivedCRS = dynamic_cast<const crs::DerivedCRS *>( + compoundCRS->componentReferenceSystems().front().get()); + if (derivedCRS) + return derivedCRS; + } + return nullptr; + }; + for (size_t i = 0; i < operationsInOut.size(); ++i) { auto &op = operationsInOut[i]; auto l_sourceCRS = op->sourceCRS(); auto l_targetCRS = op->targetCRS(); auto conv = dynamic_cast<const Conversion *>(op.get()); if (conv && i == 0 && !l_sourceCRS && !l_targetCRS) { - if (auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>( - concatOpSourceCRS.get())) { + if (auto derivedCRS = extractDerivedCRS(concatOpSourceCRS.get())) { if (i + 1 < operationsInOut.size()) { // use the sourceCRS of the next operation as our target CRS l_targetCRS = operationsInOut[i + 1]->sourceCRS(); @@ -323,8 +337,7 @@ void ConcatenatedOperation::fixStepsDirection( } } else if (conv && i + 1 == operationsInOut.size() && !l_sourceCRS && !l_targetCRS) { - auto derivedCRS = - dynamic_cast<const crs::DerivedCRS *>(concatOpTargetCRS.get()); + auto derivedCRS = extractDerivedCRS(concatOpTargetCRS.get()); if (derivedCRS) { if (i >= 1) { // use the sourceCRS of the previous operation as our source @@ -350,8 +363,7 @@ void ConcatenatedOperation::fixStepsDirection( } else if (i >= 1) { l_sourceCRS = operationsInOut[i - 1]->targetCRS(); if (l_sourceCRS) { - derivedCRS = dynamic_cast<const crs::DerivedCRS *>( - l_sourceCRS.get()); + derivedCRS = extractDerivedCRS(l_sourceCRS.get()); if (derivedCRS && conv->isEquivalentTo( derivedCRS->derivingConversion().get(), diff --git a/src/iso19111/operation/projbasedoperation.cpp b/src/iso19111/operation/projbasedoperation.cpp index 6e0fd109..fd03fc09 100644 --- a/src/iso19111/operation/projbasedoperation.cpp +++ b/src/iso19111/operation/projbasedoperation.cpp @@ -232,15 +232,13 @@ void PROJBasedOperation::_exportToJSON( method()->_exportToJSON(formatter); const auto &l_parameterValues = parameterValues(); - if (!l_parameterValues.empty()) { - writer->AddObjKey("parameters"); - { - auto parametersContext(writer->MakeArrayContext(false)); - for (const auto &genOpParamvalue : l_parameterValues) { - formatter->setAllowIDInImmediateChild(); - formatter->setOmitTypeInImmediateChild(); - genOpParamvalue->_exportToJSON(formatter); - } + writer->AddObjKey("parameters"); + { + auto parametersContext(writer->MakeArrayContext(false)); + for (const auto &genOpParamvalue : l_parameterValues) { + formatter->setAllowIDInImmediateChild(); + formatter->setOmitTypeInImmediateChild(); + genOpParamvalue->_exportToJSON(formatter); } } } diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 69cab65c..f883ddb7 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -3827,6 +3827,201 @@ TEST( // --------------------------------------------------------------------------- +TEST(wkt_parse, CONCATENATEDOPERATION_with_inverse_conversion_of_compound) { + + auto wkt = + "CONCATENATEDOPERATION[\"Inverse of RD New + Amersfoort to ETRS89 (9) " + "+ Inverse of ETRS89 to NAP height (2) + ETRS89 to WGS 84 (1)\",\n" + " SOURCECRS[\n" + " COMPOUNDCRS[\"Amersfoort / RD New + NAP height\",\n" + " PROJCRS[\"Amersfoort / RD New\",\n" + " BASEGEOGCRS[\"Amersfoort\",\n" + " DATUM[\"Amersfoort\",\n" + " ELLIPSOID[\"Bessel " + "1841\",6377397.155,299.1528128,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4289]],\n" + " CONVERSION[\"RD New\",\n" + " METHOD[\"Oblique Stereographic\",\n" + " ID[\"EPSG\",9809]],\n" + " PARAMETER[\"Latitude of natural " + "origin\",52.1561605555556,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8801]],\n" + " PARAMETER[\"Longitude of natural " + "origin\",5.38763888888889,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8802]],\n" + " PARAMETER[\"Scale factor at natural " + "origin\",0.9999079,\n" + " SCALEUNIT[\"unity\",1],\n" + " ID[\"EPSG\",8805]],\n" + " PARAMETER[\"False easting\",155000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8806]],\n" + " PARAMETER[\"False northing\",463000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8807]]],\n" + " CS[Cartesian,2],\n" + " AXIS[\"easting (X)\",east,\n" + " ORDER[1],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " AXIS[\"northing (Y)\",north,\n" + " ORDER[2],\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " VERTCRS[\"NAP height\",\n" + " VDATUM[\"Normaal Amsterdams Peil\"],\n" + " CS[vertical,1],\n" + " AXIS[\"gravity-related height (H)\",up,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " ID[\"EPSG\",7415]]],\n" + " TARGETCRS[\n" + " GEOGCRS[\"WGS 84 (3D)\",\n" + " ENSEMBLE[\"World Geodetic System 1984 ensemble\",\n" + " MEMBER[\"World Geodetic System 1984 (Transit)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G730)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G873)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G1150)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G1674)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G1762)\"],\n" + " MEMBER[\"World Geodetic System 1984 (G2139)\"],\n" + " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ENSEMBLEACCURACY[2.0]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " CS[ellipsoidal,3],\n" + " AXIS[\"geodetic latitude (Lat)\",north,\n" + " ORDER[1],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"geodetic longitude (Long)\",east,\n" + " ORDER[2],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"ellipsoidal height (h)\",up,\n" + " ORDER[3],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",4329]]],\n" + " STEP[\n" + " CONVERSION[\"Inverse of RD New\",\n" + " METHOD[\"Inverse of Oblique Stereographic\",\n" + " ID[\"INVERSE(EPSG)\",9809]],\n" + " PARAMETER[\"Latitude of natural " + "origin\",52.1561605555556,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8801]],\n" + " PARAMETER[\"Longitude of natural " + "origin\",5.38763888888889,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8802]],\n" + " PARAMETER[\"Scale factor at natural origin\",0.9999079,\n" + " SCALEUNIT[\"unity\",1],\n" + " ID[\"EPSG\",8805]],\n" + " PARAMETER[\"False easting\",155000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8806]],\n" + " PARAMETER[\"False northing\",463000,\n" + " LENGTHUNIT[\"metre\",1],\n" + " ID[\"EPSG\",8807]],\n" + " ID[\"INVERSE(EPSG)\",19914]]],\n" + " STEP[\n" + " COORDINATEOPERATION[\"PROJ-based coordinate operation\",\n" + " SOURCECRS[\n" + " COMPOUNDCRS[\"Amersfoort + NAP height\",\n" + " GEOGCRS[\"Amersfoort\",\n" + " DATUM[\"Amersfoort\",\n" + " ELLIPSOID[\"Bessel " + "1841\",6377397.155,299.1528128,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " " + "ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " CS[ellipsoidal,2],\n" + " AXIS[\"geodetic latitude (Lat)\",north,\n" + " ORDER[1],\n" + " " + "ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " AXIS[\"geodetic longitude (Lon)\",east,\n" + " ORDER[2],\n" + " " + "ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4289]],\n" + " VERTCRS[\"NAP height\",\n" + " VDATUM[\"Normaal Amsterdams Peil\"],\n" + " CS[vertical,1],\n" + " AXIS[\"gravity-related height (H)\",up,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",5709]]]],\n" + " TARGETCRS[\n" + " GEOGCRS[\"WGS 84 (3D)\",\n" + " ENSEMBLE[\"World Geodetic System 1984 " + "ensemble\",\n" + " MEMBER[\"World Geodetic System 1984 " + "(Transit)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G730)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G873)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G1150)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G1674)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G1762)\"],\n" + " MEMBER[\"World Geodetic System 1984 " + "(G2139)\"],\n" + " ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ENSEMBLEACCURACY[2.0]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " CS[ellipsoidal,3],\n" + " AXIS[\"geodetic latitude (Lat)\",north,\n" + " ORDER[1],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"geodetic longitude (Long)\",east,\n" + " ORDER[2],\n" + " ANGLEUNIT[\"degree minute second " + "hemisphere\",0.0174532925199433]],\n" + " AXIS[\"ellipsoidal height (h)\",up,\n" + " ORDER[3],\n" + " LENGTHUNIT[\"metre\",1]],\n" + " ID[\"EPSG\",4329]]],\n" + " METHOD[\"PROJ-based operation method: +proj=pipeline " + "+step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg " + "+xy_out=rad +step +proj=hgridshift +grids=nl_nsgi_rdtrans2018.tif " + "+step +proj=vgridshift +grids=nl_nsgi_nlgeo2018.tif +multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " + "+order=2,1\"],\n" + " OPERATIONACCURACY[1.002]]],\n" + " USAGE[\n" + " SCOPE[\"unknown\"],\n" + " AREA[\"Netherlands - onshore, including Waddenzee, Dutch " + "Wadden Islands and 12-mile offshore coastal zone.\"],\n" + " BBOX[50.75,3.2,53.7,7.22]]]"; + + auto obj = WKTParser().createFromWKT(wkt); + auto concat = nn_dynamic_pointer_cast<ConcatenatedOperation>(obj); + ASSERT_TRUE(concat != nullptr); + + EXPECT_EQ(concat->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline " + "+step +inv +proj=sterea +lat_0=52.1561605555556 " + "+lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 " + "+ellps=bessel " + "+step +proj=hgridshift +grids=nl_nsgi_rdtrans2018.tif " + "+step +proj=vgridshift +grids=nl_nsgi_nlgeo2018.tif " + "+multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + +// --------------------------------------------------------------------------- + TEST(wkt_parse, BOUNDCRS_transformation_from_names) { auto projcrs = ProjectedCRS::create( |
