[OpenLayers-Users] Coordinates Reversed

Tom Kunicki tkunicki at usgs.gov
Mon Mar 11 14:13:42 PDT 2013


To help it would be useful to know the WFS version and server-side vendor and implementation you are attempting to utilize.

The easiest thing would be to use WFS 1.0 with GML2.  You'll (usually) get back geographic coordinates in [lon, lat] 

The longer gist-of-it-but-skipping-details explanation:

There's some ambiguity as to what the axis ordering should be.  Computer-folk tend to prefer [x, y] or [lon, lat] and this was how the computer-folk implemented these services for a long time.  The reality is that the authorities that define the coordinate systems (i.e. the "EPSG" in "EPSG:4326")  define the proper axis order for coordinates.  As an example for EPSG:4326 the authority defined axis order is [lat, lon] == [y, x] == [north, east].  The purists brought up this discrepancy and in 2009 the OGC put forth this guidance note:  http://www.ogcnetwork.net/node/491.  What this says that any specification generated after 2009 (and implementations of those specifications) must respect the authority defined axis order (i.e. [lat, long] not [lon, lat]).  Now this is all muddled because vendors have put forth varying degrees of compliance in the implementations of these newer services.  There a number of nuances to all of this and it's usually easier (if possible) to use services that pre-date the 2009 upheaval (where everything was in the incorrect, but consistent axis order).

Tom


On Mar 11, 2013, at 2:57 PM, Jerome A. Wendell <jawendell at digitalmapping.com> wrote:

> I have setup a vector layer based on features from a WMS layer that are filtered by an argument in the url used to call up the map.  The feature is being found and shows up in the POST response in Firebug, but does not show up on the map.  My first thought was the feature needed to be transformed, so I added that.  In looking at the response in Firebug for the feature, the latitude is listed before the longitude.  This appears to be my problem because the coordinates listed for the feature in the DOM in Firebug are not realistic (contain NaN a number of times).  The code for that part of my map is below:
> var args = OpenLayers.Util.getParameters();
>                                 var filter = new OpenLayers.Filter.Comparison({
>                                                 type: OpenLayers.Filter.Comparison.EQUAL_TO,
>                                                 property: 'attribute',
>                                                 value: args['attribute']
>                                 });
>                                 var selvectorLayer = new OpenLayers.Layer.Vector("Selected Tract", {
>                                                 strategies: [new OpenLayers.Strategy.Fixed()],
>                                                 protocol: new OpenLayers.Protocol.WFS.fromWMSLayer(mylayer),
>                                                 styleMap: mystyles,
>                                                 filter: filter,
>                                                 displayInLayerSwitcher: false,
>                                                 isBaseLayer: false,
>                                                 visibility: true,
>                                                 eventListeners: {
>                                                 beforefeatureadded: function(event) {
>                                                                 event.feature.geometry.transform(new OpenLayers.Projection('EPSG:4326'),this.map.getProjectionObject());
>                                                 }
>                                                 }
>                                 });
> The WMS layer is in EPSG:4326, and the map is in EPSG:900913.  I have tried a number of things, such as adding format: new OpenLayers.Format.GML({xy: false}) to the vector layer, but the order of the coordinates does not change.  I have a control for selecting features from this same WMS layer, and when those features are returned, the coordinates are listed longitude and then latitude.
>  
> Obviously I am missing something.  Can someone point me in the right direction to find out why the coordinates are reversed?
>  
> Any suggestions are greatly appreciated.
>  
> Thanks.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list