[OpenLayers-Users] GetFeature with WFS protocol doesn't return features
Flavien.Audin
flavien.audin at univ-tours.fr
Fri Mar 8 06:24:42 PST 2013
Hi Lauri,
I'm new with Openlayers and WFS stuff, but I got the same problem as you
yesterday : GetFeature() didn't return any feature using a WFS protocol. I
found the solution by looking at the POST request (using the firebug
console) :
The coordinates of the BBox (I allow selecting features with box) sent
through WFS request, wasn't in the specified SRS (4326 in my case).
For example,
...
<ogc:BBOX>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:4326">
<gml:lowerCorner>-6843570.0309686
1828570.8275305</gml:lowerCorner>
<gml:upperCorner>-6837913.6908763
1834227.1676228</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
...
So, the WFS didn't find any features in the BBox as everything using
normally EPSG:4326
Here my solution :
I declared a WFS protocol (instead of using
"OpenLayers.Protocol.WFS.fromWMSLayer(myLayer)" ) :
var WFSprotocol = OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "*****",
srsName:"EPSG:900913", // the BBos SRS, why it's working now
featureType:"****",
featurePrefix:"****"
});
Then I used this WFS protocol for my selectFeatureControl = new
OpenLayers.Control.GetFeature({
protocol: WFSprotocol ,
box: true,
multiple:false,
hover: false,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});
If I check my POST request, I got :
...
<ogc:BBOX>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:900913">
<gml:lowerCorner>-6843570.0309686
1828570.8275305</gml:lowerCorner>
<gml:upperCorner>-6837913.6908763
1834227.1676228</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
...
and I got my selected features :)
Now, I got an other problem with multiple featureType (not in the
above-example) that change between two calls, but I'll post my own thread ;)
Hope it will help you
--
Flavien
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/GetFeature-with-WFS-protocol-doesn-t-return-features-tp5035347p5039195.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list