Moving squaredDistanceToSegment to the coordinate package

This commit is contained in:
ahocevar
2013-11-04 19:19:54 +01:00
parent 20d5a45b7d
commit 1670b31142
3 changed files with 53 additions and 32 deletions

View File

@@ -3,6 +3,7 @@ goog.provide('ol.geom.LineString');
goog.require('goog.asserts');
goog.require('goog.events.EventType');
goog.require('ol.CoordinateArray');
goog.require('ol.coordinate');
goog.require('ol.extent');
goog.require('ol.geom');
goog.require('ol.geom.Geometry');
@@ -104,7 +105,7 @@ ol.geom.LineString.prototype.distanceFromCoordinate = function(coordinate) {
var coordinates = this.getCoordinates();
var dist2 = Infinity;
for (var i = 0, j = 1, len = coordinates.length; j < len; i = j++) {
dist2 = Math.min(dist2, ol.geom.squaredDistanceToSegment(coordinate,
dist2 = Math.min(dist2, ol.coordinate.squaredDistanceToSegment(coordinate,
[coordinates[i], coordinates[j]]));
}
return Math.sqrt(dist2);