[PROJ] Reusing formatter object

Javier Jimenez Shaw j1 at jimenezshaw.com
Wed Oct 27 10:48:41 PDT 2021


Hi

Can I use a formatter object from the class
osgeo::proj::io::PROJStringFormatter many times?

in the transformation from LV_95 (EPSG:2056) to WGS84 the method
"ConcatenatedOperation::operations()" is giving me two operations. If I use
the same formatter object I get this:

operation:
+proj=pipeline
  +step +inv +proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333
+k_0=1
        +x_0=2600000 +y_0=1200000 +ellps=bessel
  +step +proj=unitconvert +xy_in=rad +xy_out=deg
  +step +proj=axisswap +order=2,1

operation:
+proj=pipeline
    +step +inv +proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333
          +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel
    +step +proj=push +v_3
    +step +proj=cart +ellps=bessel
    +step +proj=helmert +x=674.374 +y=15.056 +z=405.346
    +step +inv +proj=cart +ellps=WGS84
    +step +proj=pop +v_3
    +step +proj=unitconvert +xy_in=rad +xy_out=deg
    +step +proj=axisswap +order=2,1

What I was expecting is (what I get if I create a new formatter each time)

operation:
+proj=pipeline
  +step +inv +proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333
+k_0=1
        +x_0=2600000 +y_0=1200000 +ellps=bessel
  +step +proj=unitconvert +xy_in=rad +xy_out=deg
  +step +proj=axisswap +order=2,1

operation:
+proj=pipeline
  +step +proj=axisswap +order=2,1
  +step +proj=unitconvert +xy_in=deg +xy_out=rad
  +step +proj=push +v_3
  +step +proj=cart +ellps=bessel
  +step +proj=helmert +x=674.374 +y=15.056 +z=405.346
  +step +inv +proj=cart +ellps=WGS84
  +step +proj=pop +v_3
  +step +proj=unitconvert +xy_in=rad +xy_out=deg
  +step +proj=axisswap +order=2,1

The only difference is to create the formatter object outside or inside the
for loop that iterates ConcatenatedOperation::operations()

auto formatter =
osgeo::proj::io::PROJStringFormatter::create(osgeo::proj::io::PROJStringFormatter::Convention::PROJ_5,
dbContext);
formatter->setMultiLine(true);

Is that expected? I do not see any method like "clear" or "reset" to remove
any previous data.
Note: it is not a problem if it is intended (now that I know the effect).
But it confused me trying to understand how
ConcatenatedOperation::operations() works.

Thanks
.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
Entre dos pensamientos racionales
hay infinitos pensamientos irracionales.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20211027/9570cd37/attachment.html>


More information about the PROJ mailing list