0

I have a "rich" application (OL 2.13 + GeoExt 1) where some layers must be styled dynamically according to user input. I am able to add a vector layer using WFS and then apply a style rule. Recently, some users started complaining the feature is not working. Eventually I found out some WFS layers are not being portrayed in the map canvas by OL.

Below is a minimum example with a simple map and one of the problematic layers. After loading all objects the debugger shows a vector layer within the map object; this vector layer is reported as visible and with the drawn property set to true. In the features array there are 8 objects as expected, but there is nothing visible in the map. There are no errors reported in the console.

I am able to display this same layer through WFS in QGIS and access all its attributes without trouble.

What is going wrong here?

<html>
<head>

 <script type="text/javascript" src="http://localhost/spatiallib/OpenLayers-2.13.1/OpenLayers.js"></script>
 <link rel="stylesheet" type="text/css" href="http://localhost/spatiallib/OpenLayers-2.13.1/theme/default/style.css">

 <script type="text/javascript">

function initMap()
{
    // Do not forget to add maps.iguess.tudor.lu to the proxy's allowed addresses
    OpenLayers.ProxyHost = "http://localhost/cgi-bin/proxy.cgi?url=";

    var mapProjection = "EPSG:31467";
    var mapServicePath = "http://maps.iguess.tudor.lu/cgi-bin/mapserv?map=srv/mapserv/MapFiles/LB_localOWS_test.map";

    var bounds = new OpenLayers.Bounds(3500000,5410000,3525000,5425000);

    map = new OpenLayers.Map("MiniMap",{
        projection: new OpenLayers.Projection(mapProjection),
        units: "m",
        maxExtent: bounds,
    });

    map.addControl(new OpenLayers.Control.LayerSwitcher());

    var cityWMS =  new OpenLayers.Layer.WMS(
        "LB_urban_landuse",
        mapServicePath,
        {layers: "LB_urban_landuse",
         format: "image/png",
         srsName: mapProjection,
         transparent: "true",
         projection: new OpenLayers.Projection(mapProjection)},
        {isBaseLayer: true,
         visibility: true}
    );

    var testWFS = new OpenLayers.Layer.Vector("testWFS", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        projection: new OpenLayers.Projection("EPSG:31467"),
        visibility: true,
        protocol: new OpenLayers.Protocol.WFS({
            version: "1.1.0",
            url: "http://maps.iguess.tudor.lu/cgi-bin/mapserv?map=/srv/mapserv/MapFiles/LB_localOWS_test.map",
            featureNS: "http://mapserver.gis.umn.edu/mapserver",
            featureType: "LB_sliders_test",
            srsName: "EPSG:31467"
        })}
    );

    map.addLayers([cityWMS, testWFS]);
    map.setCenter(new OpenLayers.LonLat(3514100,5417800), 7);

    testWFS.display(true);
}

 </script>
</head>
 <body onLoad="initMap();" style="margin:0px">
     <div  style="width:800px; height:600px; background:white" id="MiniMap"></div>
     <input type=button value="Click for debugger" onclick="debugger;"></input>
 </body>
</html> 
1

Your problem may come from using WFS 1.1.0 with a coordinate system that has a northing-easting axis order. You can try these solutions:

  1. Use WFS 1.0.0 version. You can test that 1.1.0 sends coordinates as northing-easting

http://maps.iguess.tudor.lu/cgi-bin/mapserv?map=/srv/mapserv/MapFiles/LB_localOWS_test.map&service=WFS&version=1.1.0&request=getfeature&typename=LB_sliders_test&maxfeatures=100

<gml:posList srsDimension="2">5417870.977814 3514129.458722

while WFS 1.0.0 sends them as easting-northing

http://maps.iguess.tudor.lu/cgi-bin/mapserv?map=/srv/mapserv/MapFiles/LB_localOWS_test.map&service=WFS&version=1.0.0&request=getfeature&typename=LB_sliders_test&maxfeatures=100

<gml:coordinates>3514129.458722,5417870.977814 
  1. Actually OpenLayers WFS protocol should be clever enough and flip axis automatically when needed but that may not be the case. You should be able to give a hint for OpenLayers with format option "xy" as in a rather similar case in OpenLayers WFS flip coordinates
formatOptions: {
       xy: false
}
|improve this answer|||||
  • The behaviour is the same with WFS 1.0.0, but what you describe is indeed interesting. I'll try solution 2 and report back. What is solution 3? – Luís de Sousa Oct 17 '14 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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