diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-02-20 10:36:14 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-02-20 10:36:14 +0100 |
| commit | f6232db745af1acd2473f51f82d006372c04fc55 (patch) | |
| tree | 12895f9453c4f6212b74634495493c1746a1f5b3 | |
| parent | 942722214e0b94bd848dac21c8e21923cf9f1c04 (diff) | |
| download | PROJ-f6232db745af1acd2473f51f82d006372c04fc55.tar.gz PROJ-f6232db745af1acd2473f51f82d006372c04fc55.zip | |
Add VERTCON grid name alternatives in database, and handle filename substitution for VERTCON method
| -rw-r--r-- | data/sql/grid_alternatives.sql | 47 | ||||
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 40 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 19 |
3 files changed, 106 insertions, 0 deletions
diff --git a/data/sql/grid_alternatives.sql b/data/sql/grid_alternatives.sql index a45c43f1..99f20d0e 100644 --- a/data/sql/grid_alternatives.sql +++ b/data/sql/grid_alternatives.sql @@ -142,6 +142,53 @@ INSERT INTO grid_alternatives(original_grid_name, 'proj-datumgrid-europe', NULL, NULL, NULL, NULL); +-- Continental USA VERTCON: NGVD (19)29 height to NAVD (19)88 height + +INSERT INTO grid_alternatives(original_grid_name, + proj_grid_name, + proj_grid_format, + proj_method, + inverse_direction, + package_name, + url, direct_download, open_license, directory) + VALUES ('vertconw.94', + 'vertconw.gtx', + 'GTX', + 'vgridshift', + 0, + 'proj-datumgrid-north-america', + NULL, NULL, NULL, NULL); + +INSERT INTO grid_alternatives(original_grid_name, + proj_grid_name, + proj_grid_format, + proj_method, + inverse_direction, + package_name, + url, direct_download, open_license, directory) + VALUES ('vertconc.94', + 'vertconc.gtx', + 'GTX', + 'vgridshift', + 0, + 'proj-datumgrid-north-america', + NULL, NULL, NULL, NULL); + +INSERT INTO grid_alternatives(original_grid_name, + proj_grid_name, + proj_grid_format, + proj_method, + inverse_direction, + package_name, + url, direct_download, open_license, directory) + VALUES ('vertcone.94', + 'vertcone.gtx', + 'GTX', + 'vgridshift', + 0, + 'proj-datumgrid-north-america', + NULL, NULL, NULL, NULL); + -- EGM models INSERT INTO grid_alternatives(original_grid_name, diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index 2128124b..90266307 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -8001,6 +8001,46 @@ TransformationNNPtr Transformation::substitutePROJAlternativeGridNames( } } + if (methodEPSGCode == EPSG_CODE_METHOD_VERTCON) { + auto fileParameter = + parameterValue(EPSG_NAME_PARAMETER_VERTICAL_OFFSET_FILE, + EPSG_CODE_PARAMETER_VERTICAL_OFFSET_FILE); + if (fileParameter && + fileParameter->type() == ParameterValue::Type::FILENAME) { + + auto filename = fileParameter->valueFile(); + if (databaseContext->lookForGridAlternative( + filename, projFilename, projGridFormat, inverseDirection)) { + + if (filename == projFilename) { + assert(!inverseDirection); + return self; + } + + auto parameters = std::vector<OperationParameterNNPtr>{ + createOpParamNameEPSGCode( + EPSG_CODE_PARAMETER_VERTICAL_OFFSET_FILE)}; + if (inverseDirection) { + return create(createPropertiesForInverse( + self.as_nullable().get(), true, false), + targetCRS(), sourceCRS(), nullptr, + createSimilarPropertiesMethod(method()), + parameters, {ParameterValue::createFilename( + projFilename)}, + coordinateOperationAccuracies()) + ->inverseAsTransformation(); + } else { + return create( + createSimilarPropertiesTransformation(self), + sourceCRS(), targetCRS(), nullptr, + createSimilarPropertiesMethod(method()), parameters, + {ParameterValue::createFilename(projFilename)}, + coordinateOperationAccuracies()); + } + } + } + } + return self; } // --------------------------------------------------------------------------- diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 90deb661..58b740b6 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -6174,6 +6174,25 @@ TEST(operation, vertCRS_to_vertCRS) { // --------------------------------------------------------------------------- +TEST(operation, vertCRS_to_vertCRS_context) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setSpatialCriterion( + CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION); + auto list = CoordinateOperationFactory::create()->createOperations( + // NGVD29 height (m) + authFactory->createCoordinateReferenceSystem("7968"), + // NAVD88 height (1) + authFactory->createCoordinateReferenceSystem("5703"), ctxt); + ASSERT_EQ(list.size(), 3U); + EXPECT_EQ(list[0]->nameStr(), "NGVD29 height (m) to NAVD88 height (3)"); + EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=vgridshift +grids=vertcone.gtx +multiplier=0.001"); +} + +// --------------------------------------------------------------------------- + TEST(operation, compoundCRS_to_geogCRS_3D) { auto compoundcrs_ft_obj = PROJStringParser().createFromPROJString( |
