[PROJ] Anyway to set a CRS object's name via c api?

Nyall Dawson nyall.dawson at gmail.com
Fri Oct 9 14:40:43 PDT 2020


On Fri, 9 Oct 2020 at 21:04, Even Rouault <even.rouault at spatialys.com> wrote:
>
> Hi Nyall,
>
>
>
> > Using the C api "proj_get_name" method I'm able to retrieve the
>
> > descriptive name of a CRS object.
>
> >
>
> > This works well for CRS obtained from the Proj database, or for CRS
>
> > defined from WKT with a name embedded: ...PROJCRS["my CRS name",
>
> > BASEGEOGCRS[...
>
> >
>
> > But if I have a CRS object created using a different method (say, from
>
> > a proj string), is there any way I can manually set a name for this
>
> > CRS so that subsequent calls to proj_as_wkt will include the manually
>
> > set CRS name?
>
> >
>
> > While it would be possible to get the WKT returned from proj_as_wkt
>
> > and then try to insert the custom name, this would be a lot of fragile
>
> > string manipulation which I'd rather avoid!
>
>
>
>
>
> /** \brief Return a copy of the object with its name changed
>
> *
>
> * Currently, only implemented on CRS objects.
>
> *
>
> * The returned object must be unreferenced with proj_destroy() after
>
> * use.
>
> * It should be used by at most one thread at a time.
>
> *
>
> * @param ctx PROJ context, or NULL for default context
>
> * @param obj Object of type CRS. Must not be NULL
>
> * @param name New name. Must not be NULL
>
> *
>
> * @return Object that must be unreferenced with
>
> * proj_destroy(), or NULL in case of error.
>
> */
>
> PJ PROJ_DLL *proj_alter_name(PJ_CONTEXT *ctx, const PJ *obj, const char *name);
>
>
>
>
>
> Available in proj_experimental.h since 6.0

Perfect, thanks!

Nyall

>
>
>
>
>
> Even
>
>
>
> --
>
> Spatialys - Geospatial professional services
>
> http://www.spatialys.com


More information about the PROJ mailing list