[Geoserver-users] WFS Question

I am using GeoServer and OpenLayers, and new to both. I am trying to highlight features using an OpenLayers control on a WMS layer from GeoServer. According to the response to the GetFeature request in Firebug, the numberOfFeatures=“0”. Can someone make a suggestion as to what the problem may be? The code is below:

var highlightLayer = new OpenLayers.Layer.Vector(“Highlighted Features”, {

styleMap: myStyles,

displayInLayerSwitcher: false,

isBaseLayer: false

}

);

var highlightControl = new OpenLayers.Control.GetFeature({

protocol: OpenLayers.Protocol.WFS.fromWMSLayer(mylayer),

box: false,

hover: false,

maxFeatures: 20

});

highlightControl.events.register(“featureselected”, this, function(e) {

highlightLayer.addFeatures([e.feature]);

});

highlightControl.events.register(“featureunselected”, this, function(e) {

highlightLayer.removeFeatures([e.feature]);

});

map.addControl(highlightControl);

highlightControl.activate();

The portion of the GeoServer log from the request is below:

2013-03-04 13:49:09,373 INFO [geoserver.wfs] -

Request: getServiceInfo

2013-03-04 13:49:09,388 INFO [geoserver.wfs] -

Request: getFeature

service = WFS

version = 1.1.0

baseUrl = http://myhost/geoserver/

query[0]:

filter = [ bbox POLYGON ((-8933564.1969439 4710806.2675763, -8933564.1969439 4710854.040719, -8933516.4238013 4710854.040719, -8933516.4238013 4710806.2675763, -8933564.1969439 4710806.2675763)) ]

srsName = EPSG:4326

typeName[0] = {http://myhost/workspace}layer

maxFeatures = 20

outputFormat = text/xml; subtype=gml/3.1.1

resultType = results

Any help you may provide is greatly appreciated.

Thanks.

Your geoserver log file shows that the srsName is 4326 but the filter is clearly in a projected system. I would have to say that my codes for doing this are a whole lot more complicated and part of that complication is projecting vector selection polygons into the projection of the native layer before doing the filter. Unfortunately, this logic is dependent on the server. Mapserver recognizes epsg in the filter; geoserver doesnt. I found it easiest to just reproject to server epsg on the client.

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

On Mon, Mar 4, 2013 at 10:06 PM, Phil Scadden <p.scadden@anonymised.com> wrote:

Your geoserver log file shows that the srsName is 4326 but the filter is
clearly in a projected system. I would have to say that my codes for
doing this are a whole lot more complicated and part of that
complication is projecting vector selection polygons into the projection
of the native layer before doing the filter.

srsName controls the output projection, not the filter

Unfortunately, this logic
is dependent on the server. Mapserver recognizes epsg in the filter;
geoserver doesnt. I found it easiest to just reproject to server epsg on
the client.

GeoServer has been recognizing epsg in the GetFeature filters for a couple of years now, we have tests
running in each build checking this behavior.
If you can make it misbehave please open a bug report

Cheeres
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it