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

My task is very straightforward: a user draws a polygon and query all parcel polygons. The query string extends the URL limit. So I am posting XML to WFS. However, GeoServer always returned 0 feature, but I knew the query polygon overlapped several tax parcels. If I passed a single point, it worked fine. Did I miss anything for sending a polygon? I used the OpenLayers buildGeometry to create the polygon GML. I can't figure out what's wrong. Please Help. THANK YOU IN ADVANCE.

Here is my code:

var gml = new OpenLayers.Format.GML(); 
var polygonGML = gml.buildGeometry.polygon.apply(gml,[taArray[0].geometry])
var plgGMLString = (new XMLSerializer()).serializeToString(polygonGML);

var geo_req_url = proxyHost + "http://localhost:8080/geoserver/wfs"; 

var query_xml = '<?xml version=' 
    + '<wfs:GetFeature service="WFS" version="1.1.0" xmlns:wfs="" xmlns="" xmlns:gml="" xmlns:xsi="" xsi:schemaLocation="">' 
    + '<wfs:Query typeName="topp:tax_parcel"><Filter><Intersects><PropertyName>geom</PropertyName>'
    + plgGMLString 
    + '</Intersects></Filter></wfs:Query></wfs:GetFeature>'; 

    function(data) {
        geoResults = data.features;

Here is the printout of plgGMLString.

<gml:Polygon> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates decimal="." cs="," ts=" ">-74.00567761405651,40.546826958183715 ...</gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> </gml:Polygon>

share|improve this question

So is the polygon in north america? Mind that WFS 1.1 assumes by default a lat/lon axis order, so you might have to flip coordinates. See also this:

share|improve this answer
It's in NA. My plgGMLString printout is in a right order (-74.00567761405651,40.546826958183715). If I change a polygon to a point, the query works fine. – freddell Jul 25 '12 at 16:25
That is not the right order according to WFS 1.1, which expects lat and then lon (so, 40 -74, not the opposite). Maybe when encoding then point the encoder is explicit and states the srs is EPSG:4326 instead of the WFS 1.1 default urn:x-ogc:....:4326 one? – Andrea Aime Jul 26 '12 at 7:34

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.