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
|
from shapely.ops import nearest_points
|
||||||
import unittest
|
import unittest
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import bisect
|
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from itertools import pairwise, combinations, permutations
|
from itertools import pairwise
|
||||||
import re
|
import re
|
||||||
from shapely.strtree import STRtree
|
from shapely.strtree import STRtree
|
||||||
import math
|
import math
|
||||||
@@ -16,48 +15,19 @@ import shapely
|
|||||||
draw = False
|
draw = False
|
||||||
class PointSorter:
|
class PointSorter:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#self._points_by_x = [] # [(x, y)]
|
|
||||||
#self._points_by_y = [] # [(y, x)]
|
|
||||||
|
|
||||||
self.points = []
|
self.points = []
|
||||||
|
|
||||||
def add_point(self, point:Point):
|
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)
|
self.points.append(point)
|
||||||
|
|
||||||
def add_points(self, points:list[Point]):
|
def add_points(self, points:list[Point]):
|
||||||
for p in points:
|
for p in points:
|
||||||
self.add_point(p)
|
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):
|
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)
|
return sorted(self.points, key = lambda p: p.x)
|
||||||
|
|
||||||
def get_sorted_by_y(self):
|
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)
|
return sorted(self.points, key = lambda p: p.y)
|
||||||
|
|
||||||
def to_json(d, pretty: bool = True) -> str:
|
def to_json(d, pretty: bool = True) -> str:
|
||||||
@@ -174,7 +144,6 @@ class RackIDs():
|
|||||||
ret.append(p)
|
ret.append(p)
|
||||||
pin.add_points(ret)
|
pin.add_points(ret)
|
||||||
ret_sorted = list()
|
ret_sorted = list()
|
||||||
#(pa, pe) = self._rack2begend[name]
|
|
||||||
if self.rack_is_horizontal(name):
|
if self.rack_is_horizontal(name):
|
||||||
ret_sorted = pin.get_sorted_by_x()
|
ret_sorted = pin.get_sorted_by_x()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user