Skip to content
Snippets Groups Projects
Commit d8bfb19b authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

fix: some parts of new get_measurement data structure

parent 047d6be8
No related branches found
No related tags found
1 merge request!16Clhp map into main
......@@ -49,7 +49,7 @@ class SubDiv {
double minThickness;
double avgThickness;
LatLng center;
double accuracy;
int accuracy;
Color color;
List<IceStats> iceStats;
......@@ -69,12 +69,12 @@ class SubDiv {
return SubDiv(
sub_div_id: json['SubdivID'].toString(),
groupID: json['GroupID'] ?? 0,
minThickness: json['MinThickness'] ?? 0,
avgThickness: json['AvgThickness'] ?? 0,
minThickness: json['MinThickness'].toDouble ?? 0,
avgThickness: json['AvgThickness'].toDouble ?? 0,
center: json['CenLatitude'] != null && json['CenLongitude'] != null
? LatLng(json['CenLatitude'], json['CenLongitude'])
: LatLng(0.0, 0.0),
accuracy: json['Accuracy'] ?? 0.0,
accuracy: json['Accuracy'] ?? 0,
// Set grey as default color
color: json['Color'] != null ? Color(json['Color']) : Colors.grey,
iceStats: (json['IceStats'] as List<dynamic>?)
......
This diff is collapsed.
No preview for this file type
......@@ -29,6 +29,7 @@ def about_laz_file(path):
return [las.header.version, las.header.point_count, las.header.scale, las.header.offset]
def find_folder_files(direcory):
files = []
for root, _, fileNames in os.walk(direcory):
......@@ -36,7 +37,7 @@ def find_folder_files(direcory):
files.append(os.path.join(root, fileName))
return files
print(find_folder_files())
# 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
......@@ -76,7 +77,9 @@ def calculate_area_data(center, body_of_water):
# grid data
map_data = map_data['features']
map_zones = [area_limit[2], area_limit[0]]
map_data = list(filter(lambda point_position: inArea((point_position['properties']['sub_div_center'][0], point_position['properties']['sub_div_center'][1], 0.0), map_zones), map_data))
map_data = list(filter(lambda point_position: inArea(
(point_position['properties']['sub_div_center'][0], point_position['properties']['sub_div_center'][1], 0.0),
map_zones), map_data))
# Refactor lidar data to a readable format
iceOver = laspy.read(laz_data_paths[0])
......@@ -85,7 +88,8 @@ def calculate_area_data(center, body_of_water):
# add two files together temporary test data(soon to be removed)
ice_points = list(zip(iceOver.X, iceOver.Y, iceOver.Z)) + list(zip(iceUnder.X, iceUnder.Y, iceUnder.Z))
print(len(ice_points))
ice_points = list(filter(lambda point_position: inArea((point_position[0],point_position[1],0.0),[(-3300000, 4500000), (-3200000, 5000000)]), ice_points))
ice_points = list(filter(lambda point_position: inArea((point_position[0], point_position[1], 0.0),
[(-3300000, 4500000), (-3200000, 5000000)]), ice_points))
print(len(ice_points))
# only for visualizating the testing data
# print("max",max(ice_points))
......@@ -105,7 +109,6 @@ def calculate_area_data(center, body_of_water):
max_point = max(ice_points)
min_point = min(ice_points)
# define all the sub-areas within the area, local coordinates
grid_sub_area = define_gridareas(center[0], center[1], (cell_x, cell_y), grid_size)
# define all the sub-areas within the area, lidar coordinates
......@@ -135,7 +138,9 @@ def calculate_area_data(center, body_of_water):
ye, xe = end
sub_center = ((xs + xe) / 2, (ys + ye) / 2)
# check if area is part of water body
part_of_subarea_of_waterbody = list(filter(lambda pos: inArea((pos['properties']['sub_div_center'][0], pos['properties']['sub_div_center'][1], 0.0), [start,end]), map_data))
part_of_subarea_of_waterbody = list(filter(lambda pos: inArea(
(pos['properties']['sub_div_center'][0], pos['properties']['sub_div_center'][1], 0.0), [start, end]),
map_data))
print('sub_area: ', sub_area)
print('part_of_subarea_of_waterbody: ', part_of_subarea_of_waterbody)
if (len(part_of_subarea_of_waterbody) > 0):
......@@ -161,5 +166,4 @@ def calculate_area_data(center, body_of_water):
else:
return [] # return [0] if no data collected from lidar
# print(calculate_area_data((61, 11), 'mj\u00f8sa'))
No preview for this file type
No preview for this file type
......@@ -32,20 +32,24 @@ def get_measurements(self, lake_name):
# Iterate over all fetched rows
for measurement in lidar_data:
processed_subdivs = []
# Create new measurement object
# Create new measurement object with embedded sensor object
new_measurement = {
'MeasurementID': measurement['MeasurementID'],
'TimeMeasured': str(datetime.now()),
'CenterLat': measurement['CenterLat'],
'CenterLon': measurement['CenterLon'],
'Sensor': measurement['Sensor'],
'Subdivisions': [],
'Sensor': {
'SensorID': measurement['Sensor']['SensorID'],
'SensorType': measurement['Sensor']['SensorType'],
'Active': measurement['Sensor']['Active'],
},
'Subdivisions': None,
}
for sub_division in measurement['Subdivisions']:
subdiv_id = sub_division['SubdivID']
center_lat = sub_division['CenLatitude']
center_lng = sub_division['CenLongitude']
thicknesses = sub_division['Heights']
# Create new subdivision object
sub_division = {
......@@ -68,7 +72,7 @@ def get_measurements(self, lake_name):
processed_subdivs.append(sub_division)
# Append processed measurement and subdivisions
new_measurement['Subdivisions'].append(processed_subdivs)
new_measurement['Subdivisions'] = processed_subdivs
measurements.append(new_measurement)
# Populate remaining non-processed subdivisions and create "invalid" or "proxy" measurement to store them
......
......@@ -3,6 +3,7 @@ import os
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):
"""
......@@ -75,7 +76,9 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
cursor.execute('''
INSERT INTO SubdivisionMeasurementData(MeasurementID, TimeMeasured, SubdivID, WaterBodyName, MinimumThickness, AverageThickness, CalculatedSafety, Accuracy) VALUES
(?,?,?,?,?,?,?,?);
''', (measurement_id, time_measured, subId, bodyOfWater, float(minimum_thickness), float(average), float(0.0), scale_factor))
''', (
measurement_id, time_measured, subId, bodyOfWater, float(minimum_thickness), float(average), float(0.0),
scale_factor))
sub_center = (map_lat, map_lng)
# set up json formate
lidar_read = {
......@@ -123,7 +126,6 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
print('No data found, line 101')
content = json.dumps([])
# Write content data to response object
self.wfile.write(content.encode('utf-8'))
......
......@@ -13,7 +13,7 @@
{
"SubdivID": 36,
"MinThickness": -1.0,
"AvgThickness": 1,
"AvgThickness": 1.0,
"CenLatitude": 60.841532,
"CenLongitude": 10.717878,
"Accuracy": 2
......@@ -21,7 +21,7 @@
{
"SubdivID": 83,
"MinThickness": -1.0,
"AvgThickness": 14,
"AvgThickness": 14.0,
"CenLatitude": 60.828326,
"CenLongitude": 10.982563,
"Accuracy": 2
......@@ -29,7 +29,7 @@
{
"SubdivID": 33,
"MinThickness": -1.0,
"AvgThickness": 1,
"AvgThickness": 1.0,
"CenLatitude": 60.771059,
"CenLongitude": 10.698341,
"Accuracy": 2
......@@ -37,7 +37,7 @@
{
"SubdivID": 136,
"MinThickness": -1.0,
"AvgThickness": 9,
"AvgThickness": 9.0,
"CenLatitude": 60.396856,
"CenLongitude": 11.220933,
"Accuracy": 2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment