19 lines
707 B
TypeScript
19 lines
707 B
TypeScript
import { point, multiPolygon, booleanPointInPolygon } from "@turf/turf";
|
|
import leitstellenGeoJSON from "../_components/map/_geojson/Leitstellen.json"; // Pfad anpassen
|
|
|
|
export function findLeitstelleForPosition(lat: number, lng: number) {
|
|
const heliPoint = point([lat, lng]);
|
|
|
|
for (const feature of (leitstellenGeoJSON as any).features) {
|
|
if (feature.geometry.type === "MultiPolygon") {
|
|
const polygon = multiPolygon(feature.geometry.coordinates);
|
|
if (booleanPointInPolygon(heliPoint, polygon)) {
|
|
console.log("Point is inside polygon:", feature.properties.name);
|
|
return feature.properties.name ?? "Unbenannte Leitstelle";
|
|
}
|
|
}
|
|
}
|
|
|
|
return null; // Keine passende Leitstelle gefunden
|
|
}
|