Say I have the following point in EPSG:25832: [799325.792813, 5828257.530253]
I am having trouble displaying it on a leaflet map.
Using proj4, I was able to convert it to EPSG:3857
import proj4 from 'proj4'
import {transform} from 'ol/proj'
import {register} from 'ol/proj/proj4'
proj4.defs('EPSG:25832', '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs')
register(proj4)
transform([799325.792813, 5828257.530253], 'EPSG:25832', 'EPSG:3857')
// result: [1493102.7063423465, 6895070.810356369]
So the result is again in meters. I have tried to unproject the result to get the coordinates in degrees:
leafletObject?.unproject([1493102.7063423465, 6895070.810356369])
// result: {lat: -90, lng: 32627.43251240508}
But that does not yield the right result.
I then tried directly transforming to WGS84 in proj4, but the result is off the coast of northern France rather than in Berlin:
const [lat, lng] = transform([799325.792813, 5828257.530253], 'EPSG:25832', 'WGS84')
//result: [51.01550382751145, 1.9889839639171145]
leafletObject?.addLayer(L.marker({lat, lng}))
What am I doing wrong?
I managed to solve this - I was actually almost there but in my actual code I was passing the x/y values in the wrong order. The following actually works: