Do not change ol.extent.containsCoordinate
This commit is contained in:
@@ -57,26 +57,15 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if (one of) the passed coordinate(s) is contained or on the edge
|
* Checks if the passed coordinate is contained or on the edge of the extent.
|
||||||
* of the extent.
|
|
||||||
*
|
*
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {ol.Coordinate|Array.<ol.Coordinate>} coordinates Coordinate(s).
|
* @param {ol.Coordinate} coordinates Coordinate.
|
||||||
* @return {boolean} Contains.
|
* @return {boolean} Contains.
|
||||||
*/
|
*/
|
||||||
ol.extent.containsCoordinate = function(extent, coordinates) {
|
ol.extent.containsCoordinate = function(extent, coordinate) {
|
||||||
coordinates = goog.isArray(coordinates[0]) ? coordinates : [coordinates];
|
return extent[0] <= coordinate[0] && coordinate[0] <= extent[1] &&
|
||||||
var contains = false,
|
extent[2] <= coordinate[1] && coordinate[1] <= extent[3];
|
||||||
coordinate, i;
|
|
||||||
for (i = coordinates.length - 1; i >= 0; --i) {
|
|
||||||
coordinate = coordinates[i];
|
|
||||||
if (extent[0] <= coordinate[0] && coordinate[0] <= extent[1] &&
|
|
||||||
extent[2] <= coordinate[1] && coordinate[1] <= extent[3]) {
|
|
||||||
contains = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return contains;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -238,8 +238,14 @@ ol.renderer.canvas.VectorLayer.prototype.getFeatureInfoForPixel =
|
|||||||
[[location[0] - halfWidth, location[1] - halfHeight],
|
[[location[0] - halfWidth, location[1] - halfHeight],
|
||||||
[location[0] + halfWidth, location[1] + halfHeight]]);
|
[location[0] + halfWidth, location[1] + halfHeight]]);
|
||||||
coordinates = geom.getCoordinates();
|
coordinates = geom.getCoordinates();
|
||||||
if (ol.extent.containsCoordinate(symbolBounds, coordinates)) {
|
if (!goog.isArray(coordinates[0])) {
|
||||||
result.push(candidate);
|
coordinates = [coordinates];
|
||||||
|
}
|
||||||
|
for (j = coordinates.length - 1; j >= 0; --j) {
|
||||||
|
if (ol.extent.containsCoordinate(symbolBounds, coordinates[j])) {
|
||||||
|
result.push(candidate);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (goog.isFunction(geom.containsCoordinate)) {
|
} else if (goog.isFunction(geom.containsCoordinate)) {
|
||||||
// For polygons, check if the pixel location is inside the polygon
|
// For polygons, check if the pixel location is inside the polygon
|
||||||
|
|||||||
Reference in New Issue
Block a user