Opened 2 years ago

Last modified 3 months ago

#102 new defect

Support for PROJ 6.0.0

Reported by: Bas Couwenberg Owned by: Olly Betts
Priority: minor Milestone:
Component: Other Version:
Keywords: Cc:


Survex still uses proj_api.h which is deprecated in PROJ 6.0.0 and will be removed in PROJ 7.0.0 (scheduled for March 2020).

When using proj_api.h with PROJ 6.0.0 -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1 needs to be added to CFLAGS to prevent a compiler error.

Survex should be updated to (also) support the proj.h API.

Attachments (1)

proj6-wip.patch (4.2 KB) - added by Olly Betts 2 years ago.
WIP patch

Download all attachments as: .zip

Change History (13)

comment:1 Changed 2 years ago by Bas Couwenberg

Adding -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H to CFLAGS & CXXFLAGS is not sufficient, the build still fails:

/usr/bin/ld: commands.o: in function `cmd_declination':
./src/commands.c:1712: undefined reference to `pj_factors'

comment:2 Changed 2 years ago by Olly Betts

Just adding it to CPPFLAGS would make more sense since it's a preprocessor option.

Unfortunately pj_factors seems to have had a slightly strange status in the proj API over time (as shows), but I don't know of a better way to get the grid convergence. That ticket suggests it's also used in grass and qgis, and I believe therion uses it too.

I'm afraid I don't have time to work on this issue currently, but patches are certainly most welcome.

comment:3 Changed 2 years ago by Bas Couwenberg

Therion 5.4.4 added support for proj.h.

I'm not able to provide a patch, but by the time the proj transition starts enough projects may have added support for proj.h to have enough examples to enable you to add support for proj.h to Survex.

For questions about using the new new API, the mailinglist is your best option.

comment:4 Changed 2 years ago by Olly Betts

Priority: majorminor

Changed 2 years ago by Olly Betts

Attachment: proj6-wip.patch added

WIP patch

comment:5 Changed 2 years ago by Olly Betts

A quick poke using 6.1.0-1~exp1 from Debian experimental suggests that the compatibility API is simply missing pj_factors().

But it seems you can use the old and new APIs together if you include proj.h first, so I did that and adjusted the Survex code to use proj_factors() instead.

However PROJ issues unrelated to convergence then cause tests to fail.

It seems PROJ 6 fails to understand +init=esri:NNNN for any valid ESRI code NNNN I've tried. I can reproduce that from the command line - with 6.1.0:

$ proj +init=esri:104305
Rel. 6.1.0, May 15th, 2019
projection initialization failure
cause: no arguments in initialization list
program abnormally terminated

c.f. 5.2.0 (ignore the error - the point is here the ESRI code is actually understood):

$ proj +init=esri:104305
Rel. 5.2.0, September 15th, 2018
+proj=latlong unsuitable for use with proj program.
program abnormally terminated

It also doesn't give an error for converting out of range coordinates like older releases did - 6.1.0:

$ echo 179 -89 1000|cs2cs +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +to +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=0 +y_0=0 +ellps=airy +datum=OSGB36 +units=m +no_defs
-1842.61	-15536258.81 1000.00

c.f. 5.2.0:

$ echo 179 -89 1000|cs2cs +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +to +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=0 +y_0=0 +ellps=airy +datum=OSGB36 +units=m +no_defs
Rel. 5.2.0, September 15th, 2018
<cs2cs>: while processing file: <stdin>, line 1
pj_transform(): latitude or longitude exceeded limits
*	* 2175.53

Both of these seem to be PROJ 6 bugs rather than problems with our code.

I'm afraid I don't have further time to waste on this at present. Seems to me PROJ 6 simply isn't production ready yet, and I'd advise installing an older PROJ for now.

WIP patch attached in case anyone wants to work further on this. This patch gets things building but only by disabling the tests which fail - I certainly wouldn't advise using this patch in production.

comment:6 Changed 2 years ago by Bas Couwenberg

Thanks for working on the PROJ 6 support.

Once you have time for this again, you should talk to the PROJ developers via the list. They are very helpful to get projects to support the new API.

Using +init= syntax causes fallback to the PROJ 4 API which also causes issues with cs2cs tests and datumgrids, using the modern syntax (without +init= prefix) should help to use the PROJ 6 API. The projection is deprecated according to projinfo:

# projinfo ESRI:104305
Warning: object is deprecated

PROJ.4 string:
+proj=longlat +a=6378249.145 +rf=293.465 +no_defs +type=crs

WKT2_2018 string:
        ELLIPSOID["Clarke 1880 (RGS)",6378249.145,293.465,
        AXIS["geodetic latitude (Lat)",north,
        AXIS["geodetic longitude (Lon)",east,
        AREA["Algeria - north of 32°N"],

There is probably a modern replacement with a different ID, the will likely give better results with PROJ 6.

comment:7 Changed 2 years ago by Olly Betts

[87197115a7b4afbaff3c67a5d852b4359876e873] adds support for PROJ 5.x. 6.x still seems to be broken though.

The projection is deprecated according to projinfo:

It's not ESRI:104305 in particular that's interesting - that's just an arbitrary example the test suite uses to check that you can specify an ESRI code in a .svx file. It seems that +init=esri:NNNNNN no longer works at all in a proj string (e.g. +init=esri:102581 fails too but projinfo ESRI:102581 doesn't show that as deprecated).

Survex .3d files include details of their projection specified as a proj string, and if the .svx file specifies ESRI:102581, that will be in the form +init=esri:102581. The user can also specify an arbitrary proj string in their .svx file.

comment:8 Changed 2 years ago by Bas Couwenberg

You really need to talk to the PROJ developers about what seems to broken for Survex's use.

comment:9 Changed 2 years ago by Olly Betts

Lack of error for out of range coordinates reported to PROJ upstream:

comment:10 Changed 2 years ago by Olly Betts

The missing error isn't a bug but rather than PROJ6 uses a more accurate algorithm. I've applied a workaround in [26f1fb2856eff48364257c264afbc02a4cd03ca1].

comment:11 Changed 23 months ago by Olly Betts

[3f1dd91f9fff5ab056d8dd4eb0c68b0f126a4bf2] works around the +init=esri:NNNNNN issue by installing a copy of the esri file from older PROJ and arranging for PROJ to find it. I'll forward the issue upstream too, but at this point Survex now works with PROJ 6.1.0 (though using the old API still).

comment:12 Changed 3 months ago by Bas Couwenberg

The first PROJ 8.0.0 release candidate has been released which removes proj_api.h.

Note: See TracTickets for help on using tickets.