From adb005ac006b8814d2c929dded7e7d98d768b19e Mon Sep 17 00:00:00 2001 From: Sara <sarasdj@stud.ntnu.no> Date: Wed, 13 Mar 2024 19:04:17 +0100 Subject: [PATCH] update: horizontal sections, no spacing, wrong verticals --- .../__pycache__/get_relation.cpython-311.pyc | Bin 7817 -> 7972 bytes server/map/get_relation.py | 16 +++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/server/map/__pycache__/get_relation.cpython-311.pyc b/server/map/__pycache__/get_relation.cpython-311.pyc index 68c0cc6a2c8de1d9bad2c4a677526c0144087a78..78b81d93f4fc4f5ee3a9312d3d738fd2d380ea23 100644 GIT binary patch delta 1048 zcmZuvO=uHQ5Pokrn{AV3H>ok3P13}u)UKj!OhH>ym4Z}Mda(A;ijC1-s;F(<BuHVa zEh^T7BF@1-kQ}s)=wVAl1S$05MG=y+LhV7l)|28*5PffJF<6Iv-^}-B_Pu#CbG_ry zZeiNvaUmjCzI@X>@fl$cgAM3rOw7SACJ$zv3^!O0%NIP5sq@1OE8`k?%l2`#s_U5> z6h{KP;izL2*TH*-!g^EzFqh@UDU8rl3>7vI$4EszNbz<L-oHoX!ycU>H!hI~w8Ro9 zz2a`O{6Hn1w&Lm1k=j{|AC~IfQMPLh@%|CRVQ>ax;3)?=n5<<Pa~ZA)ui;V|d1VWY zIS9v9oGUd87~{2&5W@s#gb)mh63P3L*b-XwjSP?E&t`I3dPuvF*3>~wr%5Spcp)AS zE_zqoYC3x=Good)ZsJ`BVQ&<lE46!zcw0~@hRxx*(emNGiqvmO{bh%LftSkshJ`?5 z;k*@4Cfy66&BcTj+BzwgKKXVq_-0A+i%jG=Icv#DftJLsi^A(&)b54Oz%^WeH-Qh4 z2=U%Q2D*hOoH^oL5yBD7N?WA1G2U=i7s23FRz~nsYUVZ?TmeHOxQTB!IDJiyBNYfk z3sdW)eaZ1~J-FRp{qGt3cwK^b!BA?o!<0xbYE=Gjg;&SuT?Q&R?2$>zVZ3ael>c{+ z*#*<`rnVF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?qK<RMcUj*zKtv<&c5|4RR_*~fFRgB z_5Qv@U)mYWID?8aIL&Qyo+q~xA;nj%_yQYTAk76J?6G_QdAl4kmlDdL;;T`7wHsV* znyZC`=ZyZ)+w&}HyVTx0VWqU(qxQM9KfBaQ?BBY^tK&j!RBV>+!jIBrp2rPyb-QFS S4ax4T`Vh;ie7FD~y`jI_<m1Qy diff --git a/server/map/get_relation.py b/server/map/get_relation.py index 81f7ce5f..b3a36328 100644 --- a/server/map/get_relation.py +++ b/server/map/get_relation.py @@ -44,7 +44,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water break # Break from loop im remaining section has no coordinates # Split the horizontal section into two vertical parts - vertical_parts = cut_polygon_by_points(horizontal_section, vrt_line, -0.1) + vertical_parts = cut_polygon_by_points(horizontal_section, vrt_line, cell_size) divided_map.append(vertical_parts[0]) # Append split vertical sections to final list of shapes @@ -121,6 +121,12 @@ def cut_polygon_by_points(polygon: Polygon, divisor: float, cell_size: float): else: remaining_shape.append((point2.x, point2.y)) + # Populate newly created edges with points to facilitate vertical cutting + populated_shapes = populate_new_edge(split_shape, remaining_shape, cell_size, divisor) + if populated_shapes is not None: + split_shape = populated_shapes[0] + remaining_shape = populated_shapes[1] + # Ensure that the shapes are closed loops if len(split_shape) > 0 and split_shape[0] != split_shape[-1]: split_shape.append(split_shape[0]) @@ -181,23 +187,23 @@ def populate_new_edge(split_shape, remaining_shape, cell_size: float, divisor: f # Find all corners of split shape. Corner = point that intersects divisor for point in split_shape: - if divisor_range[0] < point.y < divisor_range[1]: + if divisor_range[0] < point[1] < divisor_range[1]: corners.append(point) if not corners or len(corners) < 2: return None # Sort corners in ascending order (left to right) based on x coordinate - sorted_corners = sorted(corners, key=lambda p: p.x) + sorted_corners = sorted(corners, key=lambda p: p[0]) - while starting_point < sorted_corners[0].x: # Increment starting point until it is withing the polygons bounds + while starting_point < sorted_corners[0][0]: # Increment starting point until it is withing the polygons bounds starting_point += cell_size # if starting_point < left_corner.x: # NB: optimised substitute for previous while loop, requires testing # starting_point += cell_size * math.floor(starting_point - left_corner.x) # Insert new points with cell_size spacing while starting_point is within bounds - while starting_point < sorted_corners[-1].x: + while starting_point < sorted_corners[-1][0]: split_shape.insert(0, (starting_point, divisor)) # NB may have to add/subtract small offset of 0.00001 remaining_shape.insert(-1, (starting_point, divisor)) # Prepend new point to shape -- GitLab