From 566c974ad696912ec195fb54c43c273b061da7e6 Mon Sep 17 00:00:00 2001 From: "j.mei7" Date: Sun, 27 Mar 2022 15:00:37 +0200 Subject: [PATCH] a --- __pycache__/server.cpython-310.pyc | Bin 0 -> 323 bytes analyze.py | 68 +++++++++++++++++++++++++++++ main.py | 64 --------------------------- server.py | 9 ++++ 4 files changed, 77 insertions(+), 64 deletions(-) create mode 100644 __pycache__/server.cpython-310.pyc create mode 100644 analyze.py delete mode 100644 main.py create mode 100644 server.py diff --git a/__pycache__/server.cpython-310.pyc b/__pycache__/server.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3a1d1aacef65c471360a4e580666455e474380ed GIT binary patch literal 323 zcmYjLO-lnY5X~f;C5Y>9u*WTa+@<(|A|9j&JqSx-iOrOP+0Bx)!uG0n|AHR8qmL>Kk51?7b!xfWKNWEpHmx`c_rs*7oXgy>blhp n)^!xR>!S2-wZy;4?Qj35loZvdab{)lJZ&8m(LPgL@dNk;tJ6Ty literal 0 HcmV?d00001 diff --git a/analyze.py b/analyze.py new file mode 100644 index 0000000..ca6ab67 --- /dev/null +++ b/analyze.py @@ -0,0 +1,68 @@ +OFFLINE = False +from managers import PlaceManager +from osm import OSM +from publicTransport import PublicTransportAccessibility +import requests + +# ADVANCED: +# Get external data of shops, like website +# Get General City/Region data: average age, peace index, democrazy index, average income + +# IDEAS: +# Parks +# ATMs + +# 52.9152386,,15.96z +# bhv 53.51500036203292, 8.603602165157444 +""" +# TODO Get User input +lon = 8.8285578 # 8.6039883 +lat = 52.9152386 # 52.51608 + +""" + +def get_data(lon, lat): + + # TODO Get real value based on a metric radius + areaHeightRadius = 0.01 # 0.01 + areaWidthRadius = 0.013 # 0.013 + + minLon = round(float(lon) - areaWidthRadius, 5) + maxLon = round(float(lon) + areaWidthRadius, 5) + + minLat = round(float(lat) - areaHeightRadius, 5) + maxLat = round(float(lat) + areaHeightRadius, 5) + + requestUrl = "https://overpass-api.de/api/map" + requestsUrlParams = f"?bbox={minLon},{minLat},{maxLon},{maxLat}" + + + if OFFLINE: + print("Using offline file!") + file = open("mapHH", encoding="utf8") + osm = OSM(file.read()) + else: + print(requestUrl + requestsUrlParams) + print("Downloading OSM-File...") + # TODO Check if banned from overpass-api MAYBE get alternative API then + r = requests.get(requestUrl + requestsUrlParams, headers={'Content-Type': 'application/xml'}) + print("Done: Downloading OSM-File") + osm = OSM(r.text) + + pta = PublicTransportAccessibility(osm) + placeManager = PlaceManager(osm) + + print("\n--- Public Transport Accessibility ---") + print("Bus: " + str(pta.isBusAccessible())) + print("Tram: " + str(pta.isTramAccessible())) + print("Light Rail: " + str(pta.isLightRailAccessible())) + print("Subway: " + str(pta.isSubwayAccessible())) + print("Train: " + str(pta.isTrainAccessible())) + print("Monorail: " + str(pta.isMonorailAccessible())) + + print("\n--- 20 Most present places types ---") + counter = 0 + for s in placeManager.getCountsOfTypes(): + if counter <= 20: + print(s['type'] + " : " + str(s['count']) + " times") + counter = counter + 1 \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 055b7ab..0000000 --- a/main.py +++ /dev/null @@ -1,64 +0,0 @@ -OFFLINE = True -from managers import PlaceManager -from osm import OSM -from publicTransport import PublicTransportAccessibility -import requests - -# ADVANCED: -# Get external data of shops, like website -# Get General City/Region data: average age, peace index, democrazy index, average income - -# IDEAS: -# Parks -# ATMs - -# 52.9152386,,15.96z -# bhv 53.51500036203292, 8.603602165157444 - -# TODO Get User input -lon = 8.8285578 # 8.6039883 -lat = 52.9152386 # 52.51608 - -# TODO Get real value based on a metric radius -areaHeightRadius = 0.01 # 0.01 -areaWidthRadius = 0.013 # 0.013 - -minLon = round(float(lon) - areaWidthRadius, 5) -maxLon = round(float(lon) + areaWidthRadius, 5) - -minLat = round(float(lat) - areaHeightRadius, 5) -maxLat = round(float(lat) + areaHeightRadius, 5) - -requestUrl = "https://overpass-api.de/api/map" -requestsUrlParams = f"?bbox={minLon},{minLat},{maxLon},{maxLat}" - - -if OFFLINE: - print("Using offline file!") - file = open("mapHH", encoding="utf8") - osm = OSM(file.read()) -else: - print(requestUrl + requestsUrlParams) - print("Downloading OSM-File...") - # TODO Check if banned from overpass-api MAYBE get alternative API then - r = requests.get(requestUrl + requestsUrlParams, headers={'Content-Type': 'application/xml'}) - print("Done: Downloading OSM-File") - osm = OSM(r.text) - -pta = PublicTransportAccessibility(osm) -placeManager = PlaceManager(osm) - -print("\n--- Public Transport Accessibility ---") -print("Bus: " + str(pta.isBusAccessible())) -print("Tram: " + str(pta.isTramAccessible())) -print("Light Rail: " + str(pta.isLightRailAccessible())) -print("Subway: " + str(pta.isSubwayAccessible())) -print("Train: " + str(pta.isTrainAccessible())) -print("Monorail: " + str(pta.isMonorailAccessible())) - -print("\n--- 20 Most present places types ---") -counter = 0 -for s in placeManager.getCountsOfTypes(): - if counter <= 20: - print(s['type'] + " : " + str(s['count']) + " times") - counter = counter + 1 diff --git a/server.py b/server.py new file mode 100644 index 0000000..207e383 --- /dev/null +++ b/server.py @@ -0,0 +1,9 @@ +from flask import Flask +from analyze import get_data + +app = Flask(__name__) + +@app.route('/analyze//', methods = ['POST', 'GET']) +def analyze(lon, lat): + get_data(lom, lat) + return 'Hello, World!' \ No newline at end of file