From 592f0b7333ab96b8cf819ff72c44dd4bd330e1ee Mon Sep 17 00:00:00 2001
From: Sara <sarasdj@stud.ntnu.no>
Date: Tue, 12 Mar 2024 17:53:41 +0100
Subject: [PATCH] update: more minor progress, still no proper split

---
 .../__pycache__/get_relation.cpython-311.pyc  | Bin 6562 -> 6656 bytes
 server/map/get_relation.py                    |  14 ++++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/server/map/__pycache__/get_relation.cpython-311.pyc b/server/map/__pycache__/get_relation.cpython-311.pyc
index fe7ed5abeb7016ab5d41377e8865cbfaade3f704..c02d4b335fff30f0ab474427196c1571b4382e6a 100644
GIT binary patch
delta 436
zcmZ2v++f1DoR^o2fq{X+q2oiUi}XgmZ@gUG3=9m+3=9mPZ%pRn^J4rr*;hbwaueSK
z)&(^zDa@12`C~&_YB*9@YnW2lYS^<lK-xh#g}sI)g;5g31Y?BEG7biY)o^u;3^g1z
zOxY|TMMYj9b`=)`LoMgzgZ!P0UX#5AHZyWe{x6Wo$T2xluu+iHuZW3(f#D^X`2YX^
z|H<zJ6*Z~^6%-V55{paX3-UAbO7tqM6sklO6cmaJaxzQei!%}nQlkxG^(rRw3SDFL
zocu&+7R!R5Ir5Vy2y2C12uQw=ntvs=@B;%wDWeb52L=W|rbrMK#T3o-1;mSiP;pEj
z85nruK^)$AkOC0N#vm-eK=P81)&(K08xkrDDlbYHOkjO5`L?j7)B^#T1)LWJG$-(U
z;6+mQ<Acy<JrRCp#yOkq#7!6(lP4ETSTL4NUL!GA(}K}z0s99A3r4FAs$lAXE0{tj
KDkc|68UO&ol6iCh

delta 332
zcmZoLS!B$&oR^o2fq{YHY|Dq#4N@EVzVULgF)%PNGcYiGzA%}O&x`Tb<Ve1q%yVj3
zCcovAW2xd|V3;h<A8W{5!;!*L!?cWrfnhZZ$OI5(WT@e&VFIbC<pi;^!7@dzH7pCb
zCLa_KnJg`!JeftnkJ&ZPYjPx?=Hxno4o23=?1G7mtdlbZ8+q9LikKJ}7+!*i$-e~^
zC%Xw<VN{wdEj&wTY48f^i>jtqR82P|UQ{)|B55&sr?8gdMIQevJpLDW{BMXTEReh?
zqSfL0fsH{}eu3mAA*~BSS~n(JidahB5Rh5Gc~L-f0?!9_B*`BicsBQl@G~>c+B`?x
sgpo06@<j;?#?r}Ll5;i97_Ante_$|UwA!EwrVhA*DRiP_@&!o)03#<~+yDRo

diff --git a/server/map/get_relation.py b/server/map/get_relation.py
index b63bc429..7f59fd80 100644
--- a/server/map/get_relation.py
+++ b/server/map/get_relation.py
@@ -105,23 +105,25 @@ def cut_polygon_in_two(polygon: Polygon, divisor: float, cell_size: float):
     if cell_size > 0:  # Horizontal split
         for point in exterior_coords:
             point = Point(point)  # Convert coordinates to Shapely Point object
-            if point.y < divisor:
-                split_shape.append(point)
+            if point.y < divisor:  # Check if point is over or below divisor
+                split_shape.append(point)  # Append to appropriate shape
             else:
                 remaining_shape.append(point)
 
         if len(split_shape) > 2:
             # Get last point added to
-            last_point = split_shape[len(split_shape)-2]
+            last_point = split_shape[-1]
             # Get length of the newly created edge
             new_edge_len = abs(last_point.x - split_shape[0].x)
-            print("new_edge_len: ", new_edge_len, "    cell_size: ", cell_size)
-            x_val = new_edge_len-cell_size
+            print("new_edge_len: ", new_edge_len, "    cell_size: ", cell_size, "   last_point.x: ", last_point.x,  "   split_shape[0].x: ", split_shape[0].x)
 
             # Add points along the new edge to allow horizontal sections to be split into vertical ones
             while new_edge_len > cell_size:
-                split_shape.insert(0, (x_val, last_point.y)) # NB may have to add/subtract small offset of 0.00001
+                x_val = new_edge_len - cell_size
+
+                split_shape.insert(0, (x_val, last_point.y))  # NB may have to add/subtract small offset of 0.00001
                 remaining_shape.insert(0, (x_val, last_point.y))  # Prepend
+
                 new_edge_len -= cell_size
 
     else:  # Vertical split
-- 
GitLab