Add ol.geom.MultiLineString#closestPointXY

This commit is contained in:
Tom Payne
2013-12-07 12:45:25 +01:00
parent 99042c956a
commit 128e174ee2

View File

@@ -2,6 +2,7 @@ goog.provide('ol.geom.MultiLineString');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.LineString');
goog.require('ol.geom.closest');
goog.require('ol.geom.flat');
goog.require('ol.geom.simplify');
@@ -23,12 +24,40 @@ ol.geom.MultiLineString = function(coordinates, opt_layout) {
*/
this.ends_ = [];
/**
* @private
* @type {number}
*/
this.maxDelta_ = -1;
/**
* @private
* @type {number}
*/
this.maxDeltaRevision_ = -1;
this.setCoordinates(coordinates, opt_layout);
};
goog.inherits(ol.geom.MultiLineString, ol.geom.Geometry);
/**
* @inheritDoc
*/
ol.geom.MultiLineString.prototype.closestPointXY =
function(x, y, closestPoint, minSquaredDistance) {
if (this.maxDeltaRevision_ != this.revision) {
this.maxDelta_ = Math.sqrt(ol.geom.closest.getsMaxSquaredDelta(
this.flatCoordinates, 0, this.ends_, this.stride, 0));
this.maxDeltaRevision_ = this.revision;
}
return ol.geom.closest.getsClosestPoint(
this.flatCoordinates, 0, this.ends_, this.stride,
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
};
/**
* @return {ol.geom.RawMultiLineString} Coordinates.
*/