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
592f0b73
Commit
592f0b73
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: more minor progress, still no proper split
parent
f822034a
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
+8
-6
8 additions, 6 deletions
server/map/get_relation.py
with
8 additions
and
6 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
+
0
−
0
View file @
592f0b73
No preview for this file type
This diff is collapsed.
Click to expand it.
server/map/get_relation.py
+
8
−
6
View file @
592f0b73
...
...
@@ -105,23 +105,25 @@ def cut_polygon_in_two(polygon: Polygon, divisor: float, cell_size: float):
if
cell_size
>
0
:
# Horizontal split
for
point
in
exterior_coords
:
point
=
Point
(
point
)
# Convert coordinates to Shapely Point object
if
point
.
y
<
divisor
:
split_shape
.
append
(
point
)
if
point
.
y
<
divisor
:
# Check if point is over or below divisor
split_shape
.
append
(
point
)
# Append to appropriate shape
else
:
remaining_shape
.
append
(
point
)
if
len
(
split_shape
)
>
2
:
# Get last point added to
last_point
=
split_shape
[
len
(
split_shape
)
-
2
]
last_point
=
split_shape
[
-
1
]
# Get length of the newly created edge
new_edge_len
=
abs
(
last_point
.
x
-
split_shape
[
0
].
x
)
print
(
"
new_edge_len:
"
,
new_edge_len
,
"
cell_size:
"
,
cell_size
)
x_val
=
new_edge_len
-
cell_size
print
(
"
new_edge_len:
"
,
new_edge_len
,
"
cell_size:
"
,
cell_size
,
"
last_point.x:
"
,
last_point
.
x
,
"
split_shape[0].x:
"
,
split_shape
[
0
].
x
)
# Add points along the new edge to allow horizontal sections to be split into vertical ones
while
new_edge_len
>
cell_size
:
split_shape
.
insert
(
0
,
(
x_val
,
last_point
.
y
))
# NB may have to add/subtract small offset of 0.00001
x_val
=
new_edge_len
-
cell_size
split_shape
.
insert
(
0
,
(
x_val
,
last_point
.
y
))
# NB may have to add/subtract small offset of 0.00001
remaining_shape
.
insert
(
0
,
(
x_val
,
last_point
.
y
))
# Prepend
new_edge_len
-=
cell_size
else
:
# Vertical split
...
...
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