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
966cfcf1
Commit
966cfcf1
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: minor progress
parent
4e580b52
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
+10
-6
10 additions, 6 deletions
server/map/get_relation.py
with
10 additions
and
6 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
+
0
−
0
View file @
966cfcf1
No preview for this file type
This diff is collapsed.
Click to expand it.
server/map/get_relation.py
+
10
−
6
View file @
966cfcf1
...
...
@@ -30,8 +30,8 @@ def get_relation(self, body_of_water: str):
# Divide the length and with of polygon into a grid
grid_lines
=
create_grid_coords
(
polygon
,
cell_size
=
0.1
)
hrz_lines
=
[
60.7
451
]
# Horizontal coordinates
vrt_lines
=
[
10.
9600
]
# Vertical coordinates
hrz_lines
=
[
60.7
530
]
# Horizontal coordinates
vrt_lines
=
[
10.
8572
]
# Vertical coordinates
# Cut polygon into horizontal sections
for
hrz_line
in
hrz_lines
:
...
...
@@ -47,9 +47,6 @@ def get_relation(self, body_of_water: str):
for
vrt_line
in
vrt_lines
:
cut_poly_2
=
cut_polygon_in_two
(
polygon_part
,
vrt_line
,
False
)
if
not
cut_poly_2
[
0
]:
continue
divided_map
.
append
(
cut_poly_2
[
0
])
# Append part to final list of shapes
# Set polygon_part to the remaining, un-split, horizontal section for next iteration
...
...
@@ -57,6 +54,9 @@ def get_relation(self, body_of_water: str):
polygon
=
cut_poly_1
[
1
]
# Set polygon to the remaining, un-split shape for next iteration
# Append last remainder
divided_map
.
append
(
polygon
)
tiles
=
gpd
.
GeoDataFrame
(
geometry
=
divided_map
)
# NB: test plots
...
...
@@ -102,13 +102,14 @@ def cut_polygon_in_two(polygon: Polygon, divisor: float, horizontal: bool):
else
:
remaining_shape
.
append
(
point
)
# Check if
polygons have enough coordinates
# Check if
the split_shape has enough coordinates to create a polygon
if
len
(
split_shape
)
<
3
:
print
(
"
Not enough coordinates to create valid polygons: Split shape
"
)
split_shape
=
None
else
:
split_shape
.
append
(
split_shape
[
0
])
# NB: may not be necessary?
# Check if the remaining_shape has enough coordinates to create a polygon
if
len
(
remaining_shape
)
<
3
:
print
(
"
Not enough coordinates to create valid polygons: Remaining shape
"
)
remaining_shape
=
None
...
...
@@ -121,7 +122,10 @@ def cut_polygon_in_two(polygon: Polygon, divisor: float, horizontal: bool):
# Generate grid of equally spaced x and y coordinates where the grid size is determined by cell_size
def
create_grid_coords
(
polygon
:
Polygon
,
cell_size
:
float
):
# Define boundaries of grid
min_x
,
min_y
,
max_x
,
max_y
=
polygon
.
bounds
# Divide grid into sections of size *cell_size
x_coords
=
np
.
arange
(
min_x
,
max_x
,
cell_size
)
y_coords
=
np
.
arange
(
min_y
,
max_y
,
cell_size
)
...
...
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