diff --git a/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc b/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc index dd89aae39ab901f86fce84e3504e94ab4d91eb4c..a2f322da4b53723c391fe39b2dd41dda48c08e24 100644 Binary files a/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc and b/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc differ diff --git a/server/map_handler/add_new_lake.py b/server/map_handler/add_new_lake.py index a674b4b91386f6ac3eb5583e9925b0354f7451b2..f2db07411e69a85212976a8d1c3093795a22e86b 100644 --- a/server/map_handler/add_new_lake.py +++ b/server/map_handler/add_new_lake.py @@ -4,8 +4,8 @@ import random from math import cos import geopandas as gpd from matplotlib import pyplot as plt -from shapely.geometry import Polygon, LineString, MultiLineString from shapely.ops import linemerge, unary_union, polygonize +from shapely.geometry import Polygon, LineString, MultiLineString from server.consts import LAKE_RELATIONS_PATH @@ -26,15 +26,6 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5): polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon'] polygons = [Polygon(polygon.exterior) for polygon in polygon_data['geometry']] - # Extracting interior polygons to preserve fully enclosed islands - interior_polys = [] - for polygon in polygon_data['geometry']: - for interior in polygon.interiors: - if isinstance(interior, Polygon): # Only include Polygon objects - interior_polys.append(interior) - - all_islands = polygonize(interior_polys) - if len(polygons) <= 1: raise Exception("Failed to convert JSON object to Shapely Polygons") @@ -45,13 +36,13 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5): bounds = polygons[0].bounds start_x, start_y, _, _ = bounds - cell_width = 0.5 / 111.3200 + cell_width = cell_size_in_km / 111.3200 cell_height = cell_width / cos(start_x * 0.01745) # Process all polygons for polygon in polygons: # Generate a grid based on the calculated cell size - lines = create_grid(polygon, cell_width * 2, cell_height) + lines = create_grid(polygon, cell_width*2, cell_height) lines.append(polygon.boundary) # Merge the grid lines into a single grid object lines = unary_union(lines) @@ -61,9 +52,6 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5): # Divide the polygon into tiles based on the generated grid divided_map.extend(combine_grid_with_poly(polygon, lines)) - # Add islands as the last object - divided_map.extend(all_islands) - # List to store new GeoJSON feature objects features = [] diff --git a/server/map_handler/lake_relations/all_lake_names.json b/server/map_handler/lake_relations/all_lake_names.json index d1d3eb65a68c73e21a9996a2dbd03764de9777ac..3a0d20e16aa007f3a41dbaf3a1d5b58eb9ba55e9 100644 --- a/server/map_handler/lake_relations/all_lake_names.json +++ b/server/map_handler/lake_relations/all_lake_names.json @@ -1,4 +1,5 @@ [ "Mjøsa", - "Skumsjøen" + "Skumsjøen", + "Mjøsa" ] \ No newline at end of file