From 6be7cabac2f579cf2172dfe7a988137b3186464a Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 27 Aug 2023 13:49:50 +0200 Subject: [PATCH] remove obsolete script --- find_centre.py | 58 -------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100755 find_centre.py diff --git a/find_centre.py b/find_centre.py deleted file mode 100755 index 7c79b0d..0000000 --- a/find_centre.py +++ /dev/null @@ -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()