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
720ed4d0
Commit
720ed4d0
authored
1 year ago
by
Hoa Ben The Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
change: adapt to json data
parent
fb490448
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/data_processing/process_lidar_data.py
+26
-5
26 additions, 5 deletions
server/data_processing/process_lidar_data.py
server/main.py
+1
-1
1 addition, 1 deletion
server/main.py
server/map/input_new_data.py
+3
-2
3 additions, 2 deletions
server/map/input_new_data.py
with
30 additions
and
8 deletions
server/data_processing/process_lidar_data.py
+
26
−
5
View file @
720ed4d0
import
numpy
as
np
import
laspy
import
json
import
utm
# src: https://github.com/Turbo87/utm
from
itertools
import
groupby
from
server.data_processing.area_processing
import
calculate_corners
,
define_gridareas
...
...
@@ -31,7 +32,7 @@ def about_laz_file():
# check if lidar points is within range of the area selected
def
inArea
(
position
,
areaRange
):
x
,
y
,
_
=
position
if
(
areaRange
[
0
][
0
]
>
x
>
areaRange
[
1
][
0
])
and
(
areaRange
[
0
][
1
]
<
y
<
areaRange
[
1
][
1
]):
if
(
areaRange
[
0
][
0
]
>
x
>
areaRange
[
1
][
0
])
and
(
abs
(
areaRange
[
0
][
1
]
)
>
abs
(
y
)
>
abs
(
areaRange
[
1
][
1
])
)
:
return
True
else
:
return
False
...
...
@@ -64,12 +65,31 @@ def find_height(points):
# find the height of an area based on the coordinates of it's center
# and it's affiliations (subId and groupId) (soon to be implemented
def
calculate_area_data
(
center
):
def
calculate_area_data
(
center
,
cell_size
,
body_of_water
):
# map application size to meters
cell_size_to_meters
=
cell_size
*
600000
# container for all the heights in area
area_heights
=
[]
# set the limit of the area compared to local coordinates
area_limit
=
calculate_corners
(
center
[
0
],
center
[
1
],
1500
)
area_limit
=
calculate_corners
(
center
[
0
],
center
[
1
],
cell_size_to_meters
)
# read json data with path to data for specific water body
file_name
=
"
server/lake_relations/
"
+
body_of_water
+
"
_div.json
"
with
open
(
file_name
)
as
data
:
map_data
=
json
.
load
(
data
)
map_data
=
map_data
[
'
features
'
]
print
(
map_data
[
0
][
'
properties
'
][
'
sub_div_center
'
][
0
])
map_zones
=
[
area_limit
[
1
],
area_limit
[
3
]]
print
(
map_zones
)
map_data
=
list
(
filter
(
lambda
point_position
:
inArea
((
point_position
[
'
properties
'
][
'
sub_div_center
'
][
0
][
1
],
point_position
[
'
properties
'
][
'
sub_div_center
'
][
0
][
0
],
0.0
),
map_zones
),
map_data
))
print
(
len
(
map_data
))
# Refactor lidar data to a readable format
iceOver
=
laspy
.
read
(
lazData_path
[
0
])
...
...
@@ -81,7 +101,7 @@ def calculate_area_data(center):
min_point
=
min
(
ice_points
)
# define all the sub-areas within the area, local coordinates
grid_area_heights
=
define_gridareas
(
60
,
10
,
1500
,
4
)
grid_area_heights
=
define_gridareas
(
60
,
10
,
cell_size_to_meters
,
4
)
# find the heights of each sub-area => area-heights
for
sub_area
in
grid_area_heights
:
...
...
@@ -101,5 +121,6 @@ def calculate_area_data(center):
return
area_heights
print
(
calculate_area_data
((
61
,
11
),
0.04
,
'
mjosa
'
))
print
(
abs
(
-
69.9
))
This diff is collapsed.
Click to expand it.
server/main.py
+
1
−
1
View file @
720ed4d0
...
...
@@ -48,7 +48,7 @@ class IceHTTP(BaseHTTPRequestHandler):
get_weather
(
self
)
elif
self
.
path
==
'
/new_lidar_data
'
:
input_new_Lidar_data
(
self
,
self
.
cursor
,
1
,
'
Mjosa
'
)
# hardcoded body of water must change later
input_new_Lidar_data
(
self
,
self
.
cursor
,
'
Mjosa
'
)
# hardcoded body of water must change later
# Start a server on port 8443 using self defined HTTP class
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
server/map/input_new_data.py
+
3
−
2
View file @
720ed4d0
...
...
@@ -3,11 +3,12 @@ from datetime import datetime
from
server.data_processing.process_lidar_data
import
calculate_area_data
,
about_laz_file
# input_new_Lidar_data send new data gathered from the lidar and send it to the database (from the drone, most likely)
def
input_new_Lidar_data
(
self
,
cursor
,
sensorId
,
bodyOfWater
):
def
input_new_Lidar_data
(
self
,
cursor
,
bodyOfWater
):
try
:
# hard coded coordinates
latitude
=
60.0
longitude
=
10.0
sensorId
=
1
total_measurement_average
=
0
# the total average of a measurement
...
...
@@ -27,7 +28,7 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
measurement_id
=
cursor
.
lastrowid
# calculate the area of to be calculated based on the coordinates given to the calculation model
areas_data
=
calculate_area_data
((
latitude
,
longitude
))
areas_data
=
calculate_area_data
((
latitude
,
longitude
)
,
0.04
,
bodyOfWater
)
if
(
areas_data
):
...
...
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