auskommentierter und ungenutzer Code rausgeworfen
This commit is contained in:
+1
-32
@@ -3,10 +3,9 @@ from shapely.geometry import LineString, Point, box
|
||||
from shapely.ops import nearest_points
|
||||
import unittest
|
||||
from collections import defaultdict
|
||||
import bisect
|
||||
import networkx as nx
|
||||
import matplotlib.pyplot as plt
|
||||
from itertools import pairwise, combinations, permutations
|
||||
from itertools import pairwise
|
||||
import re
|
||||
from shapely.strtree import STRtree
|
||||
import math
|
||||
@@ -16,48 +15,19 @@ import shapely
|
||||
draw = False
|
||||
class PointSorter:
|
||||
def __init__(self):
|
||||
#self._points_by_x = [] # [(x, y)]
|
||||
#self._points_by_y = [] # [(y, x)]
|
||||
|
||||
self.points = []
|
||||
|
||||
def add_point(self, point:Point):
|
||||
# bisect.insort(self._points_by_x, (x, y))
|
||||
# bisect.insort(self._points_by_y, (y, x))
|
||||
|
||||
self.points.append(point)
|
||||
|
||||
def add_points(self, points:list[Point]):
|
||||
for p in points:
|
||||
self.add_point(p)
|
||||
|
||||
def query_box(self, x1, x2, y1, y2):
|
||||
# Suche nach x-Grenzen
|
||||
ix1 = bisect.bisect_left(self._points_by_x, (x1, -float('inf')))
|
||||
ix2 = bisect.bisect_right(self._points_by_x, (x2, float('inf')))
|
||||
candidates = self._points_by_x[ix1:ix2]
|
||||
|
||||
# Filtere nach y
|
||||
ret = list()
|
||||
for (x,y) in candidates:
|
||||
if y1 <= y <= y2:
|
||||
ret.append(Point(x,y))
|
||||
return ret
|
||||
|
||||
def get_sorted_by_x(self):
|
||||
# Sortiere nach x
|
||||
# ret = list()
|
||||
# for (x,y) in self._points_by_x:
|
||||
# ret.append(Point(x,y))
|
||||
# return ret
|
||||
return sorted(self.points, key = lambda p: p.x)
|
||||
|
||||
def get_sorted_by_y(self):
|
||||
# # Sortiere nach y
|
||||
# ret = list()
|
||||
# for (y,x) in self._points_by_y:
|
||||
# ret.append(Point(x,y))
|
||||
# return ret
|
||||
return sorted(self.points, key = lambda p: p.y)
|
||||
|
||||
def to_json(d, pretty: bool = True) -> str:
|
||||
@@ -174,7 +144,6 @@ class RackIDs():
|
||||
ret.append(p)
|
||||
pin.add_points(ret)
|
||||
ret_sorted = list()
|
||||
#(pa, pe) = self._rack2begend[name]
|
||||
if self.rack_is_horizontal(name):
|
||||
ret_sorted = pin.get_sorted_by_x()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user