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
|
||||
}
|
||||
@@ -1,2 +1,7 @@
|
||||
export const checkSimulatorConnected = (date: Date) =>
|
||||
date && Date.now() - new Date(date).getTime() <= 3000_000;
|
||||
import { ConnectedAircraft } from "@repo/db";
|
||||
|
||||
export const checkSimulatorConnected = (a: ConnectedAircraft) => {
|
||||
if (!a.lastHeartbeat || Date.now() - new Date(a.lastHeartbeat).getTime() > 30_000) return false; // 30 seconds
|
||||
if (!a.posLat || !a.posLng) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user