Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
u4py
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rudolf, Michael
u4py
Commits
3f56dc18
Commit
3f56dc18
authored
1 month ago
by
Rudolf, Michael
Browse files
Options
Downloads
Patches
Plain Diff
Updated to match specifications by HLNUG
parent
29935f79
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
u4py/io/docx_report.py
+88
-30
88 additions, 30 deletions
u4py/io/docx_report.py
with
88 additions
and
30 deletions
u4py/io/docx_report.py
+
88
−
30
View file @
3f56dc18
...
@@ -5,6 +5,7 @@ requirements of the HLNUG.
...
@@ -5,6 +5,7 @@ requirements of the HLNUG.
import
os
import
os
import
numpy
as
np
import
docx
import
docx
import
docx.parts
import
docx.parts
import
docx.shared
import
docx.shared
...
@@ -67,7 +68,7 @@ def site_report(
...
@@ -67,7 +68,7 @@ def site_report(
section
.
footer_distance
=
docx
.
shared
.
Mm
(
12.7
)
section
.
footer_distance
=
docx
.
shared
.
Mm
(
12.7
)
# Start filling the Document
# Start filling the Document
document
.
add_heading
(
f
"
Beschreibung für Nr.
{
group
}
"
,
level
=
0
)
document
.
add_heading
(
f
"
Beschreibung für
Amt-
Nr.
{
group
}
"
,
level
=
0
)
# Add header
# Add header
heading
=
"
,
"
.
join
(
row
[
1
].
locations
.
split
(
"
,
"
)[:
-
4
])
heading
=
"
,
"
.
join
(
row
[
1
].
locations
.
split
(
"
,
"
)[:
-
4
])
...
@@ -86,7 +87,7 @@ def site_report(
...
@@ -86,7 +87,7 @@ def site_report(
document
,
document
,
web_query_path
,
web_query_path
,
)
)
document
=
landuse
(
row
[
1
],
document
)
#
document = landuse(row[1], document)
# Volumina
# Volumina
document
=
moved_volumes
(
row
[
1
],
document
)
document
=
moved_volumes
(
row
[
1
],
document
)
...
@@ -198,11 +199,14 @@ def hlnug_description(
...
@@ -198,11 +199,14 @@ def hlnug_description(
)
)
# Add number and name of geological map
# Add number and name of geological map
if
isinstance
(
row
[
"
geology_mapnum
"
],
list
):
mapnum
=
eval
(
row
[
"
geology_mapnum
"
])
if
mapnum
:
if
isinstance
(
mapnum
,
list
):
mapname
=
eval
(
row
[
"
geology_mapname
"
])
map_list
=
[
map_list
=
[
f
"
{
mpnum
}
{
mpname
}
"
f
"
{
mpnum
}
{
mpname
}
"
for
mpnum
,
mpname
in
zip
(
for
mpnum
,
mpname
in
zip
(
row
[
"
geology_mapnum
"
],
row
[
"
geology_
mapname
"
]
mapnum
,
mapname
)
)
]
]
mapnum_string
=
u4human
.
listed_strings
(
map_list
)
mapnum_string
=
u4human
.
listed_strings
(
map_list
)
...
@@ -211,6 +215,8 @@ def hlnug_description(
...
@@ -211,6 +215,8 @@ def hlnug_description(
prgph
.
add_run
(
prgph
.
add_run
(
f
"
auf dem Kartenblatt
{
row
[
'
geology_mapnum
'
]
}
{
row
[
'
geology_mapname
'
]
}
.
"
f
"
auf dem Kartenblatt
{
row
[
'
geology_mapnum
'
]
}
{
row
[
'
geology_mapname
'
]
}
.
"
)
)
else
:
prgph
.
add_run
(
"
.
"
)
# Add dimensions
# Add dimensions
prgph
.
add_run
(
prgph
.
add_run
(
...
@@ -241,7 +247,7 @@ def hlnug_description(
...
@@ -241,7 +247,7 @@ def hlnug_description(
if
isinstance
(
motorway_lengths
,
list
):
if
isinstance
(
motorway_lengths
,
list
):
for
rname
,
rlen
in
zip
(
motorway_names
,
motorway_lengths
):
for
rname
,
rlen
in
zip
(
motorway_names
,
motorway_lengths
):
road_list
.
append
(
road_list
.
append
(
f
"
der
{
rname
}
auf einer Länge von
{
rlen
:
.
1
f
}
\u00a0
m
"
f
"
der
{
rname
}
auf einer Länge von
{
int
(
rlen
)
}
\u00a0
m
"
)
)
else
:
else
:
road_list
.
append
(
road_list
.
append
(
...
@@ -256,7 +262,7 @@ def hlnug_description(
...
@@ -256,7 +262,7 @@ def hlnug_description(
if
isinstance
(
primary_lengths
,
list
):
if
isinstance
(
primary_lengths
,
list
):
for
rname
,
rlen
in
zip
(
primary_names
,
primary_lengths
):
for
rname
,
rlen
in
zip
(
primary_names
,
primary_lengths
):
road_list
.
append
(
road_list
.
append
(
f
"
der
{
rname
}
auf einer Länge von
{
rlen
:
.
1
f
}
\u00a0
m
"
f
"
der
{
rname
}
auf einer Länge von
{
int
(
rlen
)
}
\u00a0
m
"
)
)
else
:
else
:
road_list
.
append
(
road_list
.
append
(
...
@@ -271,7 +277,7 @@ def hlnug_description(
...
@@ -271,7 +277,7 @@ def hlnug_description(
if
isinstance
(
secondary_lengths
,
list
):
if
isinstance
(
secondary_lengths
,
list
):
for
rname
,
rlen
in
zip
(
secondary_names
,
secondary_lengths
):
for
rname
,
rlen
in
zip
(
secondary_names
,
secondary_lengths
):
road_list
.
append
(
road_list
.
append
(
f
"
der
{
rname
}
auf einer Länge von
{
rlen
:
.
1
f
}
\u00a0
m
"
f
"
der
{
rname
}
auf einer Länge von
{
int
(
rlen
)
}
\u00a0
m
"
)
)
else
:
else
:
road_list
.
append
(
road_list
.
append
(
...
@@ -281,6 +287,41 @@ def hlnug_description(
...
@@ -281,6 +287,41 @@ def hlnug_description(
f
"
Die Rutschung wird von
{
u4human
.
listed_strings
(
road_list
)
}
durchkreuzt.
"
f
"
Die Rutschung wird von
{
u4human
.
listed_strings
(
road_list
)
}
durchkreuzt.
"
)
)
else
:
if
row
[
"
roads_nearest_motorway_name
"
]:
prgph
.
add_run
(
f
"
In ca.
{
int
(
row
[
'
roads_nearest_motorway_dist
'
])
}
\u00a0
m
"
+
"
Entfernung vom Mittelpunkt der Rutschung befindet sich die
"
+
f
"
{
row
[
'
roads_nearest_motorway_name
'
]
}
.
"
)
elif
row
[
"
roads_nearest_primary_name
"
]:
prgph
.
add_run
(
f
"
In ca.
{
int
(
row
[
'
roads_nearest_primary_dist
'
])
}
\u00a0
m
"
+
"
Entfernung vom Mittelpunkt der Rutschung befindet sich die
"
+
f
"
{
row
[
'
roads_nearest_primary_name
'
]
}
.
"
)
elif
row
[
"
roads_nearest_secondary_dist
"
]
>
0
:
prgph
.
add_run
(
f
"
In ca.
{
int
(
row
[
'
roads_nearest_secondary_dist
'
])
}
\u00a0
m
"
+
"
Entfernung vom Mittelpunkt der Rutschung befindet sich
"
)
if
row
[
"
roads_nearest_secondary_name
"
]:
prgph
.
add_run
(
f
"
die
{
row
[
'
roads_nearest_secondary_name
'
]
}
.
"
)
else
:
prgph
.
add_run
(
"
eine nicht benannte Landstraße.
"
)
else
:
prgph
.
add_run
(
"
Im Umkreis von 1
\u00a0
km sind keine größeren Straßen vorhanden.
"
)
if
row
[
"
railways_has
"
]:
prgph
.
add_run
(
"
Eine Bahnlinie durchquert das Gebiet auf
"
+
f
"
{
int
(
row
[
'
railways_length
'
])
}
\u00a0
m Länge.
"
)
elif
row
[
"
railways_close
"
]:
prgph
.
add_run
(
f
"
Eine Bahnlinie liegt ca.
{
int
(
row
[
'
railways_length
'
])
}
\u00a0
m
"
+
"
entfernt vom Mittelpunkt der Rutschung.
"
)
# Add drill sites
# Add drill sites
drill_path
=
os
.
path
.
join
(
drill_path
=
os
.
path
.
join
(
web_query_path
,
web_query_path
,
...
@@ -305,8 +346,6 @@ def landuse(series: gp.GeoSeries, document: Document) -> Document:
...
@@ -305,8 +346,6 @@ def landuse(series: gp.GeoSeries, document: Document) -> Document:
:return: The tex code.
:return: The tex code.
:rtype: str
:rtype: str
"""
"""
prgph
=
document
.
add_paragraph
()
prgph
.
add_run
(
"
Landnutzung:
"
).
bold
=
True
landuse
=
""
landuse
=
""
try
:
try
:
landuse
=
eval
(
series
.
landuse_names
)
landuse
=
eval
(
series
.
landuse_names
)
...
@@ -314,6 +353,8 @@ def landuse(series: gp.GeoSeries, document: Document) -> Document:
...
@@ -314,6 +353,8 @@ def landuse(series: gp.GeoSeries, document: Document) -> Document:
landuse
=
series
.
landuse_names
landuse
=
series
.
landuse_names
landuse_perc
=
eval
(
series
.
landuse_percent
)
landuse_perc
=
eval
(
series
.
landuse_percent
)
if
landuse
:
if
landuse
:
prgph
=
document
.
add_paragraph
()
prgph
.
add_run
(
"
Landnutzung:
"
).
bold
=
True
prgph
.
add_run
(
prgph
.
add_run
(
"
Der überwiegende Teil wird durch
"
"
Der überwiegende Teil wird durch
"
+
f
"
{
u4human
.
landuse_str
(
series
.
landuse_major
)
}
bedeckt.
"
+
f
"
{
u4human
.
landuse_str
(
series
.
landuse_major
)
}
bedeckt.
"
...
@@ -342,13 +383,30 @@ def moved_volumes(series: gp.GeoSeries, document: Document) -> Document:
...
@@ -342,13 +383,30 @@ def moved_volumes(series: gp.GeoSeries, document: Document) -> Document:
:rtype: str
:rtype: str
"""
"""
document
.
add_heading
(
"
Höhenveränderungen
"
,
level
=
1
)
document
.
add_heading
(
"
Höhenveränderungen
"
,
level
=
1
)
if
np
.
all
(
np
.
abs
(
[
series
.
volumes_moved
,
series
.
volumes_added
,
series
.
volumes_removed
,
series
.
volumes_total
,
]
)
<=
200
):
document
.
add_paragraph
(
"
Im Gebiet um die detektierte Anomalie wurde laut vorliegendem
"
+
"
Differenzenplan (HVBG) keine Bewegung festgestellt.
"
)
else
:
document
.
add_paragraph
(
document
.
add_paragraph
(
"
Im Gebiet um die detektierte Anomalie wurde laut vorliegendem
"
"
Im Gebiet um die detektierte Anomalie wurde laut vorliegendem
"
+
"
Differenzenplan (HVBG) insgesamt
"
+
"
Differenzenplan (HVBG) insgesamt
"
+
f
"
{
series
.
volumes_moved
}
\u00a0
m³ Material bewegt,
"
+
f
"
{
series
.
volumes_moved
}
\u00a0
m³ Material bewegt,
"
+
f
"
wovon
{
series
.
volumes_added
}
\u00a0
m³ hinzugefügt und
"
+
f
"
wovon
{
series
.
volumes_added
}
\u00a0
m³ hinzugefügt und
"
+
f
"
{
abs
(
series
.
volumes_removed
)
}
\u00a0
m³ abgetragen wurde.
"
+
f
"
{
abs
(
series
.
volumes_removed
)
}
\u00a0
m³ abgetragen wurde.
"
+
f
"
Dies ergibt eine Gesamtbilanz von
{
series
.
volumes_total
}
\u00a0
m³,
"
+
f
"
Dies ergibt eine Gesamtbilanz von
{
series
.
volumes_total
}
"
+
f
"
\u00b1
{
series
.
volumes_error
}
\u00a0
m³,
"
+
f
"
in Summe wurde also
{
u4human
.
vol_str
(
series
.
volumes_total
)
}
.
"
+
f
"
in Summe wurde also
{
u4human
.
vol_str
(
series
.
volumes_total
)
}
.
"
)
)
return
document
return
document
...
@@ -547,7 +605,7 @@ def geology(
...
@@ -547,7 +605,7 @@ def geology(
prgph
.
alignment
=
WD_ALIGN_PARAGRAPH
.
CENTER
prgph
.
alignment
=
WD_ALIGN_PARAGRAPH
.
CENTER
run
=
prgph
.
add_run
()
run
=
prgph
.
add_run
()
run
.
add_picture
(
run
.
add_picture
(
img_path
+
f
"
_GK25_leg.
{
img_fmt
}
"
,
width
=
docx
.
shared
.
Mm
(
7
0
)
img_path
+
f
"
_GK25_leg.
{
img_fmt
}
"
,
width
=
docx
.
shared
.
Mm
(
10
0
)
)
)
prgph
=
document
.
add_paragraph
()
prgph
=
document
.
add_paragraph
()
...
@@ -585,7 +643,7 @@ def hydrogeology(
...
@@ -585,7 +643,7 @@ def hydrogeology(
prgph
.
alignment
=
WD_ALIGN_PARAGRAPH
.
CENTER
prgph
.
alignment
=
WD_ALIGN_PARAGRAPH
.
CENTER
run
=
prgph
.
add_run
()
run
=
prgph
.
add_run
()
run
.
add_picture
(
run
.
add_picture
(
img_path
+
f
"
_HUEK200_leg.
{
img_fmt
}
"
,
width
=
docx
.
shared
.
Mm
(
7
0
)
img_path
+
f
"
_HUEK200_leg.
{
img_fmt
}
"
,
width
=
docx
.
shared
.
Mm
(
10
0
)
)
)
prgph
=
document
.
add_paragraph
()
prgph
=
document
.
add_paragraph
()
...
@@ -621,7 +679,7 @@ def soils(img_path: os.PathLike, img_fmt: str, document: Document) -> Document:
...
@@ -621,7 +679,7 @@ def soils(img_path: os.PathLike, img_fmt: str, document: Document) -> Document:
prgph
.
alignment
=
WD_ALIGN_PARAGRAPH
.
CENTER
prgph
.
alignment
=
WD_ALIGN_PARAGRAPH
.
CENTER
run
=
prgph
.
add_run
()
run
=
prgph
.
add_run
()
run
.
add_picture
(
run
.
add_picture
(
img_path
+
f
"
_BFD50_leg.
{
img_fmt
}
"
,
width
=
docx
.
shared
.
Mm
(
7
0
)
img_path
+
f
"
_BFD50_leg.
{
img_fmt
}
"
,
width
=
docx
.
shared
.
Mm
(
10
0
)
)
)
prgph
=
document
.
add_paragraph
()
prgph
=
document
.
add_paragraph
()
...
...
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