Skip to content
Snippets Groups Projects
Commit 0cd1b498 authored by Hoa Ben The Nguyen's avatar Hoa Ben The Nguyen
Browse files

change: add new lidar data to actual file

parent 37b5fb5b
No related branches found
No related tags found
No related merge requests found
......@@ -124,7 +124,7 @@ def calculate_area_data(center, body_of_water):
min_point = min(ice_points)
# define all the sub-areas within the area, local coordinates
grid_area_heights = define_gridareas(60,10, (cell_x, cell_y),4)
grid_area_heights = define_gridareas(60, 10, (cell_x, cell_y),4)
# find the heights of each sub-area => area-heights
for sub_area in grid_area_heights:
......@@ -145,7 +145,8 @@ def calculate_area_data(center, body_of_water):
sub_center = ((xs + xe)/2, (ys + ye)/2)
if len(map_data) > 0:
current_map_zone = closest_points(sub_center, map_data, taken_coords)
taken_coords.append((current_map_zone['properties']['sub_div_center'][0][0], current_map_zone['properties']['sub_div_center'][0][1]))
sub_center = current_map_zone['properties']['sub_div_center'][0]
taken_coords.append(sub_center)
else:
return [0]
......@@ -158,5 +159,5 @@ def calculate_area_data(center, body_of_water):
return area_heights
print(calculate_area_data((61,11), 0.04,'mjosa'))
print(calculate_area_data((61, 11), 0.04, 'mjosa'))
import json
import os.path
from datetime import datetime
from server.data_processing.process_lidar_data import calculate_area_data, about_laz_file
......@@ -85,10 +86,17 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
self.send_header('Content-type', "application/json")
self.end_headers()
file_path = "../lake_relation/newest_lidar_data.json"
content = None
if len(lidar_json_data) > 0:
if os.path.exists(file_path):
os.remove(file_path)
# convert list of lidar data to json
content = json.dumps(lidar_json_data)
with open(file_path, "w") as file:
file.write(content)
else:
print('No data found')
content = json.dumps([])
......@@ -96,7 +104,6 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
# Write content data to response object
self.wfile.write(content.encode('utf-8'))
# error handling
except Exception as e:
print("An error occurred", e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment