aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/crs.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-02-29 13:24:58 +0100
committerGitHub <noreply@github.com>2020-02-29 13:24:58 +0100
commit10a8d5c98499127e5aa61d6cdeee466fcabb12ed (patch)
tree241ad35a9c6866c565d096fc9b0357747a347ec7 /src/iso19111/crs.cpp
parent1f3a571d32fb311a7bd4528b04071dbf332498c4 (diff)
downloadPROJ-10a8d5c98499127e5aa61d6cdeee466fcabb12ed.tar.gz
PROJ-10a8d5c98499127e5aa61d6cdeee466fcabb12ed.zip
createOperations(): fix wrong pipeline generation with CRS that has +nadgrids= and +pm= (#1998)
Fixes issue reported at https://lists.osgeo.org/pipermail/gdal-dev/2020-February/051749.html The generated pipeline assumes that the input coordinates for the grid transformation were related to the non-Greenwich based datum, so we must compensate for that and add logic to go back to Greenwich.
Diffstat (limited to 'src/iso19111/crs.cpp')
-rw-r--r--src/iso19111/crs.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index dbb68f0b..45e2309c 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -4525,9 +4525,27 @@ BoundCRS::createFromTOWGS84(const CRSNNPtr &baseCRSIn,
*/
BoundCRSNNPtr BoundCRS::createFromNadgrids(const CRSNNPtr &baseCRSIn,
const std::string &filename) {
- const CRSPtr sourceGeographicCRS = baseCRSIn->extractGeographicCRS();
+ const auto sourceGeographicCRS = baseCRSIn->extractGeographicCRS();
auto transformationSourceCRS =
- sourceGeographicCRS ? sourceGeographicCRS : baseCRSIn.as_nullable();
+ sourceGeographicCRS
+ ? NN_NO_CHECK(std::static_pointer_cast<CRS>(sourceGeographicCRS))
+ : baseCRSIn;
+ if (sourceGeographicCRS != nullptr &&
+ sourceGeographicCRS->datum() != nullptr &&
+ sourceGeographicCRS->primeMeridian()->longitude().getSIValue() != 0.0) {
+ transformationSourceCRS = GeographicCRS::create(
+ util::PropertyMap().set(common::IdentifiedObject::NAME_KEY,
+ sourceGeographicCRS->nameStr() +
+ " (with Greenwich prime meridian)"),
+ datum::GeodeticReferenceFrame::create(
+ util::PropertyMap().set(
+ common::IdentifiedObject::NAME_KEY,
+ sourceGeographicCRS->datum()->nameStr() +
+ " (with Greenwich prime meridian)"),
+ sourceGeographicCRS->datum()->ellipsoid(),
+ util::optional<std::string>(), datum::PrimeMeridian::GREENWICH),
+ sourceGeographicCRS->coordinateSystem());
+ }
std::string transformationName = transformationSourceCRS->nameStr();
transformationName += " to WGS84";
@@ -4536,8 +4554,8 @@ BoundCRSNNPtr BoundCRS::createFromNadgrids(const CRSNNPtr &baseCRSIn,
operation::Transformation::createNTv2(
util::PropertyMap().set(common::IdentifiedObject::NAME_KEY,
transformationName),
- NN_NO_CHECK(transformationSourceCRS), GeographicCRS::EPSG_4326,
- filename, std::vector<metadata::PositionalAccuracyNNPtr>()));
+ transformationSourceCRS, GeographicCRS::EPSG_4326, filename,
+ std::vector<metadata::PositionalAccuracyNNPtr>()));
}
// ---------------------------------------------------------------------------