diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cc67606 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/__pycache__/objects.cpython-310.pyc b/__pycache__/objects.cpython-310.pyc index 4b2586f..a716978 100644 Binary files a/__pycache__/objects.cpython-310.pyc and b/__pycache__/objects.cpython-310.pyc differ diff --git a/__pycache__/osm.cpython-310.pyc b/__pycache__/osm.cpython-310.pyc index 14d1211..630f0ba 100644 Binary files a/__pycache__/osm.cpython-310.pyc and b/__pycache__/osm.cpython-310.pyc differ diff --git a/__pycache__/places.cpython-310.pyc b/__pycache__/places.cpython-310.pyc new file mode 100644 index 0000000..a1cc823 Binary files /dev/null and b/__pycache__/places.cpython-310.pyc differ diff --git a/__pycache__/publicTransport.cpython-310.pyc b/__pycache__/publicTransport.cpython-310.pyc index 0d563c5..4946328 100644 Binary files a/__pycache__/publicTransport.cpython-310.pyc and b/__pycache__/publicTransport.cpython-310.pyc differ diff --git a/main.py b/main.py index 8917dce..74637b9 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,14 @@ from osm import OSM +from places import Shops from publicTransport import PublicTransportAccessibility import requests + +# 52.9152386,,15.96z # bhv 53.51500036203292, 8.603602165157444 -lon = 8.603602165157444 # 8.6039883 -lat = 53.51500036203292 # 52.51608 + +# 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 @@ -21,18 +26,19 @@ requestsUrlParams = f"?bbox={minLon},{minLat},{maxLon},{maxLat}" print(requestUrl + requestsUrlParams) print("Downloading OSM-File...") -# TODO Check if banned from overpass-api +# 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) +shops = Shops(osm) 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())) \ No newline at end of file +print("Monorail:" + str(pta.isMonorailAccessible())) + +print(shops.countOfShops()) diff --git a/objects.py b/objects.py index 892fa2d..3639210 100644 --- a/objects.py +++ b/objects.py @@ -12,7 +12,24 @@ class Node: class NodeTag: def __init__(self, _id, _nodeId, _key, _value): - self.id = _id + self.id = int(_id) self.nodeId = int(_nodeId) self.key = str(_key) self.value = str(_value) + +class Way: + def __init__(self, _id, _version, _timestamp, _changeset, _uid, _user): + self.id = int(_id) + self.version = str(_version) + self.timestamp = str(_timestamp) + self.changeset = int(_changeset) + self.uid = int(_uid) + self.user = str(_user) + + +class WayTag: + def __init__(self, _id, _wayId, _key, _value): + self.id = int(_id) + self.wayId = int(_wayId) + self.key = str(_key) + self.value = str(_value) diff --git a/osm.py b/osm.py index 61f889a..d4be465 100644 --- a/osm.py +++ b/osm.py @@ -1,16 +1,19 @@ -from objects import Node, NodeTag +from objects import Node, NodeTag, Way, WayTag class OSM: def __init__(self, _osmContent): self.osmContent = str(_osmContent) self.nodeList = [] self.nodeTagList = [] + self.wayList = [] + self.wayTagList = [] self.parseOsmContent() def parseOsmContent(self): lines = self.osmContent.split("\n") nodeLines = [] + wayLines = [] for line in lines: if " 0: nodeLines.append(line) + elif "" in line: + try: + self.createWay(wayLines) + except: + print("Way could not be inserted") + wayLines = [] + elif len(wayLines) > 0: + wayLines.append(line) + + def createWay(self, lines): + wayId = "" + + for line in lines: + if "