Re: Way to transform coordinates given an osgeo::proj::operation::CoordinateOperation?
Even Rouault <[email protected]>
| Newsgroups | gmane.comp.gis.proj-4.devel |
|---|---|
| Message-ID | <2068318.WCFyvjCoof@even-i700> |
On mercredi 9 octobre 2019 15:47:26 CEST Martin Desruisseaux wrote: > Hello > > I'm trying to find the best way to transform coordinate tupples given an > osgeo::proj::operation::CoordinateOperation instance. My current > understanding is that I need to get a PJ object as below. Is that correct? > > CoordinateOperationNNPtr operation = ... > PJ_CONTEXT *ctx = ... > PJ *pj = (ctx, operation); > // Then use PJ as documented in "getting started" guide. > > If above is the right approach, looking at the source code of > pj_obj_create, there is two things I would like to do differently: > > * Use an existing osgeo::proj::io::DatabaseContext instance. > * Do not fallback on pj_new() if the main block could not create the PJ. > > So would the following block be okay (I know if use an internal method > call, but I didn't saw a way to avoid it yet): > > DatabaseContext dbContext = ...; > auto formatter = > PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_5, > dbContext); auto projString = coordop->exportToPROJString(formatter.get()); > PJ *pj = pj_create_internal(ctx, projString.c_str()); > // Done; do not touch to pj->iso_obj or pj->cpp_context. > > Or is there a better way to "execute" a CoordinateOperation with C++ API? You have indeed to go to the C API, but use proj_create() instead of pj_create_internal() -- Spatialys - Geospatial professional services http://www.spatialys.com _______________________________________________ PROJ mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/proj