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
a023e1af
Commit
a023e1af
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: tile center calculation
parent
c85dfbde
No related branches found
Branches containing commit
No related tags found
2 merge requests
!9
Clhp map
,
!8
Clhp map
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/map/get_relation.py
+6
-5
6 additions, 5 deletions
server/map/get_relation.py
with
6 additions
and
5 deletions
server/map/get_relation.py
+
6
−
5
View file @
a023e1af
...
...
@@ -53,8 +53,11 @@ def cut_map(self, body_of_water: str): # NB: implement body_of_water
sub_div_id
=
0
for
tile
in
divided_map
:
# NB temporarily limited to 5 tiles
# Round coordinates to 4 decimals
center
=
round
(
tile
.
centroid
.
coords
[
0
][
0
],
4
),
round
(
tile
.
centroid
.
coords
[
0
][
1
],
4
)
# Calculate tile center based on bounds, and round down to two decimals
min_x
,
min_y
,
max_x
,
max_y
=
tile
.
bounds
center
=
round
(
max_x
-
min_x
,
4
),
round
(
max_y
-
min_y
,
4
)
# center = round(tile.centroid.coords[0][0], 4), round(tile.centroid.coords[0][1], 4)
rounded_coordinates
=
[]
if
isinstance
(
tile
,
Polygon
):
for
coords
in
tile
.
exterior
.
coords
:
...
...
@@ -135,9 +138,7 @@ def write_json_to_file(path: str, file_name: str, json_data: dict):
json
.
dump
(
json_data
,
f
)
'''
def
get_divided_map
(
file_name
):
geo_data = gpd.read_file(
"
server/map/
mjosa
.geojson
"
)
geo_data
=
gpd
.
read_file
(
"
server/map/
"
+
file_name
+
"
.geojson
"
)
polygon_data
=
geo_data
[
geo_data
[
'
geometry
'
].
geom_type
==
'
Polygon
'
]
polygons
=
[
Polygon
(
polygon
.
exterior
)
for
polygon
in
polygon_data
[
'
geometry
'
]]
'''
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