Check closest point against extent
This commit is contained in:
@@ -119,7 +119,6 @@ ol.geom.Geometry.prototype.closestPointXY = goog.abstractMethod;
|
||||
* @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);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.geom.LinearRing');
|
||||
|
||||
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.LinearRing, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.LinearRing.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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.geom.MultiLineString');
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.closest');
|
||||
@@ -47,6 +48,10 @@ goog.inherits(ol.geom.MultiLineString, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.MultiLineString.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.getsMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.geom.MultiPoint');
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.flat');
|
||||
@@ -24,6 +25,10 @@ goog.inherits(ol.geom.MultiPoint, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.closestPointXY =
|
||||
function(x, y, closestPoint, minSquaredDistance) {
|
||||
if (minSquaredDistance <
|
||||
ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) {
|
||||
return minSquaredDistance;
|
||||
}
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var stride = this.stride;
|
||||
var i, ii;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.geom.MultiPolygon');
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.geom.closest');
|
||||
@@ -59,6 +60,10 @@ goog.inherits(ol.geom.MultiPolygon, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.MultiPolygon.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.getssMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.endss_, this.stride, 0));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.geom.Polygon');
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.LinearRing');
|
||||
goog.require('ol.geom.closest');
|
||||
@@ -59,6 +60,10 @@ goog.inherits(ol.geom.Polygon, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.Polygon.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.getsMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||
|
||||
Reference in New Issue
Block a user