remove obsolete script

This commit is contained in:
Pim Kunis 2023-08-27 13:49:50 +02:00
parent 2bb1b16f2d
commit 6be7cabac2

View file

@ -1,58 +0,0 @@
#!/bin/python3
import osmapi
import itertools
import math
# import pickle
# import os
OSM_KOGGENLAND_ID = 161930
PICKLE_FILE = 'koggenland.pickle'
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]
def flatten(lst):
return list(itertools.chain(*lst))
def main():
osm_api = osmapi.OsmApi()
koggenland = osm_api.RelationFullRecur(OSM_KOGGENLAND_ID)
node_ids = list(map(lambda a: a['data']['id'], filter(
lambda a: a['type'] == 'node', koggenland)))
coords = []
for chunk in chunks(node_ids, 100):
coords += map(lambda a: (a['lat'], a['lon']),
osm_api.NodesGet(chunk).values())
cx, cy = 0., 0.
for (x, y) in coords:
cx += x
cy += y
cx /= len(coords)
cy /= len(coords)
print('centre', (cx, cy))
# 7KM radius (eye-balled)
# max_coord = None
# max_dist = 0
# for (x, y) in coords:
# dist = math.sqrt((cx - x)**2 + (cy - y)**2)
# if dist > max_dist:
# max_dist = dist
# max_coord = (x, y)
# print('max', max_coord)
if __name__ == '__main__':
main()