From b4259d74a1dadf10a6111b3680d6db872061e210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20M=C3=BCnch?= Date: Sun, 26 Jan 2020 19:04:52 +0100 Subject: [PATCH] Initial commit --- get_coordinates.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ locations.bin | Bin 0 -> 5572 bytes 2 files changed, 52 insertions(+) create mode 100755 get_coordinates.py create mode 100644 locations.bin diff --git a/get_coordinates.py b/get_coordinates.py new file mode 100755 index 0000000..260464f --- /dev/null +++ b/get_coordinates.py @@ -0,0 +1,52 @@ +#!/usr/bin/python +import requests, json, pickle, os.path + +URL = "https://directory.spaceapi.io/" +NORTHERNMOST = 55.05 +EASTERNMOST = 15.033333 +SOUTHERNMOST = 47.270108 +WESTERNMOST = 5.866667 +locations = {} +if os.path.isfile('locations.bin'): + print ("using offline data...") + with open("locations.bin", "rb") as f: + locations = pickle.load(f) +else: + print ("offline data not available, downloading...,") + r = requests.get(url = URL) + data = r.json() + for space in data: + spacerequest = None + try: + spacerequest = requests.get(url = data[space], timeout=1) + except requests.exceptions.RequestException as e: # This is the correct syntax + continue + try: + spacedata = spacerequest.json() + except json.JSONDecodeError as jde: + continue + if "location" in spacedata: + if "lat" in spacedata["location"]: + lat = spacedata["location"]["lat"] + lon = spacedata["location"]["lon"] + locations[space] = [float(lat), float(lon)] + + for space in locations: + print (space + " " + str(locations[space])) + with open("locations.bin", "wb") as f: + pickle.dump(locations, f, pickle.HIGHEST_PROTOCOL) +print ("Removing non-german points...") +nongerman_locations = locations.copy() +for space in locations: + if locations[space][0] > NORTHERNMOST: + del nongerman_locations[space] + print ("kicked " + space + " too far north") + elif locations[space][0] < SOUTHERNMOST: + del nongerman_locations[space] + print ("kicked " + space + " too far south") + elif locations[space][1] < WESTERNMOST: + del nongerman_locations[space] + print ("kicked " + space + " too far west") + elif locations[space][1] > EASTERNMOST: + del nongerman_locations[space] + print ("kicked " + space + " too far east") diff --git a/locations.bin b/locations.bin new file mode 100644 index 0000000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