Skip to content

Commit

Permalink
Simplify logic in column_track()
Browse files Browse the repository at this point in the history
  • Loading branch information
acroucher committed Apr 3, 2024
1 parent 9566046 commit 6f14328
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mulgrids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2011,17 +2011,15 @@ def track_dist(p):
for col in self.columnlist:
bbox = col.bounding_box
if line_intersects_rectangle(bbox, line):
add_col = False
if start_col is None:
if col.contains_point(line[0]):
start_col = col
if end_col is None:
if col.contains_point(line[1]):
end_col = col
if col == start_col == end_col:
pts = line
din = 0
add_col = True
track.append((col, line[0], line[1]))
dist.append(0)
else:
poly = col.polygon
pts = line_polygon_intersections(poly, line)
Expand All @@ -2031,10 +2029,9 @@ def track_dist(p):
elif col == end_col:
pts = [pts[0], line[-1]]
din, dout = track_dist(pts[0]), track_dist(pts[-1])
add_col = abs(dout - din) > tol
if add_col:
track.append((col, pts[0], pts[-1]))
dist.append(din)
if abs(dout - din) > tol:
track.append((col, pts[0], pts[-1]))
dist.append(din)

sortindex = np.argsort(np.array(dist))
track = [track[i] for i in sortindex]
Expand Down

0 comments on commit 6f14328

Please sign in to comment.