[gdal-dev] +lon_wrap difference between cs2cs and OGRCoordinateTransformation

Heiskanen Mika (FMI) Mika.Heiskanen at fmi.fi
Sun Apr 19 02:08:39 PDT 2020


Hello,

I've been browsing the manuals, and cannot find any reason why cs2cs and the sample C++ program behave differently:

> echo "25w 60n" | /usr/proj70/bin/cs2cs -f "%.8f" +from +init=epsg:4326 +to +init=epsg:4326 +lon_wrap=180
335.00000000 60.00000000 0.00000000

> g++ -std=c++11 -o tese tese.cpp -I/usr/gdal30/include -L/usr/gdal30/lib -lgdal
> ./tese
Warning 1: +init=epsg:XXXX syntax is deprecated. It might return a CRS with a non-EPSG compliant axis order.
x=-25 y=60

It seems to me based on browsing the source code that both call proj_trans, and hence should probably produce
the same results. I couldn't debug any further with the RHEL7 RPM packages since the pgdg repo does not
provide the necessary debuginfo packages for GDAL or PROJ (would be nice to have them for perf too).

The +lon_0 option seems to work just fine for metric projections, but does not work for geographic conversions
such as this one.

Is there a good reason for the discrepancy which I may have missed, or should this perhaps be considered a bug?

Regards,

Mika Heiskanen


[-] = =tese.cpp------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <ogr_spatialref.h>
#include <iostream>

int main()
{
  OGRSpatialReference source;
  source.SetFromUserInput("epsg:4326");
  source.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

  OGRSpatialReference target;
  target.SetFromUserInput("+init=epsg:4326 +lon_wrap=180");
  target.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

  auto* trans = OGRCreateCoordinateTransformation(&source, &target);

  double x = -25;
  double y = 60;
  trans->Transform(1, &x, &y);

  std::cout << "x=" << x << " y=" << y << "\n";
}

?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200419/e450013f/attachment.html>


More information about the gdal-dev mailing list