Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem integrating WMS and WFS. Basically what i want is when user clicks on WMS then a clicked polygon is added to vector (and selected). The problem is that the WMS is in version 1.3.0 and WFS 1.1.0. OpenLayers automatically flips axis for WMS but when it calculates bbox for wfs request, it does not. I have the following code:

    var map = new OpenLayers.Map({numZoomLevels: 20});

             var wms = new OpenLayers.Layer.WMS(
                 "OpenLayers WMS",
                 {layers: ['Dzialki','Numery_dzialek'], version:'1.3.0'}
             select = new OpenLayers.Layer.Vector("Selection", {styleMap: 
                 new OpenLayers.Style(["select"])

    var protocol = new OpenLayers.Protocol.WFS({
                 version: "1.1.0",
                 //url:  "",
                 featureType: "Dzialki",

             control = new OpenLayers.Control.GetFeature({
                 protocol: protocol,
                 box: true,
                 //hover: true,
                 multipleKey: "shiftKey",
                 toggleKey: "ctrlKey"
             });"featureselected", this, function(e) {
   "featureunselected", this, function(e) {


And generated request after click:

<wfs:GetFeature xmlns:wfs="" service="WFS" version="1.1.0" maxFeatures="10" xsi:schemaLocation="" xmlns:xsi="">
<wfs:Query typeName="gmgml:Dzialki" srsName="EPSG:4326" xmlns:gmgml="">
<ogc:Filter xmlns:ogc="">
<gml:Envelope xmlns:gml="" srsName="EPSG:4326">
<gml:lowerCorner>19.143386078712 52.371721634254</gml:lowerCorner>
<gml:upperCorner>19.143439722893 52.371775278435</gml:upperCorner>

The above request does not work (0 features returned) but when i flip coords so it looks like:

<gml:lowerCorner>52.371721634254 19.143386078712</gml:lowerCorner>
    <gml:upperCorner>52.371775278435 19.143439722893</gml:upperCorner>

it works. How to force OpenLayers to build getFeature request with flipped coords? In WMS Layer there is attribute reverseAxisOrder but can't find it in Vector Layer

share|improve this question
Format/GML/Base.js has an xy property which is used to indicate if the x/y values should be reversed. See… -- not sure how you're going to reach down into that value. – ca0v Sep 12 '12 at 16:43

You could try to use the URN form of the epsg code (urn:x-ogc:def:crs:EPSG:4326) which is supposed to avoid these problems by always being in the WMS 1.3 order. How well this will work kind of depends on the server you are talking to but if it is GeoTools based it will work.

Further discussion can be found at

share|improve this answer

use the formatOptions: {xy: false} option as below....

var wfs = new OpenLayers.Layer.Vector("OSBrgs", {
    strategies: [new OpenLayers.Strategy.BBOX(),refresh],
            styleMap: new OpenLayers.StyleMap({
                           pointRadius: "6", 
                          fillColor: "#666666"
             protocol: new OpenLayers.Protocol.WFS({
                    version: "1.0.0",
                    srsName: "EPSG:4326",
                    url: "/OL_WFS/Request.aspx",
                    featureType: "OFF_SYSTEM_BRG",
                    featurePrefix: "gmgml",
                    featureNS: "",
                    geometryName: "GEOMETRY",
                    formatOptions: {
                           xy: false
             renderers: OpenLayers.Layer.Vector.prototype.renderers
share|improve this answer

I ran into the same problem. Here is one way to reverse the coordinates going out of OL:

        WKB = gmlParser.write(feature);

        //Another problem. The OL GML parser doesn't switch the axis order of 4326 on output. So, let's read it back in, then out again.

        //Bring it back in, but reverse the axis.
        var gmlParser2 = new OpenLayers.Format.GML();
        gmlParser2.srsName = "EPSG:4326";
        gmlParser2.xy = false;

        var ReverseAxisOrderFeature =;
        WKB = gmlParser2.write(ReverseAxisOrderFeature);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.