From d8526d7870e4b91238c9a7b652ed03c21b77e884 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 22 Apr 2019 13:15:02 +0200 Subject: ESRI_WKT: preserve Gauss_Kruger in conversion name for round-tripping --- test/unit/test_io.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test') diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 30e0b427..c4178f20 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -5180,6 +5180,43 @@ TEST(wkt_parse, wkt1_esri_ups_south) { // --------------------------------------------------------------------------- +TEST(wkt_parse, wkt1_esri_gauss_kruger) { + auto wkt = "PROJCS[\"ETRS_1989_UWPP_2000_PAS_8\",GEOGCS[\"GCS_ETRS_1989\"," + "DATUM[\"D_ETRS_1989\"," + "SPHEROID[\"GRS_1980\",6378137.0,298.257222101]]," + "PRIMEM[\"Greenwich\",0.0]," + "UNIT[\"Degree\",0.0174532925199433]]," + "PROJECTION[\"Gauss_Kruger\"]," + "PARAMETER[\"False_Easting\",8500000.0]," + "PARAMETER[\"False_Northing\",0.0]," + "PARAMETER[\"Central_Meridian\",24.0]," + "PARAMETER[\"Scale_Factor\",0.999923]," + "PARAMETER[\"Latitude_Of_Origin\",0.0]," + "UNIT[\"Meter\",1.0]]"; + + auto dbContext = DatabaseContext::create(); + auto obj = WKTParser().attachDatabaseContext(dbContext).createFromWKT(wkt); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + + EXPECT_EQ( + crs->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT1_ESRI, dbContext) + .get()), + wkt); + + auto crs2 = AuthorityFactory::create(dbContext, "ESRI") + ->createProjectedCRS("102177"); + + EXPECT_EQ( + crs2->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT1_ESRI, dbContext) + .get()), + wkt); +} + +// --------------------------------------------------------------------------- + TEST(wkt_parse, invalid) { EXPECT_THROW(WKTParser().createFromWKT(""), ParsingException); EXPECT_THROW(WKTParser().createFromWKT("A"), ParsingException); -- cgit v1.2.3 From 3faaf339216f128be7a8bb354e858203e5ec6d7f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 22 Apr 2019 15:26:43 +0200 Subject: Database: use non-deprecated code for SWEREF99 for 'RH2000 height to SWEREF99' transformation --- test/cli/testprojinfo | 4 ++-- test/cli/testprojinfo_out.dist | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo index 244e1bd5..d8569a76 100755 --- a/test/cli/testprojinfo +++ b/test/cli/testprojinfo @@ -103,8 +103,8 @@ echo "Testing CRS with towgs84: projinfo -o PROJ EPSG:25832" >> ${OUT} $EXE -o PROJ EPSG:25832 >>${OUT} 2>&1 echo "" >>${OUT} -echo "Testing RH2000 height to SWEREF99: projinfo -s EPSG:5613 -t EPSG:4377" >> ${OUT} -$EXE -s EPSG:5613 -t EPSG:4377 >>${OUT} 2>&1 +echo "Testing RH2000 height to SWEREF99: projinfo -s EPSG:5613 -t EPSG:4977" >> ${OUT} +$EXE -s EPSG:5613 -t EPSG:4977 >>${OUT} 2>&1 echo "" >>${OUT} echo "Testing NAD83(2011) + NAVD88 height -> NAD83(2011) : projinfo -s EPSG:6349 -t EPSG:6319 --spatial-test intersects -o PROJ" >> ${OUT} diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist index f5cbb8bf..ea0f4983 100644 --- a/test/cli/testprojinfo_out.dist +++ b/test/cli/testprojinfo_out.dist @@ -693,12 +693,12 @@ Testing CRS with towgs84: projinfo -o PROJ EPSG:25832 PROJ.4 string: +proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs -Testing RH2000 height to SWEREF99: projinfo -s EPSG:5613 -t EPSG:4377 +Testing RH2000 height to SWEREF99: projinfo -s EPSG:5613 -t EPSG:4977 Candidate operations found: 1 ------------------------------------- Operation n°1: -PROJ:EPSG_5613_TO_EPSG_4377, RH2000 height to SWEREF99, unknown accuracy, Sweden - onshore +PROJ:EPSG_5613_TO_EPSG_4977, RH2000 height to SWEREF99, unknown accuracy, Sweden - onshore PROJ string: +proj=vgridshift +grids=SWEN17_RH2000.gtx +multiplier=1 @@ -713,7 +713,7 @@ COORDINATEOPERATION["RH2000 height to SWEREF99", LENGTHUNIT["metre",1]], ID["EPSG",5613]]], TARGETCRS[ - GEOGCRS["SWEREF99 (3D)", + GEOGCRS["SWEREF99", DATUM["SWEREF99", ELLIPSOID["GRS 1980",6378137,298.257222101, LENGTHUNIT["metre",1]]], @@ -722,14 +722,14 @@ COORDINATEOPERATION["RH2000 height to SWEREF99", CS[ellipsoidal,3], AXIS["geodetic latitude (Lat)",north, ORDER[1], - ANGLEUNIT["degree minute second hemisphere",0.0174532925199433]], - AXIS["geodetic longitude (Long)",east, + ANGLEUNIT["degree",0.0174532925199433]], + AXIS["geodetic longitude (Lon)",east, ORDER[2], - ANGLEUNIT["degree minute second hemisphere",0.0174532925199433]], + ANGLEUNIT["degree",0.0174532925199433]], AXIS["ellipsoidal height (h)",up, ORDER[3], LENGTHUNIT["metre",1]], - ID["EPSG",4377]]], + ID["EPSG",4977]]], METHOD["GravityRelatedHeight to Geographic3D", ID["PROJ","HEIGHT_TO_GEOGRAPHIC3D"]], PARAMETERFILE["Geoid (height correction) model file","SWEN17_RH2000.gtx"], @@ -737,7 +737,7 @@ COORDINATEOPERATION["RH2000 height to SWEREF99", SCOPE["unknown"], AREA["Sweden - onshore"], BBOX[55.28,10.93,69.07,24.17]], - ID["PROJ","EPSG_5613_TO_EPSG_4377"]] + ID["PROJ","EPSG_5613_TO_EPSG_4977"]] Testing NAD83(2011) + NAVD88 height -> NAD83(2011) : projinfo -s EPSG:6349 -t EPSG:6319 --spatial-test intersects -o PROJ Candidate operations found: 2 -- cgit v1.2.3 From cca27b1fae234a90df42ff5341121759846dc39b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 30 Apr 2019 14:31:16 +0200 Subject: Propagate ballpark transformation flag to inverse coordinate operations --- test/unit/test_operation.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index b7b87d76..e1ced807 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -5396,6 +5396,21 @@ TEST(operation, projCRS_to_projCRS_context_incompatible_areas) { // --------------------------------------------------------------------------- +TEST(operation, projCRS_to_projCRS_context_incompatible_areas_ballpark) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + auto list = CoordinateOperationFactory::create()->createOperations( + authFactory->createCoordinateReferenceSystem("26711"), // UTM 11 NAD27 + authFactory->createCoordinateReferenceSystem( + "3034"), // ETRS89 / LCC Europe + ctxt); + ASSERT_GE(list.size(), 1U); + EXPECT_TRUE(list[0]->hasBallparkTransformation()); +} + +// --------------------------------------------------------------------------- + TEST(operation, projCRS_to_projCRS_north_pole_inverted_axis) { auto authFactory = -- cgit v1.2.3 From b4a9e65cec051ca3cb16b8cccfa012d70ce10570 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 30 Apr 2019 14:56:32 +0200 Subject: createOperations(): in SourceTargetCRSExtentUse::INTERSECTION mode, early return if the intersection of the areas is empty --- test/unit/test_operation.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index e1ced807..730cd270 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -5411,6 +5411,24 @@ TEST(operation, projCRS_to_projCRS_context_incompatible_areas_ballpark) { // --------------------------------------------------------------------------- +TEST( + operation, + projCRS_to_projCRS_context_incompatible_areas_crs_extent_use_intersection) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setSourceAndTargetCRSExtentUse( + CoordinateOperationContext::SourceTargetCRSExtentUse::INTERSECTION); + auto list = CoordinateOperationFactory::create()->createOperations( + authFactory->createCoordinateReferenceSystem("26711"), // UTM 11 NAD27 + authFactory->createCoordinateReferenceSystem( + "3034"), // ETRS89 / LCC Europe + ctxt); + ASSERT_GE(list.size(), 0U); +} + +// --------------------------------------------------------------------------- + TEST(operation, projCRS_to_projCRS_north_pole_inverted_axis) { auto authFactory = -- cgit v1.2.3 From 09cbfb85c834d99e5a00f5989dc144613e0cfbf2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 30 Apr 2019 17:25:38 +0200 Subject: WKT importer: accepts PROJ-based COORDINATEOPERATION --- test/unit/test_operation.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 730cd270..a38e9df2 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -6477,6 +6477,18 @@ TEST(operation, compoundCRS_to_compoundCRS_context) { "+step +proj=hgridshift +grids=conus +step " "+proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap " "+order=2,1"); + { + // Test that we can round-trip this through WKT and still get the same + // PROJ string. + auto wkt = list[0]->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT2_2018).get()); + auto obj = WKTParser().createFromWKT(wkt); + auto co = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(co != nullptr); + EXPECT_EQ( + list[0]->exportToPROJString(PROJStringFormatter::create().get()), + co->exportToPROJString(PROJStringFormatter::create().get())); + } bool foundApprox = false; for (size_t i = 0; i < list.size(); i++) { -- cgit v1.2.3