I've been having some issues using the distanceTo function on linestring geometries. I'm not sure this is a misunderstanding on my part or problems in the OL library.
An example:
var feat1, feat2, wkt1, wkt2;
var wkt = new OpenLayers.Format.WKT();
wkt1 = 'LINESTRING(0 0, 10 0)';
wkt2 = 'LINESTRING(11 0, 20 0)';
feat1 = wkt.read(wkt1);
feat2 = wkt.read(wkt2);
var dist = feat1.geometry.distanceTo(feat2.geometry);
console.log(dist); // would expect this to be 1? In fact returns 0
In fact any start X for the second line with a Y of 0 returns a distance of 0.
Also the docs at http://dev.openlayers.org/releases/OpenLayers-2.13.1/doc/apidocs/files/OpenLayers/Geometry/LineString-js.html#OpenLayers.Geometry.LineString.distanceTo states that this function "Calculate the closest distance between two geometries (on the x-y plane)" - however it appears to simply find the distance between the two closest vertices of the line geometries?
I've been having some issues using the distanceTo function on linestring geometries. I'm not sure this is a misunderstanding on my part or problems in the OL library.
An example:
In fact any start X for the second line with a Y of 0 returns a distance of 0.
Also the docs at http://dev.openlayers.org/releases/OpenLayers-2.13.1/doc/apidocs/files/OpenLayers/Geometry/LineString-js.html#OpenLayers.Geometry.LineString.distanceTo states that this function "Calculate the closest distance between two geometries (on the x-y plane)" - however it appears to simply find the distance between the two closest vertices of the line geometries?