0
votes

When using the ol.format.WFS (both GML2 and GML3) to read features they will always be assumed to be in YX if the projection is EPSG:4326. So OL flips them. I am using this with Geoserver 2.11 and, as of this version, the server can send the coordinates as XY, depending on how you pass the projection. You can read about it here.

Going through the OL code I can see it reads the projection from the xml and it decides to flip it based on the axis orientation, which for 4326 is neu, resulting in a flip.

The problem is my configuration depends on the client and the server might be already sending XY. I was wondering if this is a bug with OpenLayers or if it was a decision made.

Is there a way to prevent it from doing it?

1

1 Answers

2
votes

You can override it with a custom projection object

/ override the axis orientation for WMS GetFeatureInfo
var proj = new ol.proj.Projection({
  code: 'http://www.opengis.net/gml/srs/epsg.xml#4326',
  axis: 'enu'
});
ol.proj.addEquivalentProjections([ol.proj.get('EPSG:4326'), proj]);

Just make sure that the string for code matches what is in your WFS/GML document.