fix cut trough empty space detection in cut_polygon_with_line
This commit is contained in:
parent
f65b15bb29
commit
b9977676d6
2 changed files with 5 additions and 2 deletions
|
@ -507,7 +507,9 @@ class AltitudeArea(LevelGeometryMixin, models.Model):
|
||||||
for area in our_areas
|
for area in our_areas
|
||||||
if buffered.intersects(area.orig_geometry))
|
if buffered.intersects(area.orig_geometry))
|
||||||
if touches:
|
if touches:
|
||||||
area = max(touches, key=itemgetter(1))[0]
|
area = max(touches, key=lambda item: (item[0].altitude2 is not None,
|
||||||
|
item[0].altitude,
|
||||||
|
item[1]))[0]
|
||||||
else:
|
else:
|
||||||
area = min(our_areas, key=lambda a: a.orig_geometry.distance(center))
|
area = min(our_areas, key=lambda a: a.orig_geometry.distance(center))
|
||||||
area.geometry = area.geometry.union(polygon)
|
area.geometry = area.geometry.union(polygon)
|
||||||
|
|
|
@ -209,7 +209,8 @@ def cut_polygon_with_line(polygon: Union[Polygon, MultiPolygon], line: LineStrin
|
||||||
point_backwards = ring[0].coords[-2]
|
point_backwards = ring[0].coords[-2]
|
||||||
angle_forwards = math.atan2(point_forwards[0] - last.point.x, point_forwards[1] - last.point.y)
|
angle_forwards = math.atan2(point_forwards[0] - last.point.x, point_forwards[1] - last.point.y)
|
||||||
angle_backwards = math.atan2(point_backwards[0] - last.point.x, point_backwards[1] - last.point.y)
|
angle_backwards = math.atan2(point_backwards[0] - last.point.x, point_backwards[1] - last.point.y)
|
||||||
angle_segment = math.atan2(current.point.x - last.point.x, current.point.y - last.point.y)
|
next_segment_point = Point(segment.coords[1])
|
||||||
|
angle_segment = math.atan2(next_segment_point.x - last.point.x, next_segment_point.y - last.point.y)
|
||||||
|
|
||||||
while angle_forwards <= angle_backwards:
|
while angle_forwards <= angle_backwards:
|
||||||
angle_forwards += 2*math.pi
|
angle_forwards += 2*math.pi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue