@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.
|
@@ -6893,7 +6893,14 @@
|
|
|
6893
6893
|
}
|
|
6894
6894
|
getFeaturesAtCoordinate(coordinate) {
|
|
6895
6895
|
const [lon, lat] = coordinate;
|
|
6896
|
-
|
|
6896
|
+
const features = knn$1(this._featuresRtree, lon, lat, 10, (d2) => d2.feature.containsCoordinate(coordinate)).map((d2) => {
|
|
6897
|
+
const midX = d2.minX + (d2.minX + d2.maxX) / 2;
|
|
6898
|
+
const midY = d2.minY + (d2.minY + d2.maxY) / 2;
|
|
6899
|
+
d2.distance = Math.hypot(midX - lon, midY - lat);
|
|
6900
|
+
return d2;
|
|
6901
|
+
});
|
|
6902
|
+
features.sort((a, b) => a.distance - b.distance);
|
|
6903
|
+
return features.map((d2) => d2.feature);
|
|
6897
6904
|
}
|
|
6898
6905
|
getFeaturesInExtent(extent) {
|
|
6899
6906
|
const [minX, minY, maxX, maxY] = extent;
|