[PROJ] Make push and pop FIFO?

Even Rouault even.rouault at spatialys.com
Tue Feb 6 05:59:57 PST 2024


Jochem,
> This new implementation uses a single stack instead of 4? So, the following pipeline would alter the ellipsoidal height and swap the original lon,lat? That is quite confusing for users that are used to the old push and pop.
>
> +step +proj=stack +push=1,2 /
> +step +proj=cart /
> +step +proj=helmert +rx=1 +ry=2 +rz=3 /
> +step +proj=cart +inv /
> +step +proj=stack +pop=1,2

No, this wouldn't swap lon,lat.   push=1,2 pushes the tuple (x,y) to the 
top of the stack as (a=x,b=y) and pop=1,2 restores (a,b) as (x,y). So 
this usage is strictly equivalent to using the old operators with 
+proj=push +v_1 +v_2 and +proj=pop +v_1 +v_2.

Said otherwise "+proj=stack +push=1,2" is not equivalent to "+proj=stack 
+push=1" followed by "+proj=stack +push=2".


>
> I am also wondering if the single stack could give new problems. How to access the stack values after the first two? This theoretical (but not unthinkable) case would still be impossible:
>
> * input lon1 lat1 h1
> * push lon1 lat1 h1
> * helmert transformation to lon2 lat2 h2
> * push lon2 lat2 h2
> * pop lon1 lat1 h1
> * helmert transformation to lon3 lat3 h3
> * pop lon2 lat2
> * output lon2 lat2 h3

We'd probably need an extended stack swap operator, where you could 
designate the indices of the stack that you want to exchange (and you 
would need to push/pop separately (lon1, lat1) and (h1)). But that 
becomes quite involved (for the user writing the pipeline)

I guess you could probably also achieve that pipeline by combining the 
"old" and "new" stacks (you can use both in the same pipeline). But 
here, the solution for "normal" human brains (assuming mine qualifies as 
normal) would probably be named variables. There's some reason why Forth 
concepts haven't percolated to more modern languages.

Even

-- 
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/20240206/f33ec14a/attachment.htm>


More information about the PROJ mailing list