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
40745962
Commit
40745962
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: some progress, one more row split sort of
parent
c4b0dadf
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
+23
-8
23 additions, 8 deletions
server/map/get_relation.py
with
23 additions
and
8 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
+
0
−
0
View file @
40745962
No preview for this file type
This diff is collapsed.
Click to expand it.
server/map/get_relation.py
+
23
−
8
View file @
40745962
...
...
@@ -157,7 +157,7 @@ def create_grid_coords(polygon: Polygon, cell_size: float):
# NB: only for testing
def
circle_polygon
():
circle_points
=
[]
num_points
=
2
00
num_points
=
5
00
center_x
,
center_y
=
0.0
,
0.0
radius
=
6
...
...
@@ -174,28 +174,43 @@ def circle_polygon():
# Adds equally spaced points along an edge that is created after a polygon is cut.
def
populate_new_edge
(
split_shape
,
remaining_shape
,
cell_size
:
float
,
divisor
:
float
):
# Prepend new points onto the newly created edge to facilitate vertical splitting
if
len
(
split_shape
)
>
2
and
polygon_min_x
is
not
None
:
if
split_shape
is
not
None
and
polygon_min_x
is
not
None
:
# Define starting point with an x-value that will be common for all polygons
starting_point
=
polygon_min_x
# Get corners of the newly created shape which make up the new edge
right_corner
=
split_shape
[
-
1
]
left_
corner
=
split_shape
[
0
]
print
(
"
Hit main if
"
)
# Create list of corners
corner
s
=
[
]
print
(
"
right_corner:
"
,
right_corner
,
"
left_corner:
"
,
left_corner
,
"
cell_size:
"
,
cell_size
)
divisor_range
=
((
divisor
-
0.01
),(
divisor
+
0.01
)
)
while
starting_point
<
left_corner
.
x
:
# Increment starting point until it is withing the polygons bounds
# Find all corners of split shape. Corner = point that intersects divisor
for
point
in
split_shape
:
if
divisor_range
[
0
]
<
point
.
y
<
divisor_range
[
1
]:
corners
.
append
(
point
)
print
(
"
Hit point in split_shape
"
)
if
not
corners
or
len
(
corners
)
<
2
:
print
(
"
no corners :(
"
)
return
None
# Sort corners in ascending order (left to right) based on x coordinate
sorted_corners
=
sorted
(
corners
,
key
=
lambda
p
:
p
.
x
)
while
starting_point
<
sorted_corners
[
0
].
x
:
# Increment starting point until it is withing the polygons bounds
starting_point
+=
cell_size
# if starting_point < left_corner.x: # NB: optimised substitute for previous while loop, requires testing
# starting_point += cell_size * math.floor(starting_point - left_corner.x)
# Insert new points with cell_size spacing while starting_point is within bounds
while
starting_point
<
right
_corner
.
x
:
while
starting_point
<
sorted
_corner
s
[
-
1
]
.
x
:
split_shape
.
insert
(
0
,
(
starting_point
,
divisor
))
# NB may have to add/subtract small offset of 0.00001
remaining_shape
.
insert
(
0
,
(
starting_point
,
divisor
))
# Prepend new point to shape
print
(
"
Hit point insertion
"
)
starting_point
+=
cell_size
return
split_shape
,
remaining_shape
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