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