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

fix: sub_div_center calculation, + update skumsjøen centers

parent bfe0a62e
No related branches found
No related tags found
1 merge request!12Clhp map
File added
......@@ -6,7 +6,7 @@ from urllib.parse import urlparse, parse_qs, unquote
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_new_lake import cut_map
from server.consts import LAKE_RELATIONS_PATH
from map_handler.get_lake_relation import get_divided_map
from map_handler.get_measurements import get_measurements
......
File deleted
No preview for this file type
No preview for this file type
......@@ -45,8 +45,7 @@ def cut_map(self, cursor, lake_name: str):
# Calculate tile center based on bounds, and round down to two decimals
min_x, min_y, max_x, max_y = tile.bounds
center = round(max_x - min_x, 4), round(max_y - min_y, 4)
# center = round(tile.centroid.coords[0][0], 4), round(tile.centroid.coords[0][1], 4)
center = round(max_y - (max_y - min_y), 6), round(max_x - (max_x - min_x), 6)
rounded_coordinates = []
if isinstance(tile, Polygon):
......@@ -55,8 +54,6 @@ def cut_map(self, cursor, lake_name: str):
rounded_coordinates.append(rounded_coords)
rounded_tile = Polygon(rounded_coordinates)
sub_div_center_list.append((sub_div_id, center[0], center[1]))
tile_feature = {
'type': 'Feature',
'properties': {
......@@ -74,11 +71,6 @@ def cut_map(self, cursor, lake_name: str):
'tile_count': sub_div_id, # Add the last subdivision ID as number of tiles
}
# Create a text file containing all subdivision ids and center coordinates
with open(LAKE_RELATIONS_PATH + lake_name + "_centers.txt", 'w') as file:
for sub_div_id, x, y in sub_div_center_list:
file.write(f"{sub_div_id}, {x}, {y}\n") # Write each list entry on a new line
# Add lake name to database
cursor.execute('''
INSERT INTO BodyOfWater(Name) VALUES
......
......@@ -25,11 +25,6 @@ def get_measurements(self, cursor, lake_name):
# List of all fetched measurement objects
measurement_data = {}
'''
f = open('server/?')
data = json.load(f)
'''
# Iterate over all fetched rows
for row in rows:
measurement_id = row[0]
......@@ -37,16 +32,6 @@ def get_measurements(self, cursor, lake_name):
center_lat = row[12]
center_lng = row[13]
'''
curr_stat = []
# Find matching ice stat
for stat in data['stats']
if ice_stats.sub_div_id == sub_div_id
curr_stat = stat
break
'''
# Create subdivision new object
sub_division = {
'SubdivID': sub_div_id,
......@@ -81,11 +66,6 @@ def get_measurements(self, cursor, lake_name):
'Subdivisions': [sub_division], # Array of sub_division objects
}
# Add remaining stuff
# NB remember to clos file after implementation
# f.close()
# Convert dictionary values to list of measurements
data = list(measurement_data.values())
......@@ -123,4 +103,4 @@ def calculateColor(thickness: float): # NB neither final colors nor ranges
elif thickness > 8:
return 0xFF00d6ff # Blue
else:
return 0xFF939393 # Gray
return 0xFF939393 # Grey
[
"Mj\u00c3\u00b8sa",
"Skumsj\u00c3\u00b8en"
"Skumsj\u00c3\u00b8en",
"skumsj\u00f8en",
"skumsj\u00f8en",
"skumsj\u00f8en",
"skumsj\u00f8en",
"skumsj\u00f8en",
"skumsj\u00f8en",
"skumsj\u00f8en",
"skumsj\u00f8en"
]
\ No newline at end of file
0, 0.0217, 0.0112
1, 0.017, 0.02
2, 0.0008, 0.001
3, 0.0005, 0.0003
4, 0.0002, 0.0001
5, 0.0004, 0.0002
6, 0.0004, 0.0004
7, 0.0003, 0.0002
\ No newline at end of file
0, 60.759476, 10.528021
1, 60.739476, 10.530733
2, 60.742282, 10.536377
3, 60.7481, 10.544887
4, 60.750731, 10.543055
5, 60.750735, 10.542226
6, 60.751169, 10.54319
7, 60.749417, 10.543726
This diff is collapsed.
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