Skip to content
Snippets Groups Projects
Commit 3c818922 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

update: move map plotting to function + tidy server imports

parent 81b0bc99
No related branches found
No related tags found
1 merge request!12Clhp map
...@@ -3,12 +3,12 @@ import json ...@@ -3,12 +3,12 @@ import json
import sqlite3 import sqlite3
from flask import Flask from flask import Flask
from urllib.parse import urlparse, parse_qs 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 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 map_handler.add_lake import cut_map
from server.consts import LAKE_RELATIONS_PATH 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.get_measurements import get_all_markers
from map_handler.input_new_data import input_new_Lidar_data from map_handler.input_new_data import input_new_Lidar_data
......
File deleted
import os
import json
import random
import geopandas as gpd 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 from shapely.ops import linemerge, unary_union, polygonize
import json from shapely.geometry import Polygon, LineString, MultiLineString
import os
from server.consts import LAKE_RELATIONS_PATH from server.consts import LAKE_RELATIONS_PATH
...@@ -34,25 +37,6 @@ def cut_map(self, body_of_water: str): # NB: implement body_of_water ...@@ -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)) 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 = [] features = []
sub_div_id = 0 sub_div_id = 0
...@@ -151,3 +135,19 @@ def write_json_to_file(path: str, file_name: str, json_data: dict): ...@@ -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: with open(path + '/' + file_name + '_div.json', 'w') as f:
json.dump(json_data, 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()
File moved
import json import json
from datetime import datetime
import random import random
from datetime import datetime
# get_markers requests all marker data or valid markers, converts the data to json, and writes # get_markers requests all marker data or valid markers, converts the data to json, and writes
......
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