Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
8e591cfd
Commit
8e591cfd
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: add break from splitting horizontal sections
parent
1aec7901
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Clhp map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/map/__pycache__/get_relation.cpython-311.pyc
+0
-0
0 additions, 0 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
server/map/get_relation.py
+18
-13
18 additions, 13 deletions
server/map/get_relation.py
with
18 additions
and
13 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
+
0
−
0
View file @
8e591cfd
No preview for this file type
This diff is collapsed.
Click to expand it.
server/map/get_relation.py
+
18
−
13
View file @
8e591cfd
...
...
@@ -27,11 +27,12 @@ def get_relation(self, body_of_water: str):
# Divide all polygons into sections
for
polygon
in
polygons
:
# Divide the length and with of polygon into a grid
# Divide the length and with of polygon into a grid
of equally sized parts
grid_lines
=
create_grid_coords
(
polygon
,
cell_size
=
0.1
)
hrz_lines
=
grid_lines
[
1
]
# Horizontal coordinates
vrt_lines
=
grid_lines
[
0
]
# Vertical coordinates
vrt_lines
=
grid_lines
[
0
]
# Vertical grid coordinates
hrz_lines
=
grid_lines
[
1
]
# Horizontal grid coordinates
for
line
in
vrt_lines
:
print
(
"
Line:
"
,
line
)
...
...
@@ -39,22 +40,26 @@ def get_relation(self, body_of_water: str):
for
hrz_line
in
hrz_lines
:
# Split shape into upper and lower section as hrz_line as divider
cut
_poly
_1
=
cut_polygon_in_two
(
polygon
,
hrz_line
,
True
)
polygon_part
=
cut
_poly
_1
[
0
]
# Save upper horizontal section
divided
_poly
=
cut_polygon_in_two
(
polygon
,
hrz_line
,
True
)
horizontal_section
=
divided
_poly
[
0
]
# Save upper horizontal section
if
not
polygon_part
or
not
cut
_poly
_1
[
0
]:
if
not
horizontal_section
or
not
divided
_poly
[
0
]:
continue
# Cut each horizontal section into vertical sections, right to left
# Cut each horizontal section into vertical sections, right to left
for
vrt_line
in
vrt_lines
:
cut_poly_2
=
cut_polygon_in_two
(
polygon_part
,
vrt_line
,
False
)
if
len
(
horizontal_section
.
exterior
.
coords
)
<
3
:
break
# Break from loop im remaining section has no coordinates
# Split the horizontal section into two vertical parts
vertical_parts
=
cut_polygon_in_two
(
horizontal_section
,
vrt_line
,
False
)
divided_map
.
append
(
cut_poly_2
[
0
])
# Append
part
to final list of shapes
divided_map
.
append
(
vertical_parts
[
0
])
# Append
split vertical sections
to final list of shapes
# Set
polygon_part
to the remaining, un-split, horizontal section for next iteration
polygon_part
=
cut_poly_2
[
1
]
# Set
horizontal_section
to the remaining, un-split, horizontal section for next iteration
horizontal_section
=
vertical_parts
[
1
]
polygon
=
cut
_poly
_1
[
1
]
# Set polygon to the remaining, un-split shape for next iteration
polygon
=
divided
_poly
[
1
]
# Set polygon to the remaining, un-split shape for next iteration
divided_map
.
append
(
polygon
)
...
...
@@ -72,7 +77,7 @@ def get_relation(self, body_of_water: str):
x
,
y
=
polygon
.
exterior
.
xy
ax
.
plot
(
x
,
y
,
color
=
'
blue
'
,
alpha
=
0.5
)
ax
.
fill
(
x
,
y
,
color
=
random_color
,
alpha
=
0.5
)
ax
.
fill
(
x
,
y
,
color
=
random_color
,
alpha
=
1
)
plt
.
show
()
...
...
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