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
46cc40aa
Commit
46cc40aa
authored
1 year ago
by
Hoa Ben The Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
change: response json instead of only 200 ok
parent
14f7a8a0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/data_processing/process_lidar_data.py
+2
-1
2 additions, 1 deletion
server/data_processing/process_lidar_data.py
server/map/input_new_data.py
+29
-0
29 additions, 0 deletions
server/map/input_new_data.py
with
31 additions
and
1 deletion
server/data_processing/process_lidar_data.py
+
2
−
1
View file @
46cc40aa
...
...
@@ -143,7 +143,8 @@ def calculate_area_data(center, cell_size, body_of_water):
# filter data within sub-area zones
points_in_area
=
list
(
filter
(
lambda
point_position
:
inArea
(
point_position
,
areazone
),
ice_points
))
area_heights
.
append
((
current_zone_id
,
sub_area
[
0
],
sub_center
,
find_height
(
points_in_area
)))
heights
=
find_height
(
points_in_area
)
area_heights
.
append
((
current_zone_id
,
sub_area
[
0
],
sub_center
,
heights
))
return
area_heights
...
...
This diff is collapsed.
Click to expand it.
server/map/input_new_data.py
+
29
−
0
View file @
46cc40aa
...
...
@@ -30,7 +30,10 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
# calculate the area of to be calculated based on the coordinates given to the calculation model
areas_data
=
calculate_area_data
((
latitude
,
longitude
),
0.04
,
bodyOfWater
)
lidar_json_data
=
{}
if
(
areas_data
):
# store lidar data in jason formate
# calculate data for each zone within the area
for
area
in
areas_data
:
# lng and lat relative to map
...
...
@@ -51,6 +54,17 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
(?,?,?,?,?,?,?,?);
'''
,(
measurement_id
,
area
[
0
],
area
[
1
],
float
(
minimum_thickness
),
float
(
average
),
float
(
map_lat
),
float
(
map_lng
),
float
(
1
)))
# set up json formate
lidar_read
=
{
'
MeasurementId
'
:
measurement_id
,
'
SubId
'
:
area
[
0
],
'
GroupId
'
:
area
[
1
],
'
SubCenter
'
:
(
map_lat
,
map_lng
),
'
Heights
'
:
area
[
2
]
}
lidar_json_data
.
append
(
lidar_read
)
total_measurement_average
=
total_measurement_average
/
len
(
areas_data
)
# input the newly generated measurement_id and whole average thickness
...
...
@@ -59,6 +73,7 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
SET measurementID = ?, WholeAverageThickness = ?
WHERE MeasurementID IS NULL AND WholeAverageThickness = 0;
'''
,
(
int
(
measurement_id
),
total_measurement_average
),
)
else
:
print
(
'
No data found
'
)
...
...
@@ -67,6 +82,20 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
# Send response
self
.
send_response
(
200
)
self
.
send_header
(
'
Content-type
'
,
"
application/json
"
)
self
.
end_headers
()
content
=
None
if
len
(
lidar_json_data
)
>
0
:
# convert list of lidar data to json
content
=
json
.
dumps
(
lidar_json_data
)
else
:
print
(
'
No data found
'
)
content
=
[]
# Write content data to response object
self
.
wfile
.
write
(
content
.
encode
(
'
utf-8
'
))
# error handling
except
Exception
as
e
:
...
...
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