osm-python-tools icon indicating copy to clipboard operation
osm-python-tools copied to clipboard

Could we get (perhaps computed) center coordinates for all elements?

Open mcepl opened this issue 2 years ago • 1 comments
trafficstars

For example:

from OSMPythonTools.api import Api
api = Api()
way = api.query('relation/3629242')
way.centerLat()
way.centerLon()

I understand that it is probably not trivial and some computation would have to be done in the background, but either remove those methods when they cannot be filled with some meaningful data or compute the result?

mcepl avatar Nov 18 '22 08:11 mcepl

The same in more detailed example:

import urllib.parse
from OSMPythonTools.api import Api

orig_url = "https://www.openstreetmap.org/way/30722274#map=14/49.2925/38.1815"
parsed_url = urllib.parse.urlparse(orig_url)

api = Api()
way = api.query(parsed_url.path)
print(way.centerLon(), way.centerLat())

mcepl avatar Dec 07 '22 17:12 mcepl