import proj4 from 'proj4'; // Define LV95 projection (EPSG:2056) and WGS84 (EPSG:4326) // LV95 / Swiss TM 35 const LV95_PROJ = '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; const WGS84_PROJ = 'EPSG:4326'; /** * Convert LV95 coordinates to WGS84 (lat/lon) * Uses proj4 for accurate coordinate transformation */ export function lv95ToWGS84(x: number, y: number): { lat: number; lon: number } { const [lon, lat] = proj4(LV95_PROJ, WGS84_PROJ, [x, y]); return { lat, lon }; } /** * Convert WGS84 (lat/lon) to LV95 coordinates * Uses proj4 for accurate coordinate transformation */ export function wgs84ToLV95(lat: number, lon: number): { x: number; y: number } { const [x, y] = proj4(WGS84_PROJ, LV95_PROJ, [lon, lat]); return { x, y }; }