def __init__(self, candidates, epsilon): ClusterCandidateIndex.__init__(self, candidates, epsilon) self.candidates_by_ids = [None] * len(candidates) self.idx = index.Index() for cluster_candidate in candidates: if self.candidates_by_ids[cluster_candidate.id] != None: raise Exception("should have all unique ids") self.candidates_by_ids[cluster_candidate.id] = cluster_candidate line_seg = cluster_candidate.line_segment bounding_box = self.get_bounding_box_of_line_segment(line_seg) self.idx.insert(cluster_candidate.id, bounding_box, cluster_candidate)
def find_neighbors_of(self, cluster_candidate): neighbors = ClusterCandidateIndex.find_neighbors_of( self, cluster_candidate) cluster_candidate.set_num_neighbors(len(neighbors)) return neighbors
def __init__(self, candidates, epsilon): ClusterCandidateIndex.__init__(self, candidates, epsilon)
def find_neighbors_of(self, cluster_candidate): neighbors = ClusterCandidateIndex.find_neighbors_of(self, cluster_candidate) cluster_candidate.set_num_neighbors(len(neighbors)) return neighbors