Handle orthographic projections compatibly #2092
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PROJ is changing the way it handles '+proj=ortho' in spec strings, as of version 7.2. Previously, that projection performed a spheroidal calculation, even with the WGS84 datum. With the change, PROJ uses the precise ellipsoidal shape when projecting.
I encountered and reported this in #2016, because I build Mapper on Linux where PROJ has been at version 7.2 for several months. The new PROJ alters the geographic coordinates of map objects, changing their alignment in relation to georeferenced templates.
This PR includes a regression test of a GPX track template that fails with the latest PROJ due to the track becoming misaligned with the map. It also addresses the problem, by detecting maps having '+proj=ortho' in the CRS, that were created with an older version of PROJ. It prevents misalignment by inserting '+f=0' into the spec string. The revised CRS spec performs identically to the way older versions of Mapper handled the original CRS spec.
This solution does not have the drawback mentioned in solution #2020. It supports the ellipsoidal orthographic projection by passing the spec string directly to PROJ.
In this code change, detection of maps that need the spheroidal version is 99.98% effective. It works because the grid scale factor can be inferred from a saved map file. The spheroidal and ellipsoidal projections generally have different grid scale factors, leading to an inconsistency that is evident when Mapper loads a map with a 'ortho' projection that is spheroidal, but not explicitly so. [The grid scale factors are close enough between latitudes 45.05° and 45.06° that the discrepancy is not detected. This exception affects parts of Minneapolis and Turin.]