Add ol.geom.Point#closestPointXY
This commit is contained in:
@@ -20,6 +20,24 @@ ol.geom.Point = function(coordinates, opt_layout) {
|
|||||||
goog.inherits(ol.geom.Point, ol.geom.Geometry);
|
goog.inherits(ol.geom.Point, ol.geom.Geometry);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.closestPointXY =
|
||||||
|
function(x, y, closestPoint, minSquaredDistance) {
|
||||||
|
var flatCoordinates = this.flatCoordinates;
|
||||||
|
var squaredDistance = ol.geom.flat.squaredDistance(
|
||||||
|
x, y, flatCoordinates[0], flatCoordinates[1]);
|
||||||
|
if (squaredDistance < minSquaredDistance) {
|
||||||
|
closestPoint[0] = flatCoordinates[0];
|
||||||
|
closestPoint[1] = flatCoordinates[1];
|
||||||
|
return squaredDistance;
|
||||||
|
} else {
|
||||||
|
return minSquaredDistance;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.geom.RawPoint} Coordinates.
|
* @return {ol.geom.RawPoint} Coordinates.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user