[PROJ] Simple cs2cs in code

Paul Ramsey pramsey at cleverelephant.ca
Fri Feb 8 11:25:11 PST 2019


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


More information about the PROJ mailing list