-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vertical part from Compound ignored transforming to DerivedProjected #3340
Comments
After debugging into the code, I got some clues, and maybe a solution. In the method // Only do a vertical transformation if the target CRS is 3D.
const auto dstSingle = dynamic_cast<crs::SingleCRS *>(targetCRS.get());
if (dstSingle &&
dstSingle->coordinateSystem()->axisList().size() == 2) { where Because it is 2D it is not doing the vertical component operation. Trying to fix it, I modified the method crs::CRSNNPtr baseCRS = derivedSrc->baseCRS();
if (derivedSrc->coordinateSystem()->axisList().size() == 3 &&
derivedSrc->baseCRS()->coordinateSystem()->axisList().size() == 2)
{
baseCRS = derivedSrc->baseCRS()->promoteTo3D(std::string(), nullptr);
}
auto opsSecond =
createOperations(baseCRS, targetCRS, context); However, a few lines later, when it calls So I think the solution is to create the baseCRS directly as 3D. DerivedProjectedCRSNNPtr
WKTParser::Private::buildDerivedProjectedCRS(const WKTNodeNNPtr &node) {
...
if (baseProjCRS->coordinateSystem()->axisList().size() == 2 &&
cs->axisList().size() == 3) {
ProjectedCRSPtr aux = std::dynamic_pointer_cast<ProjectedCRS>(
baseProjCRS->promoteTo3D(std::string(), nullptr).as_nullable());
if (aux)
baseProjCRS = NN_NO_CHECK(aux);
}
return DerivedProjectedCRS::create(buildProperties(node), baseProjCRS,
conversion, cs);
} A second option is doing the The first option would affect only WKT inputs (are there other parsers I should check?), while the second affects every case, not giving a choice to a potential C++ user, but also preventing the problem in the transformation. Which solution (if any) makes more sense? |
Ups, I didn't see that @rouault had already implemented a solution (I do not refresh GitHub page enough, and I got no emails this time). Good to see that we reached to the same conclusion :) |
Thanks @rouault ! |
WKT import: 3D-promote base CRS of 3D DerivedProjectedCRS (fixes #3340)
WKT import: 3D-promote base CRS of 3D DerivedProjectedCRS (fixes #3340)
[Backport 9.1] WKT import: 3D-promote base CRS of 3D DerivedProjectedCRS (fixes #3340)
Example of problem
When I try to transform from a
Compound CRS
likeEPSG:6318+6360
(vertical in US foot) to aDerivedProjected 3D CRS
, it seems to be ignoring the vertical component of the compound CRS. However it is not the case when source is a geographic 3D (with vertical in US foot), or when destination is a projected CRS in 3D.Compound to DerivedProjected 3D
Geographic 3D (vert in US foot) to DerivedProjected
(see that source vertical units are considered)
Compound to Projected 3D
Problem description
The transformation should consider the vertical component of the compound, including the units management.
Expected Output
If I guess it correctly, something like this (convert
z
fromus-ft
tom
, and applyvgridshift
[in operation 1])Environment Information
proj 9.1.0
)Installation method
The text was updated successfully, but these errors were encountered: