Check closest point against extent

This commit is contained in:
Tom Payne
2013-12-09 11:31:40 +00:00
parent 66f1826358
commit f4fe0046b2
7 changed files with 30 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
goog.provide('ol.geom.LineString');
goog.require('ol.extent');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.closest');
goog.require('ol.geom.flat');
@@ -40,6 +41,10 @@ goog.inherits(ol.geom.LineString, ol.geom.Geometry);
*/
ol.geom.LineString.prototype.closestPointXY =
function(x, y, closestPoint, minSquaredDistance) {
if (minSquaredDistance <
ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) {
return minSquaredDistance;
}
if (this.maxDeltaRevision_ != this.revision) {
this.maxDelta_ = Math.sqrt(ol.geom.closest.getMaxSquaredDelta(
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));