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
1bc72c15
Commit
1bc72c15
authored
1 year ago
by
Hoa Ben The Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
fix: calculation
parent
19c84eaf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/data_processing/area_processing.py
+16
-11
16 additions, 11 deletions
server/data_processing/area_processing.py
with
16 additions
and
11 deletions
server/data_processing/area_processing.py
+
16
−
11
View file @
1bc72c15
...
@@ -30,31 +30,36 @@ def calculate_corners(lat, lng, area_offset):
...
@@ -30,31 +30,36 @@ def calculate_corners(lat, lng, area_offset):
(60.7966, 10.7405)]
'''
(60.7966, 10.7405)]
'''
# separate the zones into smaller area, into a grid
# separate the zones into smaller area, into a grid
def
define_gridareas
(
lat
,
lng
,
area_offset
,
grid_size
,
dimension
,
subId
,
groupId
):
def
define_gridareas
(
lat
,
lng
,
area_offset
,
grid_size
):
a
=
dimension
+
subId
+
groupId
#
soon to be implemented
#
a = dimension + subId + groupId soon to be implemented
print
(
a
)
#
print(a)
grided_area
=
[]
# container for an area turned into a grid of areas
grided_area
=
[]
# container for an area turned into a grid of areas
# find the main area's corner positions
# find the main area's corner positions
main_area
=
calculate_corners
(
lat
,
lng
,
area_offset
)
main_area
=
calculate_corners
(
lat
,
lng
,
area_offset
)
# find the main area's range size
# find the main area's range size
area_size
=
(
main_area
[
0
][
0
]
-
main_area
[
2
][
0
],
main_area
[
0
][
1
]
-
main_area
[
2
][
1
])
area_size
=
(
main_area
[
2
][
0
]
-
main_area
[
0
][
0
],
main_area
[
0
][
1
]
-
main_area
[
2
][
1
])
# find each subareas vector to it's center
# find each subareas vector to it's center
dist_to_subcenter
=
(
area_size
[
0
]
/
(
grid_size
*
2
),
area_size
[
1
]
/
(
grid_size
*
2
))
dist_to_subcenter
=
(
area_size
[
0
]
/
(
grid_size
*
2
),
area_size
[
1
]
/
(
grid_size
*
2
))
print
(
dist_to_subcenter
)
# find subareas size relative to main area
# find subareas size relative to main area
subarea_offset
=
area_offset
/
grid_size
subarea_offset
=
area_offset
/
grid_size
print
(
main_area
)
# find the center coordinates of each area in grid to find the corner areas
# find the center coordinates of each area in grid to find the corner areas
for
y
in
range
(
grid_size
-
1
):
for
y
in
(
range
(
grid_size
)
):
relative_size_lng
=
y
/
grid_size
relative_size_lng
=
y
/
grid_size
for
x
in
range
(
grid_size
-
1
):
for
x
in
(
range
(
grid_size
)
):
relative_size_lat
=
x
/
grid_size
relative_size_lat
=
x
/
grid_size
lat_pos
=
main_area
[
0
][
0
]
+
relative_size_lat
*
area_size
[
0
]
-
dist_to_subcenter
[
0
]
lat_pos
=
main_area
[
3
][
0
]
+
relative_size_lat
*
area_size
[
0
]
+
dist_to_subcenter
[
0
]
lng_pos
=
main_area
[
0
][
1
]
+
relative_size_lng
*
area_size
[
1
]
-
dist_to_subcenter
[
1
]
lng_pos
=
main_area
[
3
][
1
]
+
relative_size_lng
*
area_size
[
1
]
+
dist_to_subcenter
[
1
]
# id of each subarea
sub_id
=
x
%
grid_size
+
grid_size
*
y
# use the center of sub areas to find the corner of each subarea
# use the center of sub areas to find the corner of each subarea
grided_area
.
append
(
calculate_corners
(
lat_pos
,
lng_pos
,
subarea_offset
))
corners
=
calculate_corners
(
lat_pos
,
lng_pos
,
subarea_offset
)
grided_area
.
append
((
sub_id
,
corners
))
return
grided_area
return
grided_area
#print(calculate_corners(60,10,1500))
print
(
define_gridareas
(
60
,
10
,
1500
,
4
))
#print(define_gridareas(60,10,1500,4))
\ No newline at end of file
\ No newline at end of file
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