added MRT sds image
This commit is contained in:
18
apps/dispatch/app/_helpers/findLeitstelleinPoint.ts
Normal file
18
apps/dispatch/app/_helpers/findLeitstelleinPoint.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user