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

update: backtrack

parent 3fca7139
No related branches found
No related tags found
1 merge request!10Clhp map
......@@ -3,6 +3,7 @@ from http.server import HTTPServer, BaseHTTPRequestHandler
from consts import SSL_CERT_PATH, SSL_KEY_PATH, HOST, PORT
from map.get_measurements import get_all_markers
from map.add_lake import cut_map
from map.process_lake import fetch_divided_map
from APIs.get_weather import get_weather
from map.input_new_data import input_new_Lidar_data
import ssl
......@@ -40,7 +41,9 @@ class IceHTTP(BaseHTTPRequestHandler):
get_all_markers(self, self.cursor, 'mjosa') # Get all markers
# NB: temporary hardcoded waterBodyName
elif self.path == '/get_relation':
cut_map(self, 'Mjosa') # NB temp hardcoded value
fetch_divided_map(self, 'Mjosa') # NB temp hardcoded value
elif self.path == '/divide_new_relation':
cut_map(self, 'Mjosa')
def do_POST(self):
if self.path == '/get_weather_data':
......
No preview for this file type
No preview for this file type
File added
import geopandas as gpd
from shapely.geometry import Polygon, LineString, MultiLineString
from shapely.ops import linemerge, unary_union, polygonize
import matplotlib.pyplot as plt
import random
import math
import json
import os
# Writes contents of a map json file to the response
def fetch_divided_map(self, file_name):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()
# Extract contents from JSON file
with open("server/lake_relations/" + file_name + "_div.json", "r") as file:
data = file.read()
# Write contents of the JSON file to response
self.wfile.write(data.encode('utf-8'))
# Returns a list of [(sub_div_id, sub_div_center)]
def get_ids_and_centers(file_name): # NB buggy
# Expected format: [(id, [x,y]), (id, [x,y])]
geo_data = gpd.read_file("server/lake_relations/" + file_name + "_div.json")
subdivisions = []
for index, row in geo_data.iterrows():
sub_div_id = row['sub_div_id']
sub_div_center = row['sub_div_center']
print("sub_div_id: ", sub_div_id)
subdivision = {
'sub_div_id': sub_div_id,
'sub_div_center': sub_div_center
}
subdivisions.append(subdivision)
return subdivisions
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