[PROJ] Transforming coordinates in C++
Even Rouault
even.rouault at spatialys.com
Fri Oct 29 05:10:24 PDT 2021
Le 29/10/2021 à 13:49, Javier Jimenez Shaw a écrit :
> Thanks Even.
>
> I see that proj_create takes a PJ_CONTEXT *ctx as the first argument.
> What I have in C++ is a DatabaseContextPtr. Can I get a PJ_CONTEXT*
> from a DatabaseContextPtr?
I don't see a getter for it currently. It can be optionally passed in
the DatabaseContext::create() factory method (DatabaseContext doesn't
strictly require a PJ_CONTEXT*. From what I can see it is only needed to
find proj.db and grid files, and if none is provided the default context
is used. I hope this is safe enough in multi threaded uses. hum...), so
if there was one, you already knew it through other means, but it
wouldn't hurt if you added a getter. Or you create one from scratch.
All this is a testimony of the ISO-19111 part having being mostly
developed as an addition besides the traditional C code base, and the
connection between the two parts being a bit tricky.
> .___ ._ ..._ .. . ._. .___ .. __ . _. . __.. ... .... ._ .__
> Entre dos pensamientos racionales
> hay infinitos pensamientos irracionales.
>
>
>
> On Fri, 29 Oct 2021 at 12:17, Even Rouault <even.rouault at spatialys.com
> <mailto:even.rouault at spatialys.com>> wrote:
>
>
> Le 29/10/2021 à 12:00, Javier Jimenez Shaw a écrit :
>> Hi
>>
>> Using C++ I am trying this: Given two CRSs, I would like to have
>> access to the list of possible transformations (like with
>> projinfo), and use those transformations to transform coordinates
>> (like with cs2cs).
>>
>> Studying the code of projinfo, that uses mainly the C++ API, I
>> already have a std::vector<CoordinateOperationNNPtr>. Nice, I can
>> dump them in different formats.
>>
>> However, when I go to the code of cs2cs, I see that it is mainly
>> using the C API.
>>
>> Is there any C++ equivalent to the function
>> PJ_COORD proj_trans (PJ *P, PJ_DIRECTION direction, PJ_COORD coord);
>> ?
>
> No.
>
> If you know which transformation you want to do, what you can
> easily do is exportToPROJString() it, and use proj_create() to
> instanciate it as a PJ* object you can use with proj_trans()
>
> That's more or less what proj_create_operations() +
> proj_list_get() do.
>
> Even
>
>>
>> Thanks.
>> .___ ._ ..._ .. . ._. .___ .. __ . _. . __.. ... .... ._ .__
>> Entre dos pensamientos racionales
>> hay infinitos pensamientos irracionales.
>>
>>
>> _______________________________________________
>> PROJ mailing list
>> PROJ at lists.osgeo.org <mailto:PROJ at lists.osgeo.org>
>> https://lists.osgeo.org/mailman/listinfo/proj <https://lists.osgeo.org/mailman/listinfo/proj>
>
> --
> http://www.spatialys.com <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/20211029/cb8a584d/attachment.html>
More information about the PROJ
mailing list