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
598f8dd0
Commit
598f8dd0
authored
8 months ago
by
Maximilian Loch
Browse files
Options
Downloads
Patches
Plain Diff
small name change
parent
e57a76ce
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
areg_linker_script.py
+75
-75
75 additions, 75 deletions
areg_linker_script.py
with
75 additions
and
75 deletions
geocod
er_script.py
→
areg_link
er_script.py
+
75
−
75
View file @
598f8dd0
# script zum
geocod
en der schulen und zuweisen der URI aus dem AREG
from
script_helper
import
DBTools
,
APITools
from
configparser
import
ConfigParser
if
__name__
==
'
__main__
'
:
print
(
"
geocoding dataset now
"
)
# datenbank mit den schuldaten
conn_config
=
ConfigParser
()
conn_config
.
read
(
"
db_conn.cfg
"
)
conn_str
=
f
"""
host=
{
conn_config
[
'
connection
'
][
'
host
'
]
}
port=
{
conn_config
[
'
connection
'
][
'
port
'
]
}
dbname=
{
conn_config
[
'
connection
'
][
'
dbname
'
]
}
user=
{
conn_config
[
'
connection
'
][
'
user
'
]
}
password=
{
conn_config
[
'
connection
'
][
'
pwd
'
]
}
"""
table
=
conn_config
[
'
connection
'
][
'
table
'
]
url
=
conn_config
[
'
connection
'
][
'
url
'
]
# logfile = r"geocoder.log"
my_db
=
DBTools
(
conn_str
)
my_api
=
APITools
(
url
)
schulen
=
my_db
.
select_adress
(
table
)
adresse
=
{}
maxfeatures
=
len
(
schulen
)
numfeatures
=
0
errorfeatures
=
0
missinfeatures
=
0
log
=
[]
for
item
in
schulen
:
adresse
[
"
hnr
"
]
=
item
[
1
]
adresse
[
"
stn
"
]
=
item
[
2
]
adresse
[
"
plz
"
]
=
item
[
3
]
adresse
[
"
ort
"
]
=
item
[
4
]
areg_response
=
my_api
.
geocode
(
adresse
)
if
areg_response
.
get
(
"
uri
"
)
is
not
None
:
areg_uri
=
areg_response
[
"
uri
"
]
my_db
.
update_uri
(
str
(
item
[
0
]),
areg_uri
,
table
)
numfeatures
+=
1
else
:
areg_response_key
=
list
(
areg_response
.
keys
())
if
areg_response_key
[
0
]
==
"
MISSING
"
:
missinfeatures
+=
1
if
areg_response_key
[
0
]
==
"
ERROR
"
:
errorfeatures
+=
1
progress_msg
=
(
f
"
{
areg_response_key
[
0
]
}
:
"
+
f
"
{
areg_response
[
areg_response_key
[
0
]]
}
|
"
+
f
"
betroffene schule: [
{
item
[
0
]
}
]
\t
{
adresse
[
'
hnr
'
]
}
;
"
+
# noqa
f
"
{
adresse
[
'
stn
'
]
}
;
{
adresse
[
'
plz
'
]
}
;
"
+
f
"
{
adresse
[
'
ort
'
]
}
"
)
print
(
progress_msg
)
my_db
.
closecursor
()
# sorgt auf dem cloudserver fuer fehler wegen permission
# with open(logfile, "w", encoding='utf-8') as out:
# for item in log:
# out.write(item)
percentage
=
round
((
numfeatures
*
100
)
/
maxfeatures
,
2
)
statistics
=
(
f
"
statistics:
\n
{
numfeatures
}
from
{
maxfeatures
}
geocod
ed
"
+
f
"
>>
{
percentage
}
%
\n
{
missinfeatures
}
features with
"
+
f
"
missing attributes
\n
{
errorfeatures
}
features with
"
+
f
"
errors
\n
"
)
print
(
statistics
)
print
(
"
geocod
ing dataset finished, closing programm
"
)
# script zum
verlink
en der schulen und zuweisen der URI aus dem AREG
from
script_helper
import
DBTools
,
APITools
from
configparser
import
ConfigParser
if
__name__
==
'
__main__
'
:
print
(
"
geocoding dataset now
"
)
# datenbank mit den schuldaten
conn_config
=
ConfigParser
()
conn_config
.
read
(
"
db_conn.cfg
"
)
conn_str
=
f
"""
host=
{
conn_config
[
'
connection
'
][
'
host
'
]
}
port=
{
conn_config
[
'
connection
'
][
'
port
'
]
}
dbname=
{
conn_config
[
'
connection
'
][
'
dbname
'
]
}
user=
{
conn_config
[
'
connection
'
][
'
user
'
]
}
password=
{
conn_config
[
'
connection
'
][
'
pwd
'
]
}
"""
table
=
conn_config
[
'
connection
'
][
'
table
'
]
url
=
conn_config
[
'
connection
'
][
'
url
'
]
# logfile = r"geocoder.log"
my_db
=
DBTools
(
conn_str
)
my_api
=
APITools
(
url
)
schulen
=
my_db
.
select_adress
(
table
)
adresse
=
{}
maxfeatures
=
len
(
schulen
)
numfeatures
=
0
errorfeatures
=
0
missinfeatures
=
0
log
=
[]
for
item
in
schulen
:
adresse
[
"
hnr
"
]
=
item
[
1
]
adresse
[
"
stn
"
]
=
item
[
2
]
adresse
[
"
plz
"
]
=
item
[
3
]
adresse
[
"
ort
"
]
=
item
[
4
]
areg_response
=
my_api
.
geocode
(
adresse
)
if
areg_response
.
get
(
"
uri
"
)
is
not
None
:
areg_uri
=
areg_response
[
"
uri
"
]
my_db
.
update_uri
(
str
(
item
[
0
]),
areg_uri
,
table
)
numfeatures
+=
1
else
:
areg_response_key
=
list
(
areg_response
.
keys
())
if
areg_response_key
[
0
]
==
"
MISSING
"
:
missinfeatures
+=
1
if
areg_response_key
[
0
]
==
"
ERROR
"
:
errorfeatures
+=
1
progress_msg
=
(
f
"
{
areg_response_key
[
0
]
}
:
"
+
f
"
{
areg_response
[
areg_response_key
[
0
]]
}
|
"
+
f
"
betroffene schule: [
{
item
[
0
]
}
]
\t
{
adresse
[
'
hnr
'
]
}
;
"
+
# noqa
f
"
{
adresse
[
'
stn
'
]
}
;
{
adresse
[
'
plz
'
]
}
;
"
+
f
"
{
adresse
[
'
ort
'
]
}
"
)
print
(
progress_msg
)
my_db
.
closecursor
()
# sorgt auf dem cloudserver fuer fehler wegen permission
# with open(logfile, "w", encoding='utf-8') as out:
# for item in log:
# out.write(item)
percentage
=
round
((
numfeatures
*
100
)
/
maxfeatures
,
2
)
statistics
=
(
f
"
statistics:
\n
{
numfeatures
}
from
{
maxfeatures
}
link
ed
"
+
f
"
>>
{
percentage
}
%
\n
{
missinfeatures
}
features with
"
+
f
"
missing attributes
\n
{
errorfeatures
}
features with
"
+
f
"
errors
\n
"
)
print
(
statistics
)
print
(
"
link
ing dataset finished, closing programm
"
)
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