@guardian/interactive-component-library 0.1.0-alpha.50 → 0.1.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6897,7 +6897,14 @@ class VectorSource {
|
|
|
6897
6897
|
}
|
|
6898
6898
|
getFeaturesAtCoordinate(coordinate) {
|
|
6899
6899
|
const [lon, lat] = coordinate;
|
|
6900
|
-
|
|
6900
|
+
const features = knn$1(this._featuresRtree, lon, lat, 10, (d2) => d2.feature.containsCoordinate(coordinate)).map((d2) => {
|
|
6901
|
+
const midX = d2.minX + (d2.minX + d2.maxX) / 2;
|
|
6902
|
+
const midY = d2.minY + (d2.minY + d2.maxY) / 2;
|
|
6903
|
+
d2.distance = Math.hypot(midX - lon, midY - lat);
|
|
6904
|
+
return d2;
|
|
6905
|
+
});
|
|
6906
|
+
features.sort((a, b) => a.distance - b.distance);
|
|
6907
|
+
return features.map((d2) => d2.feature);
|
|
6901
6908
|
}
|
|
6902
6909
|
getFeaturesInExtent(extent) {
|
|
6903
6910
|
const [minX, minY, maxX, maxY] = extent;
|