Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Adressen Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maximilian Loch
Adressen Integration
Commits
70185a18
Commit
70185a18
authored
2 years ago
by
Maximilian Loch
Browse files
Options
Downloads
Patches
Plain Diff
added type hints + small bugfixes
parent
72f4c478
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
script_helper.py
+15
-9
15 additions, 9 deletions
script_helper.py
with
15 additions
and
9 deletions
script_helper.py
+
15
−
9
View file @
70185a18
...
...
@@ -10,17 +10,17 @@ class DBTools:
Tools für das arbeiten mit der Datenbank, hier sind die select Funktionen
zum auslesen der Daten und zum updaten der Daten mit den Adressen.
"""
def
__init__
(
self
,
data
:
str
)
->
None
:
def
__init__
(
self
,
conn
:
str
)
->
None
:
"""
Aufbauen der Verbindung zu der Datenbank
:param str data: Connection String mit allen Informationen für die
Verbindung zur Datenbank
"""
self
.
db_connection
=
psycopg2
.
connect
(
data
)
self
.
db_connection
=
psycopg2
.
connect
(
conn
)
self
.
cursor
=
self
.
db_connection
.
cursor
()
def
select_adress
(
self
):
def
select_adress
(
self
)
->
"
list[tuple[str, ... ]]
"
:
"""
Funktion zum selektieren der Adressdaten der Schulen um diese zu
geocoden und ihnen URI aus dem AREG zuzuweisen.
...
...
@@ -44,7 +44,7 @@ class DBTools:
return
query_result
def
select_uri
(
self
):
def
select_uri
(
self
)
->
"
list[tuple[str,str]]
"
:
"""
Funktion zum selektieren der URI aus dem Datensatz um diese mit
aktuellen AREG Adressen anzureichern.
...
...
@@ -94,7 +94,7 @@ class DBTools:
self
.
cursor
.
execute
(
sql_alter
)
self
.
cursor
.
execute
(
sql_update
)
def
update_adress
(
self
,
data
,
param_uri
:
str
)
->
None
:
def
update_adress
(
self
,
data
:
"
dict[str,str]
"
,
param_uri
:
str
)
->
None
:
"""
Funktion zum Update der Datenbank mit den neuen Adressdaten aus dem
AREG anhand der URI.
...
...
@@ -105,6 +105,7 @@ class DBTools:
"""
geometry
=
str
(
data
[
'
geometry
'
])
geometry
=
geometry
.
replace
(
"'"
,
'"'
)
adressdaten
=
data
[
'
properties
'
]
sql_alter
=
"""
alter table
...
...
@@ -125,7 +126,7 @@ class DBTools:
update
prototyp_areg.schulen
set
hnr=
'
{
data
[
'
properties
'
]
[
'
hnr
'
]
}
'
,
hnr=
'
{
adressdaten
[
'
hnr
'
]
}
'
,
strasse=
'
{
data
[
'
properties
'
][
'
stn
'
]
}
'
,
plz=
'
{
data
[
'
properties
'
][
'
plz
'
]
}
'
,
ort=
'
{
data
[
'
properties
'
][
'
ort
'
]
}
'
,
...
...
@@ -162,7 +163,7 @@ class APITools:
"""
self
.
base_url
=
param_url
def
geocode
(
self
,
data
:
dict
)
->
dict
:
def
geocode
(
self
,
data
:
"
dict
[str,str]
"
)
->
"
dict
[str,str]
"
:
"""
Funktion zum Aufrufen des Geocoder Prozesses in der API. Bereinigung
finden nicht in dieser Funktion oder diesem Skript sondern im Geocoder
...
...
@@ -200,10 +201,15 @@ class APITools:
return
result
def
findadresse
(
self
,
param_uri
)
:
def
findadresse
(
self
,
param_uri
:
str
)
->
"
dict[dict[str, str], ... ]
"
:
"""
Funktion zum finden der Adresse im AREG anhand der vergebenen URI.
:param str param_uri: URI des Datensatzes
Antwort ist in Form eines Dictionaries. Die eigentrlichen Adress-
Attribute befinden sich im abschnitt `properties`.
:param str param_uri: URI des Datensatzes mit Link zur API.
:return: GeoJSON des jeweiligen Items das der URI entspricht
:rtype: dict
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment