diff --git a/server/map/__pycache__/get_relation.cpython-311.pyc b/server/map/__pycache__/get_relation.cpython-311.pyc
index 9f6bc3bbed6c8498228339e917a9df921d086870..292074eece6f6c20639a8f1279a549c2c84d1952 100644
Binary files a/server/map/__pycache__/get_relation.cpython-311.pyc and b/server/map/__pycache__/get_relation.cpython-311.pyc differ
diff --git a/server/map/get_relation.py b/server/map/get_relation.py
index d636963657d3fdf0b2a92cef87e0b6060ca8fe7d..930381370a9f26761c8cd1891c1ee9363e7c59b1 100644
--- a/server/map/get_relation.py
+++ b/server/map/get_relation.py
@@ -30,8 +30,11 @@ def get_relation(self, body_of_water: str):
# Divide the length and with of polygon into a grid
grid_lines = create_grid_coords(polygon, cell_size=0.1)
+ #hrz_lines = grid_lines[0] # Horizontal coordinates
+ #vrt_lines = grid_lines[1] # Vertical coordinates
+
hrz_lines = [60.7530] # Horizontal coordinates
- vrt_lines = [10.8572] # Vertical coordinates
+ vrt_lines = [11.2267] # Vertical coordinates
# Cut polygon into horizontal sections
for hrz_line in hrz_lines:
@@ -54,8 +57,16 @@ def get_relation(self, body_of_water: str):
polygon = cut_poly_1[1] # Set polygon to the remaining, un-split shape for next iteration
- # Append last remainder
- divided_map.append(polygon)
+ # Split last remainder into horizontal lines
+ for vrt_line in vrt_lines:
+ last_section = cut_polygon_in_two(polygon, vrt_line, False)
+
+ divided_map.append(last_section[0]) # Append part to final list of shapes
+
+ # Set polygon_part to the remaining, un-split, horizontal section for next iteration
+ polygon = last_section[1]
+
+ break # NB: temporary break to ensure treatment of only the first polygon
tiles = gpd.GeoDataFrame(geometry=divided_map)
@@ -104,15 +115,14 @@ def cut_polygon_in_two(polygon: Polygon, divisor: float, horizontal: bool):
# Check if the split_shape has enough coordinates to create a polygon
if len(split_shape) < 3:
- print("Not enough coordinates to create valid polygons: Split shape")
+ print("Not enough coordinates to create valid polygon: Split shape")
split_shape = None
# Check if the remaining_shape has enough coordinates to create a polygon
if len(remaining_shape) < 3:
- print("Not enough coordinates to create valid polygons: Remaining shape")
+ print("Not enough coordinates to create valid polygon: Remaining shape")
remaining_shape = None
-
# Return split polygons as Shapely Polygon objects
return Polygon(split_shape), Polygon(remaining_shape)
@@ -131,4 +141,3 @@ def create_grid_coords(polygon: Polygon, cell_size: float):
# Return tuple of list of x coordinates and list of y coordinates
return x_coords, y_coords
-