[PROJ] Way to transform coordinates given an osgeo::proj::operation::CoordinateOperation?

Martin Desruisseaux martin.desruisseaux at geomatys.com
Wed Oct 9 06:47:26 PDT 2019


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?

     Thanks,

         Martin


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20191009/47d619eb/attachment.html>


More information about the PROJ mailing list