First version of Karten App

This commit is contained in:
2026-10-09 04:20:40 +02:00
commit 83a36c7a22
41 changed files with 10834 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import proj4 from "proj4";
import type { Point } from "../karte/types";
const ETRS25832 =
"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs";
proj4.defs("EPSG:25832", ETRS25832);
export function toEtrs(lon: number, lat: number): Point {
const projected = proj4("EPSG:4326", "EPSG:25832", [lon, lat]);
return { easting: projected[0], northing: projected[1] };
}
export function watchStandort(
onStandort: (standort: Point | "denied") => void,
): () => void {
if (!navigator.geolocation) {
onStandort("denied");
return () => {};
}
const id = navigator.geolocation.watchPosition(
(position) => {
onStandort(toEtrs(position.coords.longitude, position.coords.latitude));
},
(error) => {
if (error.code === error.PERMISSION_DENIED) onStandort("denied");
},
{ enableHighAccuracy: true },
);
return () => navigator.geolocation.clearWatch(id);
}