Implement ol/geom/Geometry#containsXY

Fixes issue #8863
ol/source/Vector#getFeaturesAtCoordinate and
implementations of ol/geom/Geometry#containsXY
This commit is contained in:
timkeane
2018-11-09 07:58:04 -05:00
committed by Frederic Junod
parent 5967bc75ba
commit 7274798aa1
5 changed files with 2 additions and 43 deletions

View File

@@ -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;
} }
/** /**

View File

@@ -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
*/ */

View File

@@ -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
*/ */

View File

@@ -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
*/ */

View File

@@ -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
*/ */