[OpenLayers-Users] Problem using Spatial Filter

Diego Marin Santos diegomrsantos at gmail.com
Fri Oct 16 15:41:29 EDT 2009


I'm using a WFS layer and I wanna filter some features using a spatial
filter. My filter is of type: DWITHIN

Here is the code:

*var point =  new OpenLayers.Geometry.Point(-122.8764, 42.3263)
point.transform(new OpenLayers.Projection("EPSG:4326"), new
OpenLayers.Projection("EPSG:2270"));

var wfslayer = new OpenLayers.Layer.Vector("WFS", {
   strategies: [new OpenLayers.Strategy.BBOX()],
   protocol: new OpenLayers.Protocol.WFS({
             url:  "http://localhost:8080/geoserver/wfs",
             featureType: "schools",
             featureNS: "http://www.medford.org/",
             srsName: "EPSG:900913",
             version: "1.1.0"
             }),
filter:  new OpenLayers.Filter.Spatial({
           type: OpenLayers.Filter.Spatial.DWITHIN,
           property: "the_geom",
           value: point,
               distance : 4250
               })
});*

I have a doubt about what I should use in the value property of the Filter,
does the variable point have to be in the same projection of the data? I
think so. Is correct the way i did it? My feature type schools is in
EPSG:2270 projection.

But the main problem is that it returns a number of features that is
different of the number of features the postgis returns when I run this
query (that is equivalent to code above):

SELECT Count(*) as value
FROM schools
WHERE
 ST_DWithin(
           the_geom,
            ST_Transform(ST_GeomFromText('POINT(-122.8764 42.3263)',
4326),2270),
            4250
           );

What do you think is my mistake?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091016/c42358c7/attachment.html


More information about the Users mailing list