From ab034eb1058297cc2cfe247276e06ba7ea0a1ecd Mon Sep 17 00:00:00 2001 From: Hoa Ben The Nguyen <hbnguye@stud.ntnu.no> Date: Fri, 23 Feb 2024 01:27:57 +0100 Subject: [PATCH] change: adapt to changes --- .../process_lidar_data.py | 20 ++++++++--------- server/map/get_markers.py | 22 ++++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) rename server/{ => data_processing}/process_lidar_data.py (86%) diff --git a/server/process_lidar_data.py b/server/data_processing/process_lidar_data.py similarity index 86% rename from server/process_lidar_data.py rename to server/data_processing/process_lidar_data.py index 541cb70e..a0fdea41 100644 --- a/server/process_lidar_data.py +++ b/server/data_processing/process_lidar_data.py @@ -57,21 +57,19 @@ def find_height(points): height_differences.append(difference) groupss.append(groups) - return min(height_differences) + return height_differences -print(lazData_path[0]) - -# Refactor data format -iceOver = laspy.read(lazData_path[0]) -iceUnder = laspy.read(lazData_path[1]) +# areas +def height_in_area(area): + # Refactor data format + iceOver = laspy.read(lazData_path[0]) + iceUnder = laspy.read(lazData_path[1]) -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)) -area_heights = [] + area_heights = [] -# areas -for area in areas: ice_points = list(filter(lambda position: inArea(position, area), ice_points)) area_heights.append(find_height(ice_points)) -print(area_heights) \ No newline at end of file + return area_heights diff --git a/server/map/get_markers.py b/server/map/get_markers.py index 6238ba93..9fa5dd1a 100644 --- a/server/map/get_markers.py +++ b/server/map/get_markers.py @@ -1,5 +1,6 @@ import json from datetime import datetime +from server.data_processing.process_lidar_data import height_in_area # get_markers requests all marker data or valid markers, converts the data to json, and writes # the data to the response object @@ -105,7 +106,6 @@ def get_all_markers(self, cursor, valid: bool): def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater): try: - cursor.execute(''' INSERT INTO Measurement( SensorID, TimeMeasured, WaterBodyName) VALUES (?,?,?); @@ -115,19 +115,21 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater): measurement_id = cursor.lastrowid cursor.execute(''' - SELECT CornerLatitude, CornerLongitude - FROM Cursor + SELECT DISTINCT CenterLatitude, CenterLongitude + FROM SubDivision where MeasurementID = ?; ''') - cursor_data = cursor.fetchall() + position_data = cursor.fetchall() - if(cursor_data): - for row in cursor_data: - longitude, latitude = row + if(position_data): + for row in position_data: + latitude, longitude = row + heights = height_in_area((latitude,longitude)) + average = sum(heights)/len(heights) cursor.execute(''' - INSERT INTO Data(MeasurementID, Latitude, Longitude, IceTop, IceBottom, CalculatedThickness) VALUES - (?,?,?,?); - ''',(measurementId, )) + INSERT INTO SubDivision(MeasurementID, SubDivisionID, GroupID, MinimumThickness, AverageThickness, CenterLatitude, CenterLongitude, Accuracy) VALUES + (?,?,?,?,?,?,?,?); + ''',(measurement_id, 1, 1, min(heights), average, latitude, longitude, 1)) cursor.connection.commit() -- GitLab