[OpenLayers-Users] Spatial Filter Result wrong

Coup Coup tencoupons55 at yahoo.com
Fri Jun 17 10:46:36 EDT 2011


I am trying to get a client-side openlayers function that can determine if 2 geometries are within x miles of each other. First, I'm trying to develop a prototype of said methodology using spatial filters. My end result is wrong (false).  (there are no river crossings)

Here is the test:
fishkill = new OpenLayers.Geometry.Point(-73.903094, 41.534933);
//(Fishkill, NY 12524)
fishkill = fishkill.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));

poughkeepsie = new OpenLayers.Geometry.Point(-73.87089, 41.640904);
//( Poughkeepsie, NY 12603)
poughkeepsie = poughkeepsie.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));
               
var tolerance = 20;
filter = new OpenLayers.Filter.Spatial({type: OpenLayers.Filter.Spatial.DWITHIN,
                    value: poughkeepsie, distance:tolerance, distanceUnits: 'mi'})
alert('Result: ' + filter.evaluate(fishkill));


This test returns false, indicating to me that fishkill is NOT within 20 miles of poughkeepsie (this is wrong, the points are actually about 9 miles apart.) 

Anyone see what I'm doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110617/45bf850f/attachment-0001.html


More information about the Users mailing list