Add ol.geom.Polygon#closestPointXY
This commit is contained in:
@@ -2,6 +2,7 @@ goog.provide('ol.geom.Polygon');
|
|||||||
|
|
||||||
goog.require('ol.geom.Geometry');
|
goog.require('ol.geom.Geometry');
|
||||||
goog.require('ol.geom.LinearRing');
|
goog.require('ol.geom.LinearRing');
|
||||||
|
goog.require('ol.geom.closest');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.simplify');
|
||||||
|
|
||||||
@@ -35,12 +36,40 @@ ol.geom.Polygon = function(coordinates, opt_layout) {
|
|||||||
*/
|
*/
|
||||||
this.interiorPoint_ = null;
|
this.interiorPoint_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.maxDelta_ = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.maxDeltaRevision_ = -1;
|
||||||
|
|
||||||
this.setCoordinates(coordinates, opt_layout);
|
this.setCoordinates(coordinates, opt_layout);
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.geom.Polygon, ol.geom.Geometry);
|
goog.inherits(ol.geom.Polygon, ol.geom.Geometry);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.geom.Polygon.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_, true, x, y, closestPoint, minSquaredDistance);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user