Skip to content

Commit

Permalink
refactor: left right of choke are now side_a and side_b, sides are co…
Browse files Browse the repository at this point in the history
…mputed accuratly now
  • Loading branch information
eladyaniv01 committed Dec 13, 2020
1 parent 7286ebd commit 125f881
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions MapAnalyzer/constructs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,14 @@ def __init__(
self.md_pl_choke = pathlibchoke
self.is_choke = True
self.ramp = None
self.side_a = None
self.side_b = None
self._set_sides()

def _set_sides(self):
org = self.top
pts = [self.bottom, self.right, self.left]
res = self.map_data.closest_towards_point(points=pts, target=org)
self.side_a = int(round((res[0] + org[0]) / 2)), int(round((res[1] + org[1]) / 2))
if res != self.bottom:
org = self.bottom
pts = [self.top, self.right, self.left]
res = self.map_data.closest_towards_point(points=pts, target=org)
self.side_b = int(round((res[0] + org[0]) / 2)), int(round((res[1] + org[1]) / 2))
else:
self.side_b = int(round((self.right[0] + self.left[0]) / 2)), int(round((self.right[1] + self.left[1]) / 2))
points = list(self.points)
points.append(self.side_a)
points.append(self.side_b)
self.points = set([Point2((int(p[0]), int(p[1]))) for p in points])
self.indices = self.map_data.points_to_indices(self.points)

@property
def left(self):
return min(self.points)

@property
def right(self):
return max(self.points)

@property
def corner_walloff(self):
Expand Down

0 comments on commit 125f881

Please sign in to comment.