[PROJ] Simple cs2cs in code

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PROJ] Simple cs2cs in code

Paul Ramsey
I'm embarrassed to ask this, but looking at fixing up the postgis
transform code to use the new API, I have

pj_transform(srcpj, dstpj, 1, 0, &(pt->x), &(pt->y), &(pt->z))

and I cannot for the life of my figure out how to replicate that in
the new API...

If I was instantiating a *PJ from an epsg:from and epsg:to, I would be
fine, because there's the lovely proj_create_crs_to_crs function.

But that's not the contract I have to fulfill. I have to fulfill a
transform from_projstr to to_projstr. In generality. For a happy
future, I'll also add some stuff to use proj_create_crs_to_crs where
the metadata we have supports that call (which happily is in most
cases). But in the fraught present, I still need to support the
from_projstr, to_projstr pattern.

I see I can use proj_create to go from a trom_projstr to a from_PJ,
that's nice. And I can also make a to_PJ. But I don't see a way to
call with a from and to.

That leaves me wondering if I can just string concatenate a
from_projstr and a to_projstr into a pipeline, get a PJ from that
using proj_create, and call a forward transformation on that?

Which still leaves my trying to create and test proj pipelines, which
I have so far failed to do... the generic case being "a projected
system on spheroid X to a different system on spheroid Y".

I'm sorry if it's obvious and I"m looking at the wrong page :(

Thanks,

P
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Simple cs2cs in code

Even Rouault-2
On vendredi 8 février 2019 12:25:11 CET Paul Ramsey wrote:

> I'm embarrassed to ask this, but looking at fixing up the postgis
> transform code to use the new API, I have
>
> pj_transform(srcpj, dstpj, 1, 0, &(pt->x), &(pt->y), &(pt->z))
>
> and I cannot for the life of my figure out how to replicate that in
> the new API...
>
> If I was instantiating a *PJ from an epsg:from and epsg:to, I would be
> fine, because there's the lovely proj_create_crs_to_crs function.
>
> But that's not the contract I have to fulfill. I have to fulfill a
> transform from_projstr to to_projstr. In generality. For a happy
> future, I'll also add some stuff to use proj_create_crs_to_crs where
> the metadata we have supports that call (which happily is in most
> cases). But in the fraught present, I still need to support the
> from_projstr, to_projstr pattern.
>
> I see I can use proj_create to go from a trom_projstr to a from_PJ,
> that's nice. And I can also make a to_PJ. But I don't see a way to
> call with a from and to.
>
> That leaves me wondering if I can just string concatenate a
> from_projstr and a to_projstr into a pipeline, get a PJ from that
> using proj_create, and call a forward transformation on that?
>
> Which still leaves my trying to create and test proj pipelines, which
> I have so far failed to do... the generic case being "a projected
> system on spheroid X to a different system on spheroid Y".
>
> I'm sorry if it's obvious and I"m looking at the wrong page :(

Paul,

With PROJ 5, yes creating a simple pipeline is the solution. So you can use

PJ* P = proj_create(ctxt,
        "+proj=pipeline +step +inv " + from_projstr + " +step " + to_projstr)

and use proj_trans(P, PJ_FWD, coord) afterwards

That's how current GDAL versions ported from the pj_transform() API to the new
one.


With PROJ 6, proj_create_crs_to_crs() has been extended to support PROJ CRS
strings or WKT CRS as arguments in addition to EPSG:XXXX codes.

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj