Implement ol/geom/Geometry#containsXY
Fixes issue #8863 ol/source/Vector#getFeaturesAtCoordinate and implementations of ol/geom/Geometry#containsXY
This commit is contained in:
@@ -92,7 +92,8 @@ class Geometry extends BaseObject {
|
|||||||
* @return {boolean} Contains (x, y).
|
* @return {boolean} Contains (x, y).
|
||||||
*/
|
*/
|
||||||
containsXY(x, y) {
|
containsXY(x, y) {
|
||||||
return false;
|
const coord = this.getClosestPoint([x, y]);
|
||||||
|
return coord[0] === x && coord[1] === y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,16 +88,6 @@ class LineString extends SimpleGeometry {
|
|||||||
return new LineString(this.flatCoordinates.slice(), this.layout);
|
return new LineString(this.flatCoordinates.slice(), this.layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @override
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
containsXY(x, y) {
|
|
||||||
const coord = this.getClosestPoint([x, y]);
|
|
||||||
return coord[0] === x && coord[1] === y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -100,17 +100,6 @@ class MultiLineString extends SimpleGeometry {
|
|||||||
return new MultiLineString(this.flatCoordinates.slice(), this.layout, this.ends_.slice());
|
return new MultiLineString(this.flatCoordinates.slice(), this.layout, this.ends_.slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @override
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
containsXY(x, y) {
|
|
||||||
return this.getLineStrings().some(function(lineString) {
|
|
||||||
return lineString.containsXY(x, y);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -57,17 +57,6 @@ class MultiPoint extends SimpleGeometry {
|
|||||||
return multiPoint;
|
return multiPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @override
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
containsXY(x, y) {
|
|
||||||
return this.getCoordinates().some(function(coord) {
|
|
||||||
return coord[0] === x && coord[1] === y;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -35,16 +35,6 @@ class Point extends SimpleGeometry {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @override
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
containsXY(x, y) {
|
|
||||||
const coord = this.getCoordinates();
|
|
||||||
return coord[0] === x && coord[1] === y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user