diff --git a/server/main.py b/server/main.py index 33097ee3095e2eec3d1f4f10336874b44cf3f437..8a1d2a3ee845a1d40b001a132e600a87c19c102d 100644 --- a/server/main.py +++ b/server/main.py @@ -3,12 +3,12 @@ import json import sqlite3 from flask import Flask from urllib.parse import urlparse, parse_qs -from http.server import HTTPServer, BaseHTTPRequestHandler from consts import SSL_CERT_PATH, SSL_KEY_PATH, HOST, PORT +from http.server import HTTPServer, BaseHTTPRequestHandler from map_handler.add_lake import cut_map from server.consts import LAKE_RELATIONS_PATH -from map_handler.process_lake import get_divided_map +from map_handler.get_lake import get_divided_map from map_handler.get_measurements import get_all_markers from map_handler.input_new_data import input_new_Lidar_data diff --git a/server/map_handler/__pycache__/process_lake.cpython-311.pyc b/server/map_handler/__pycache__/process_lake.cpython-311.pyc deleted file mode 100644 index c3ce2485ffb747f63820d5518630ccdbbaac4910..0000000000000000000000000000000000000000 Binary files a/server/map_handler/__pycache__/process_lake.cpython-311.pyc and /dev/null differ diff --git a/server/map_handler/add_lake.py b/server/map_handler/add_lake.py index 2a1ab71b0289b69620193962bc642e6ad45f7b02..d48efa915afdb7a9ac203250a2c903da05dacfcc 100644 --- a/server/map_handler/add_lake.py +++ b/server/map_handler/add_lake.py @@ -1,8 +1,11 @@ +import os +import json +import random import geopandas as gpd -from shapely.geometry import Polygon, LineString, MultiLineString +from matplotlib import pyplot as plt from shapely.ops import linemerge, unary_union, polygonize -import json -import os +from shapely.geometry import Polygon, LineString, MultiLineString + from server.consts import LAKE_RELATIONS_PATH @@ -34,25 +37,6 @@ def cut_map(self, body_of_water: str): # NB: implement body_of_water divided_map.extend(combine_grid_with_poly(polygon, lines)) - ''' - ####################### PLOTTING ############################ - tiles = [gpd.GeoDataFrame(geometry=[tile]) for tile in divided_map] - - print("Plotting... This may take some time...") - # NB test plot - fig, ax = plt.subplots() - ax.set_aspect(1.5) - - # Plot each tile - for tile in tiles: # NB temporarily limited to 5 tiles - random_color = "#{:06x}".format(random.randint(0, 0xFFFFFF)) - gpd.GeoSeries(tile.geometry).plot(ax=ax, facecolor=random_color, edgecolor='none') - - - plt.show() - ##################### PLOTTIND END ########################### - ''' - features = [] sub_div_id = 0 @@ -151,3 +135,19 @@ def write_json_to_file(path: str, file_name: str, json_data: dict): with open(path + '/' + file_name + '_div.json', 'w') as f: json.dump(json_data, f) + + +def plot_map(divided_map): + tiles = [gpd.GeoDataFrame(geometry=[tile]) for tile in divided_map] + + print("Plotting... This may take some time...") + # NB test plot + fig, ax = plt.subplots() + ax.set_aspect(1.5) + + # Plot each tile + for tile in tiles: # NB temporarily limited to 5 tiles + random_color = "#{:06x}".format(random.randint(0, 0xFFFFFF)) + gpd.GeoSeries(tile.geometry).plot(ax=ax, facecolor=random_color, edgecolor='none') + + plt.show() diff --git a/server/map_handler/process_lake.py b/server/map_handler/get_lake.py similarity index 100% rename from server/map_handler/process_lake.py rename to server/map_handler/get_lake.py diff --git a/server/map_handler/get_measurements.py b/server/map_handler/get_measurements.py index a066d30752e32a39c442bb713bb9832a520290eb..25b2b6359725f354a37dd9c96c738a32deaebf14 100644 --- a/server/map_handler/get_measurements.py +++ b/server/map_handler/get_measurements.py @@ -1,6 +1,6 @@ import json -from datetime import datetime import random +from datetime import datetime # get_markers requests all marker data or valid markers, converts the data to json, and writes