[PROJ] computing proj_factors with the C API

Markus Metz markus.metz.giswork at gmail.com
Mon Feb 8 14:10:30 PST 2021


On Thu, Feb 4, 2021 at 12:58 AM Nicolas Bellaiche <Nicolas.Bellaiche at ign.fr>
wrote:
>
> Hi,
>
> Two major problems I'm struggling with:
>
> 1) computing the proj_factors with the C API.
>
> My code seems very simple:
>
> my_proj = proj_create(nullptr, "IGNF:LAMB93");
>
> auto geodetic_crs = proj_crs_get_geodetic_crs(nullptr, my_proj);
>
> PJ_FACTORS facs = proj_factors(geodetic_crs, coord);
>
>
> the error message sent by proj_factors is "latitude or longitude exceeded
limits" but when I look into the code, it seems the geodetic_crs->fwd is
not initialized.

According to "projinfo -o WKT2:2019 IGNF:LAMB93", the bbox is
       BBOX[41,-5.5,52,10]]
here, easting and northing seem to be swapped, the WKT2 output says that
easting is the first axis.

Following your code and using
        coord = proj_coord(5.0, 47.0, 0.0, 0.0);
which is somewhere inside the reported bbox, I don't get any errors. Maybe
your coords are outside the bbox, thus "latitude or longitude exceeded
limits"?

>
>
> The problem disappears if I call proj_init_plus but then I can't use the
useful proj_crs_get_horizontal_datum, proj_create_ellipsoidal_2D_cs with
the PJ object created.

proj_crs_get_horizontal_datum() is independent of any PJ_COORD and may fail
if there is no horizontal datum, but "IGNF:LAMB93" has "Reseau Geodesique
Francais 1993" as datum. In my test with "IGNF:LAMB93",
proj_crs_get_horizontal_datum() works with both the original crs and the
crs from proj_crs_get_geodetic_crs();

proj_create_ellipsoidal_2D_cs() is experimental.
>
>
> Anybody understanding what's wrong with my code?

Wrong coordinates? Using experimental code?

Markus M
>
>
>
> 2) if I initialize my PJ object with proj.db, it seems the geoid grid of
IGNF:LAMB93 is not loaded, so I can't compute the ellipsoidal height from
the altitude and vice versa. I can do it with the old format of proj4 (by
copying the file IGNF of PROJ4 in the PROJ_LIB directory and using
"+init=IGNF:LAMB93") but then the object is not recognized as an iso object
and once again I can't use proj_crs_get_horizontal_datum,
proj_create_ellipsoidal_2D_cs etc...
>
>
> Is there anything I did wrong or is it an issue with PROJ7?
>
>
> I hope I've been clear enough, any help would be really appreciated,
>
>
> Thanks a lot for your answers,
>
>
> Nicolas Bellaiche
>
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/proj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20210208/ba99ed87/attachment.html>


More information about the PROJ mailing list