AW: [OpenLayers-Users] Spatial Filter Result wrong
Arnd Wippermann
arnd.wippermann at web.de
Fri Jun 17 12:59:50 EDT 2011
as far as I can see from OpenLayers\Filter\Spatial.js is the filter type not
supported
evaluate: function(feature) {
var intersect = false;
switch(this.type) {
case OpenLayers.Filter.Spatial.BBOX:
case OpenLayers.Filter.Spatial.INTERSECTS:
if(feature.geometry) {
var geom = this.value;
if(this.value.CLASS_NAME == "OpenLayers.Bounds") {
geom = this.value.toGeometry();
}
if(feature.geometry.intersects(geom)) {
intersect = true;
}
}
break;
default:
OpenLayers.Console.error(
OpenLayers.i18n("filterEvaluateNotImplemented"));
break;
}
return intersect; //is false for case default
},
Arnd
_____
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Coup Coup
Gesendet: Freitag, 17. Juni 2011 16:47
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] Spatial Filter Result wrong
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/642ca849/attachment.html
More information about the Users
mailing list