[PROJ] Equivalent of OSRSetFromUserInput in proj 6 API

Nyall Dawson nyall.dawson at gmail.com
Mon Apr 8 16:02:58 PDT 2019


On Mon, 8 Apr 2019 at 19:42, Even Rouault <even.rouault at spatialys.com> wrote:
>
> On lundi 8 avril 2019 19:32:23 CEST Nyall Dawson wrote:
> > On Mon, 8 Apr 2019 at 18:15, Even Rouault <even.rouault at spatialys.com>
> wrote:
> > > On lundi 8 avril 2019 13:18:07 CEST Nyall Dawson wrote:
> > > > Hi list,
> > > >
> > > > While plugging away at the QGIS proj 6 upgrade I came across code
> > > > which uses OSRSetFromUserInput in order to convert any freeform string
> > > > to a coordinate reference system object.
> > > >
> > > > Is there an equivalent of this in the proj 6 API I should be using
> > > > instead of this?
> > >
> > > proj_create() will be able to handle PROJ strings, WKT, AUTH:CODE, OGC
> > > URNs
> > > and CRS names (like 'WGS84')
> > >
> > > If you pass it a PROJ string that needs to be interpretated as a CRS, you
> > > need to add " +type=crs" to it, otherwise it will be interpretated as a
> > > coordinate operation.
> >
> > Is there any way use proj_create with an EPSG code, but restrict the
> > results to CRS objects only (for those duplicate codes)?
> >
>
> Use proj_create(ctx, "urn:ogc:def:crs:EPSG::XXXX")
>
> or proj_create_from_database(ctx, "EPSG", "XXXX", PJ_CATEGORY_CRS, false,
> nullptr)

Ok - in either of these approaches I'd need to do some pre-processing
of the string in order to determine whether it's a "EPSG:####" format.

What I'm wondering is whether there's any benefit here of porting away
from calling OSRSetFromUserInput and then OSRExportToWkt, and whether
doing so would end up with me just re-implementing all the logic which
is present in OSRSetFromUserInput. (There's also a lot of extra logic
in place regarding setting GDAL_FIX_ESRI_WKT in certain
circumstances).

I guess I'm hoping you'll tell me that there's no benefit to porting
this code away from OSRSetFromUserInput, and I can just leave
everything as is ;)

Nyall


More information about the PROJ mailing list