osm-smart-menu icon indicating copy to clipboard operation
osm-smart-menu copied to clipboard

Support UTM coordinates in URL Templates

Open jgpacker opened this issue 5 years ago • 3 comments

https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

For example, https://geoportal.bayern.de/bayernatlas/?E=670944.04&N=5405283.56&zoom=11 seems to be equivalent to https://www.openstreetmap.org/#map=16/48.7778/11.3248.

Users should be able to specify links like this: https://geoportal.bayern.de/bayernatlas/?E={utm_easting}&N={utm_northing}&zoom={zoom}

There are JS libraries to do this, but they may require parameters such as zone in addition to easting and northing. I need to understand this better. Any help is appreciated.

jgpacker avatar Jul 24 '20 19:07 jgpacker

Zones depend on the location, see http://epsg.io/?q=utm for instance. Zone in your first link explains that.

Bibi56 avatar Dec 21 '21 23:12 Bibi56

In Geohack, you see the corresponding UTM zone, for the above example

UTM 32U 670791 5405362

A possibility would to have new parameters {x:<EPSGCode>} {y:<EPSGCode>}, here {x:32632} and {y:32632}, see http://epsg.io/32632, so that you can use proj4.js to convert from lat/lon (i.e. EPSG:4326) to EPSG:32632. Another is to add {x:UTM} {y:UTM} and (mis)use Geohack to get the UTM coordinates.

Geohack https://geohack.toolforge.org/geohack.php?params={latitude}N{longitude}_E

Bibi56 avatar Dec 26 '21 22:12 Bibi56

I've wanted to add a redirect for the norwegian mapping authority's orthophoto service, Norge i Bilder (https://norgeibilder.no/). It, however, uses UTM 33 (https://epsg.io/32633), not lon & lat linke OSM. I therefore needed to convert between the two.

I made a crude python script to convert between the urls using the epsg api (https://github.com/maptiler/epsg.io#for-one-point). It was surprisingly easy, although I have no idea how such functionality should be implemented in this extension. My code is as follows:

# Script to translate between lon-lat and UTM zone 33N, to jump from OSM to the norwegian mapping authority's orthophoto service, Norge i Bilder

import requests

osm_url = "https://www.openstreetmap.org/#map=17/60.36682/5.35884" # Any OSM link in norway 
zoom = int(osm_url.split("/")[-3][5::])
lat = osm_url.split("/")[-2]
lon = osm_url.split("/")[-1]

api_url = f"http://epsg.io/trans?x={lon}&y={lat}&s_srs=4326&t_srs=32633" # url for the epsg api, convert from epgs:4326 (lon lat) to epgs:32633 (UTM 33)
r = requests.get(api_url)
result = r.json()

x = result["x"]
y = result["y"]
new_zoom = zoom - 2 # This gives roughly the same zoom level, based on testing

NiB_url = f"https://norgeibilder.no/?x={x}&y={y}&level={new_zoom}&utm=33"
print(NiB_url)

I'm hoping that something like this could be implemented, as not all services support longitude and latitude. I wish I could contribute directly to this repository, but I don't have the required expertise, sadly. I hope this was helpful.

v0iden avatar Mar 15 '22 09:03 v0iden