I am using GeoServer and OpenLayers. I have an OGC filter setup to be used on a WMS layer. The filtered features are being placed on a vector layer. As long as the value that I pass to the filter does not contain any whitespace, the filter works fine, and the features are returned by GeoServer. If the value passed to the filter contains whitespace within it, nothing is returned by GeoServer. I am using Firefox with Firebug to test the map, and all of the values that are passed to the filter are shown correctly in the POST command. I know the features exist on the layer that is being filtered, so the problem is with the filter when the value contains whitespace. Below is the portion of my code used to make the request:
var filter = new OpenLayers.Filter.Comparison(
{ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: ‘myproperty’, value: âÂÂmyvalueâ }
);
wfsProtocol = new OpenLayers.Protocol.WFS(
{ version: “1.1.0”, url: “http://myserver:8080/geoserver/mystore/wfs”, featureType: “mylayer”, //name of the geoserver layer featureNS: “mystore”, //name of the geoserver store geometryName: “the_geom”, srsName: “EPSG:4326”, scope: strategy }
);
var strategy = new OpenLayers.Strategy.Fixed(); var response = wfsProtocol.read(
{ filter: filter, callback: processWFSQuery }
); function processWFSQuery(response) { try {
var gmlParser = new OpenLayers.Format.GML.v3();
var features = gmlParser.read(response.priv.responseXML);
vectorLayer.destroyFeatures();
if(features.length > 0) {
for(var i = 0; i < features.length; i++)
{ var feature = features[i]; feature.geometry.transform(new OpenLayers.Projection(‘EPSG:4326’),this.map.getProjectionObject()); vectorLayer.addFeatures(feature); }
layextent = vectorLayer.getDataExtent();
map.zoomToExtent(layextent);
}else {
alert(“Not found!”);
if (popup)
{ popup.destroy(); }
}
} catch(e)
{ alert("Error: " + e); }
}
I am using a shapefile data store. The post request for the feature that is found is as follows:
XML
<wfs:GetFeature xmlns:wfs=“http://www.opengis.net/wfs” service=“WFS” version=“1.1.0” xsi:schemaLocation=“http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
<wfs:Query typeName=“feature:wv_mineral_tracts” srsName=“EPSG:4326” xmlns:feature=“wv_data”>
<ogc:Filter xmlns:ogc=“http://www.opengis.net/ogc”>
<ogc:PropertyIsEqualTo matchCase=“true”>
<ogc:PropertyName>ROOTID</ogc:PropertyName>
<ogc:Literal>01-01-9999-0100-0990-0000</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
Source
<wfs:GetFeature xmlns:wfs=“http://www.opengis.net/wfs” service=“WFS” version=“1.1.0” xsi:schemaLocation=“http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”><wfs:Query typeName=“feature:wv_mineral_tracts” srsName=“EPSG:4326” xmlns:feature=“wv_data”><ogc:Filter xmlns:ogc=“http://www.opengis.net/ogc”><ogc:PropertyIsEqualTo matchCase=“true”><ogc:PropertyName>ROOTID</ogc:PropertyName><ogc:Literal>01-01-9999-0100-0990-0000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter></wfs:Query></wfs:GetFeature>
And the response for the above request is below:
<?xml version=“1.0” encoding=“UTF-8”?>
<wfs:FeatureCollection numberOfFeatures=“1” timeStamp=“2013-04-12T12:32:44.975Z” xsi:schemaLocation=“http://www.titlemaps.com/wv_data http://www.titlemaps.com:8080/geoserver/wv_data/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=wv_data%3Awv_mineral_tracts http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd” xmlns:ogc=“http://www.opengis.net/ogc” xmlns:gml=“http://www.opengis.net/gml” xmlns:wv_data=“http://www.titlemaps.com/wv_data” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xlink=“http://www.w3.org/1999/xlink” xmlns:ows=“http://www.opengis.net/ows” xmlns:wfs=“http://www.opengis.net/wfs”><gml:featureMember><wv_data:wv_mineral_tracts gml:id=“wv_mineral_tracts.57”><wv_data:the_geom><gml:MultiSurface srsDimension=“2” srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”><gml:surfaceMember><gml:Polygon srsDimension=“2”><gml:exterior><gml:LinearRing srsDimension=“2”><gml:posList>-79.91917805223417 38.99168620084022 -79.91775518812635 38.99146850204535 -79.9159418034612 38.98777276004835 -79.91486534977649 38.988193573320714 -79.91450162234823 38.98868830854628 -79.91353024036711 38.98818853580909 -79.91308215154596 38.98832832930842 -79.9077928103966 38.98476003091119 -79.91022019770175 38.98328188522186 -79.90963054816243 38.98245500701079 -79.91073246547312 38.98169203909736 -79.9116146582654 38.98156225053195 -79.91292513862976 38.981165179028835 -79.91344347967444 38.982230841650555 -79.91271894124013 38.98300726263689 -79.91209214827362 38.98321836175092 -79.91288307485652 38.98385944136893 -79.91260656668068 38.98449696878364 -79.9138493929973 38.98478611867047 -79.91529727270267 38.98337388110928 -79.91670959318768 38.984159812343385 -79.91796931267791 38.983383826308994 -79.9175439067215 38.98785006863406 -79.91822241655356 38.99012226609006 -79.91917805223417 38.99168620084022</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface></wv_data:the_geom><wv_data:ROOTID>01-01-9999-0100-0990-0000</wv_data:ROOTID></wv_data:wv_mineral_tracts></gml:featureMember></wfs:FeatureCollection>
The post request for the feature that is not found is below:
XML
<wfs:GetFeature xmlns:wfs=“http://www.opengis.net/wfs” service=“WFS” version=“1.1.0” xsi:schemaLocation=“http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
<wfs:Query typeName=“feature:wv_mineral_tracts” srsName=“EPSG:4326” xmlns:feature=“wv_data”>
<ogc:Filter xmlns:ogc=“http://www.opengis.net/ogc”>
<ogc:PropertyIsEqualTo matchCase=“true”>
<ogc:PropertyName>ROOTID</ogc:PropertyName>
<ogc:Literal>01-01- 17-0012-0000-0000</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
Source
<wfs:GetFeature xmlns:wfs=“http://www.opengis.net/wfs” service=“WFS” version=“1.1.0” xsi:schemaLocation=“http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”><wfs:Query typeName=“feature:wv_mineral_tracts” srsName=“EPSG:4326” xmlns:feature=“wv_data”><ogc:Filter xmlns:ogc=“http://www.opengis.net/ogc”><ogc:PropertyIsEqualTo matchCase=“true”><ogc:PropertyName>ROOTID</ogc:PropertyName><ogc:Literal>01-01- 17-0012-0000-0000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter></wfs:Query></wfs:GetFeature>
The response for the request above is below:
<?xml version=“1.0” encoding=“UTF-8”?>
<wfs:FeatureCollection numberOfFeatures=“0” timeStamp=“2013-04-12T12:38:05.961Z” xsi:schemaLocation=“http://www.titlemaps.com/wv_data http://www.titlemaps.com:8080/geoserver/wv_data/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=wv_data%3Awv_mineral_tracts http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd” xmlns:ogc=“http://www.opengis.net/ogc” xmlns:gml=“http://www.opengis.net/gml” xmlns:wv_data=“http://www.titlemaps.com/wv_data” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xlink=“http://www.w3.org/1999/xlink” xmlns:ows=“http://www.opengis.net/ows” xmlns:wfs=“http://www.opengis.net/wfs”/>
I get the same type of response for any features that have whitespace within the value passed to the filter. Both of the features in the requests above exist in the shapefile. In the layer preview of GeoServer I can perform the search and both features are found.
If you need any additional information, please let me know.
|