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
84468543
Commit
84468543
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: split into horizontal sections from grid
parent
5e7028a9
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
+14
-5
14 additions, 5 deletions
server/map/get_relation.py
with
14 additions
and
5 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
+
0
−
0
View file @
84468543
No preview for this file type
This diff is collapsed.
Click to expand it.
server/map/get_relation.py
+
14
−
5
View file @
84468543
...
...
@@ -33,7 +33,10 @@ def get_relation(self, body_of_water: str):
#hrz_lines = grid_lines[0] # Horizontal coordinates
#vrt_lines = grid_lines[1] # Vertical coordinates
hrz_lines
=
[
60.7530
,
60.5931
]
# Horizontal coordinates
hrz_lines
=
grid_lines
[
1
]
# Horizontal coordinates
for
line
in
hrz_lines
:
print
(
"
line:
"
,
line
)
vrt_lines
=
[
11.0413
]
# Vertical coordinates
# Cut polygon into horizontal sections
...
...
@@ -49,6 +52,8 @@ def get_relation(self, body_of_water: str):
divided_map
.
append
(
polygon
)
break
tiles
=
gpd
.
GeoDataFrame
(
geometry
=
divided_map
)
# NB test plot
...
...
@@ -88,12 +93,12 @@ def cut_polygon_in_two(polygon: Polygon, divisor: float, horizontal: bool):
for
point
in
exterior_coords
:
point
=
Point
(
point
)
# Convert coordinates to Shapely Point object
if
horizontal
:
# Horizontal split
if
point
.
y
>
divisor
:
if
point
.
y
<
divisor
:
split_shape
.
append
(
point
)
else
:
remaining_shape
.
append
(
point
)
else
:
# Vertical split
if
point
.
x
>
divisor
:
if
point
.
x
<
divisor
:
split_shape
.
append
(
point
)
else
:
remaining_shape
.
append
(
point
)
...
...
@@ -125,8 +130,12 @@ def create_grid_coords(polygon: Polygon, cell_size: float):
x_coords
=
np
.
arange
(
min_x
,
max_x
,
cell_size
)
y_coords
=
np
.
arange
(
min_y
,
max_y
,
cell_size
)
if
len
(
x_coords
)
==
0
or
len
(
y_coords
)
==
0
:
# Round the coordinates to 4 decimals
x_coords_rounded
=
np
.
around
(
x_coords
,
decimals
=
4
)
y_coords_rounded
=
np
.
around
(
y_coords
,
decimals
=
4
)
if
len
(
x_coords_rounded
)
==
0
or
len
(
y_coords_rounded
)
==
0
:
raise
ValueError
(
"
No grid points generated
"
)
# Return tuple of list of x coordinates and list of y coordinates
return
x_coords
,
y_coords
return
x_coords
_rounded
,
y_coords
_rounded
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