Merge pull request #10094 from ahocevar/immediate-hitdetection

New Layer#getFeatures method with fast hit detection
This commit is contained in:
Andreas Hocevar
2019-10-14 22:21:08 +02:00
committed by GitHub
20 changed files with 726 additions and 51 deletions
+18
View File
@@ -135,6 +135,24 @@ class BaseVectorLayer extends Layer {
return this.declutter_;
}
/**
* Get the topmost feature that intersects the given pixel on the viewport. Returns a promise
* that resolves with an array of features. The array will either contain the topmost feature
* when a hit was detected, or it will be empty.
*
* The hit detection algorithm used for this method is optimized for performance, but is less
* accurate than the one used in {@link import("../PluggableMap.js").default#getFeaturesAtPixel}: Text
* is not considered, and icons are only represented by their bounding box instead of the exact
* image.
*
* @param {import("../pixel.js").Pixel} pixel Pixel.
* @return {Promise<Array<import("../Feature").default>>} Promise that resolves with an array of features.
* @api
*/
getFeatures(pixel) {
return super.getFeatures(pixel);
}
/**
* @return {number|undefined} Render buffer.
*/
+9
View File
@@ -192,6 +192,15 @@ class Layer extends BaseLayer {
this.changed();
}
/**
* @param {import("../pixel").Pixel} pixel Pixel.
* @return {Promise<Array<import("../Feature").default>>} Promise that resolves with
* an array of features.
*/
getFeatures(pixel) {
return this.renderer_.getFeatures(pixel);
}
/**
* In charge to manage the rendering of the layer. One layer type is
* bounded with one layer renderer.
+18
View File
@@ -116,6 +116,24 @@ class VectorTileLayer extends BaseVectorLayer {
return new CanvasVectorTileLayerRenderer(this);
}
/**
* Get the topmost feature that intersects the given pixel on the viewport. Returns a promise
* that resolves with an array of features. The array will either contain the topmost feature
* when a hit was detected, or it will be empty.
*
* The hit detection algorithm used for this method is optimized for performance, but is less
* accurate than the one used in {@link import("../PluggableMap.js").default#getFeaturesAtPixel}: Text
* is not considered, and icons are only represented by their bounding box instead of the exact
* image.
*
* @param {import("../pixel.js").Pixel} pixel Pixel.
* @return {Promise<Array<import("../Feature").default>>} Promise that resolves with an array of features.
* @api
*/
getFeatures(pixel) {
return super.getFeatures(pixel);
}
/**
* @return {VectorTileRenderType} The render mode.
*/