Skip to content

LineString distanceTo Issues #1391

Open
@geographika

Description

@geographika

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions