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
...@@ -145,7 +145,8 @@ def calculate_area_data(center, body_of_water): ...@@ -145,7 +145,8 @@ def calculate_area_data(center, body_of_water):
sub_center = ((xs + xe)/2, (ys + ye)/2) sub_center = ((xs + xe)/2, (ys + ye)/2)
if len(map_data) > 0: if len(map_data) > 0:
current_map_zone = closest_points(sub_center, map_data, taken_coords) 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: else:
return [0] return [0]
......
import json import json
import os.path
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
...@@ -85,10 +86,17 @@ def input_new_Lidar_data(self, cursor, bodyOfWater): ...@@ -85,10 +86,17 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
self.send_header('Content-type', "application/json") self.send_header('Content-type', "application/json")
self.end_headers() self.end_headers()
file_path = "../lake_relation/newest_lidar_data.json"
content = None content = None
if len(lidar_json_data) > 0: if len(lidar_json_data) > 0:
if os.path.exists(file_path):
os.remove(file_path)
# convert list of lidar data to json # convert list of lidar data to json
content = json.dumps(lidar_json_data) content = json.dumps(lidar_json_data)
with open(file_path, "w") as file:
file.write(content)
else: else:
print('No data found') print('No data found')
content = json.dumps([]) content = json.dumps([])
...@@ -96,7 +104,6 @@ def input_new_Lidar_data(self, cursor, bodyOfWater): ...@@ -96,7 +104,6 @@ def input_new_Lidar_data(self, cursor, bodyOfWater):
# 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'))
# error handling # error handling
except Exception as e: except Exception as e:
print("An error occurred", e) print("An error occurred", e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment