[PROJ] Change in behaviour (ONLY_BEST option)

Even Rouault even.rouault at spatialys.com
Wed Apr 12 12:33:24 PDT 2023


Le 12/04/2023 à 20:57, Javier Jimenez Shaw a écrit :
> Thanks Even for the quick fix.
>
> Is there a way in C++ to set the option to "NO" or "YES"?
> I saw that I can use proj.ini file and a environment variable, that 
> overwrites the value in proj.ini. So if a user of my application plays 
> with the environment variables, they can change the behaviour (already 
> happened with PROJ_LIB some time ago)
> I would like to set the behaviour directly in the C++ code. Is that 
> possible?

You can specify ONLY_BEST=YES/NO in the options argument of 
proj_create_crs_to_crs[_from_pj](). This is what cs2cs does when 
specifying the --only-best switch

Even


>
> Thanks
>
> On Wed, 12 Apr 2023 at 19:24, Even Rouault 
> <even.rouault at spatialys.com> wrote:
>
>     Hi Javier,
>
>     Fixed per https://github.com/OSGeo/PROJ/pull/3707
>
>     doh, I hadn't anticipated that the only_best functionality would
>     introduce such complexity. The fundamental issue is that the
>     pipeline computation engine has subtle behavioral differences
>     depending if you ask it to assume that all registered grids are
>     available (which is used to get the "universe of possible", from
>     which we can see if we are missing the "best" transformation),
>     which corresponds projinfo --grid-check known_available mode, or
>     if you ask it to discard early transformations using grid not
>     available. In the former case, PROJ may sometimes not need to
>     synthetize the ballkpark transformation when it sees that the
>     extent of the grids cover the extent of the CRS. So in the
>     warn-only mode of only_best we must actually hybrid the 2
>     strategies to discover both missing best transformation, and get a
>     ballpark transformation. Not sure if the above makes sense...
>
>     Even
>
>     Le 12/04/2023 à 16:46, Javier Jimenez Shaw a écrit :
>>     Hi
>>
>>     I am trying to migrate an application from PROJ 9.1.0 to PROJ
>>     9.2.0, and I found a change in behaviour, that I was not
>>     expecting in this release:
>>     Transform a coordinate not having the proper geoid file (the
>>     Spanish one in this test). I was expecting that the z component
>>     is not changed. But I am getting an error instead, and "* * inf"
>>     value.
>>     I know that ONLY_BEST is there, but I understood that the default
>>     was to keep the same behaviour as before, and show a warning
>>     asking for a "definition".
>>     But that is not what I experience. See this command lines:
>>
>>     echo 39 -3 0 | PROJ_DEBUG=2 PROJ_NETWORK=OFF cs2cs EPSG:4326+5773
>>     EPSG:4326+5782
>>     pj_open_lib(proj.ini): call
>>     fopen(/home/jshaw/work/PROJ/install-sh/share/proj/proj.ini) -
>>     succeeded
>>     pj_open_lib(proj.db): call
>>     fopen(/home/jshaw/work/PROJ/install-sh/share/proj/proj.db) -
>>     succeeded
>>     pj_open_lib(us_nga_egm96_15.tif): call fopen(us_nga_egm96_15.tif)
>>     - failed
>>     pj_open_lib(egm96_15.gtx): call fopen(egm96_15.gtx) - failed
>>     pj_open_lib(es_ign_egm08-rednap.tif): call
>>     fopen(es_ign_egm08-rednap.tif) - failed
>>     pj_open_lib(es_2019m.asc): call fopen(es_2019m.asc) - failed
>>     pj_open_lib(es_2019z.asc): call fopen(es_2019z.asc) - failed
>>     pj_open_lib(us_nga_egm96_15.tif): call fopen(us_nga_egm96_15.tif)
>>     - failed
>>     pj_open_lib(egm96_15.gtx): call fopen(egm96_15.gtx) - failed
>>     pj_open_lib(es_ign_egm08-rednap.tif): call
>>     fopen(es_ign_egm08-rednap.tif) - failed
>>     Attempt to use coordinate operation Inverse of WGS 84 to EGM96
>>     height (1) + ETRS89 to Alicante height (1) using ETRS89 to WGS 84
>>     (1) failed. Grid es_ign_egm08-rednap.tif is not available.
>>     Consult https://proj.org/resource_files.html for guidance. Grid
>>     us_nga_egm96_15.tif is not available. Consult
>>     https://proj.org/resource_files.html for guidance. This might
>>     become an error in a future PROJ major release. Set the ONLY_BEST
>>     option to YES or NO. This warning will no longer be emitted (for
>>     the current transformation instance).
>>     * * inf
>>
>>
>>     echo 39 -3 0 | PROJ_DEBUG=2 PROJ_ONLY_BEST_DEFAULT=NO
>>     PROJ_NETWORK=OFF cs2cs EPSG:4326+5773 EPSG:4326+5782
>>     pj_open_lib(proj.ini): call
>>     fopen(/home/jshaw/work/PROJ/install-sh/share/proj/proj.ini) -
>>     succeeded
>>     pj_open_lib(proj.db): call
>>     fopen(/home/jshaw/work/PROJ/install-sh/share/proj/proj.db) -
>>     succeeded
>>     pj_open_lib(us_nga_egm96_15.tif): call fopen(us_nga_egm96_15.tif)
>>     - failed
>>     pj_open_lib(egm96_15.gtx): call fopen(egm96_15.gtx) - failed
>>     pj_open_lib(es_ign_egm08-rednap.tif): call
>>     fopen(es_ign_egm08-rednap.tif) - failed
>>     pj_open_lib(es_2019m.asc): call fopen(es_2019m.asc) - failed
>>     pj_open_lib(es_2019z.asc): call fopen(es_2019z.asc) - failed
>>     39.00 -3.00 0.00
>>
>>
>>     echo 39 -3 0 | PROJ_DEBUG=2 PROJ_NETWORK=ON cs2cs EPSG:4326+5773
>>     EPSG:4326+5782
>>     pj_open_lib(proj.ini): call
>>     fopen(/home/jshaw/work/PROJ/install-sh/share/proj/proj.ini) -
>>     succeeded
>>     pj_open_lib(proj.db): call
>>     fopen(/home/jshaw/work/PROJ/install-sh/share/proj/proj.db) -
>>     succeeded
>>     pj_open_lib(us_nga_egm96_15.tif): call fopen(us_nga_egm96_15.tif)
>>     - failed
>>     pj_open_lib(egm96_15.gtx): call fopen(egm96_15.gtx) - failed
>>     pj_open_lib(us_nga_egm96_15.tif): call fopen(us_nga_egm96_15.tif)
>>     - failed
>>     pj_open_lib(egm96_15.gtx): call fopen(egm96_15.gtx) - failed
>>     Using https://cdn.proj.org/us_nga_egm96_15.tif
>>     pj_open_lib(es_ign_egm08-rednap.tif): call
>>     fopen(es_ign_egm08-rednap.tif) - failed
>>     pj_open_lib(es_2019m.asc): call fopen(es_2019m.asc) - failed
>>     pj_open_lib(es_2019z.asc): call fopen(es_2019z.asc) - failed
>>     pj_open_lib(es_ign_egm08-rednap.tif): call
>>     fopen(es_ign_egm08-rednap.tif) - failed
>>     Using https://cdn.proj.org/es_ign_egm08-rednap.tif
>>     pj_open_lib(us_nga_egm96_15.tif): call fopen(us_nga_egm96_15.tif)
>>     - failed
>>     pj_open_lib(egm96_15.gtx): call fopen(egm96_15.gtx) - failed
>>     Using https://cdn.proj.org/us_nga_egm96_15.tif
>>     pj_open_lib(es_ign_egm08-rednap.tif): call
>>     fopen(es_ign_egm08-rednap.tif) - failed
>>     Using https://cdn.proj.org/es_ign_egm08-rednap.tif
>>     39.00 -3.00 0.30
>>
>>
>>     The behaviour in 9.1.0 was the same as with
>>     "PROJ_ONLY_BEST_DEFAULT=NO", that is what I was expecting now
>>     (plus warning message).
>>
>>     Am I missing something? Is this a bug?
>>
>>     Thanks.
>>
>>     .___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
>>
>>     _______________________________________________
>>     PROJ mailing list
>>     PROJ at lists.osgeo.org
>>     https://lists.osgeo.org/mailman/listinfo/proj
>
>     -- 
>     http://www.spatialys.com
>     My software is free, but my time generally not.
>
-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20230412/b3a34f82/attachment.htm>


More information about the PROJ mailing list