[gdal-dev] GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

Simon Eves simon.eves at omnisci.com
Fri May 24 13:35:40 PDT 2019


I feel like I'm asking a really dumb and naive question again, but here
goes...

Our geo importer loads polygons in what I assume is a very standard way.
The importer code has not changed in some time, and works fine built
against GDAL 2.3.2 and Proj 5.1, and also against GDAL 2.4.1 and Proj 5.2.

When I build our system against GDAL 3.0.0 and Proj 6.1.0, everything seems
to work fine, and GeoJSON and KML files import correctly, but Shapefiles
result in all the geo being transposed in X/Y!

Simplified code...

sr = new OGRSpatialReference();
sr->importFromEPSG(4326);
ds = GDALOpenEx(file, GDAL_OF_VECTOR, nullptr, nullptr, nullptr);
layer = ds.GetLayer(0)
layer.ResetReading();
f = layer.GetNextFeature();
OGRGeometry* g = f->GetGeometryRef();
if (g->getSpatialReference()) {
  g->transformTo(sr);
}
// omitting code that determines that it's a MULTIPOLYGON
mp = dynamic_cast<OGRMultiPolygon*>(g);
mp->getNumGeometries();
mpg = mp->getGeometryRef(0);
er = mpg->getExteriorRing();
OGRPoint p;
er->getPoint(0, &p);
x = p.getX();
y = p.getY();

and 'x' and 'y' are transposed!

An ogrinfo dump on the command-line displays the correct values.

What did I miss?!

-- 
<http://www.omnisci.com/>
Simon Eves
Senior Graphics Engineer, Rendering Group
OmniSci, 1 Front St. #2650, San Francisco, CA 94111, USA


Email: simon.eves at omnisci.com | Cell:  415.902.1996
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190524/ae9fca89/attachment.html>


More information about the gdal-dev mailing list