Skip to content
Snippets Groups Projects
Commit b9844d5d authored by Maximilian Loch's avatar Maximilian Loch
Browse files

fixed adress query in findadresse()

parent 70185a18
Branches
No related tags found
No related merge requests found
......@@ -105,7 +105,6 @@ class DBTools:
"""
geometry = str(data['geometry'])
geometry = geometry.replace("'", '"')
adressdaten = data['properties']
sql_alter = """
alter table
......@@ -126,10 +125,10 @@ class DBTools:
update
prototyp_areg.schulen
set
hnr='{adressdaten['hnr']}',
strasse='{data['properties']['stn']}',
plz='{data['properties']['plz']}',
ort='{data['properties']['ort']}',
hnr='{data['hnr']}',
strasse='{data['stn']}',
plz='{data['plz']}',
ort='{data['ort']}',
geom=ST_GeomFromGeoJSON('{geometry}')
where
areg_uri='{param_uri}';
......@@ -201,7 +200,7 @@ class APITools:
return result
def findadresse(self, param_uri: str) -> "dict[dict[str, str], ... ]":
def findadresse(self, param_uri: str) -> "dict[str,str]":
"""
Funktion zum finden der Adresse im AREG anhand der vergebenen URI.
Antwort ist in Form eines Dictionaries. Die eigentrlichen Adress-
......@@ -214,6 +213,14 @@ class APITools:
:rtype: dict
"""
url = param_uri + r"?f=json"
result = {}
response = requests.get(url)
response_json = response.json()
return response_json
result['hnr'] = response_json['properties']['hnr']
result['stn'] = response_json['properties']['stn']
result['plz'] = response_json['properties']['plz']
result['ort'] = response_json['properties']['ort']
result['geometry'] = response_json['geometry']
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment