Add ol.geom.Geometry#getClosestPoint
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
@exportSymbol ol.geom.Geometry
|
@exportSymbol ol.geom.Geometry
|
||||||
|
@exportProperty ol.geom.Geometry.prototype.getClosestPoint
|
||||||
@exportProperty ol.geom.Geometry.prototype.getExtent
|
@exportProperty ol.geom.Geometry.prototype.getExtent
|
||||||
@exportProperty ol.geom.Geometry.prototype.getLayout
|
@exportProperty ol.geom.Geometry.prototype.getLayout
|
||||||
@exportProperty ol.geom.Geometry.prototype.getSimplifiedGeometry
|
@exportProperty ol.geom.Geometry.prototype.getSimplifiedGeometry
|
||||||
|
|||||||
@@ -103,6 +103,30 @@ ol.geom.Geometry = function() {
|
|||||||
goog.inherits(ol.geom.Geometry, ol.Observable);
|
goog.inherits(ol.geom.Geometry, ol.Observable);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} x X.
|
||||||
|
* @param {number} y Y.
|
||||||
|
* @param {ol.Coordinate} closestPoint Closest point.
|
||||||
|
* @param {number} minSquaredDistance Minimum squared distance.
|
||||||
|
* @return {number} Minimum squared distance.
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.closestPointXY = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Coordinate} point Point.
|
||||||
|
* @param {ol.Coordinate=} opt_closestPoint Closest point.
|
||||||
|
* @return {ol.Coordinate} Closest point.
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) {
|
||||||
|
// FIXME check extent
|
||||||
|
var closestPoint = goog.isDef(opt_closestPoint) ?
|
||||||
|
opt_closestPoint : [NaN, NaN];
|
||||||
|
this.closestPointXY(point[0], point[1], closestPoint, Infinity);
|
||||||
|
return closestPoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
Reference in New Issue
Block a user