def findCrossTypeSolutions(self, elements, solutions): shapes_found = [] logger.debug('Buscando soluciones cruzadas...') for geo_type_a in elements.keys(): for geo_type_b in elements.keys(): if geo_type_a != geo_type_b: for element_id_a in elements[geo_type_a].keys(): for element_id_b in elements[geo_type_b].keys(): element_a = elements[geo_type_a][element_id_a] element_b = elements[geo_type_b][element_id_b] if not element_a['used'] and not element_b[ 'used'] and element_a[ 'allows_intersection'] and element_b[ 'allows_intersection'] and not self.shareToken( element_a, element_b): shape_a = asShape(element_a['geometry']) shape_b = asShape(element_b['geometry']) middle_point = None #print element_a['nombre'],element_b['nombre'], shape_a.distance(shape_b), self.near_distance_limit if shape_a.crosses(shape_b): middle_point = shape_a.intersection( shape_b).representative_point() elif shape_a.distance( shape_b) > 0 and shape_a.distance( shape_b ) < self.near_distance_limit: middle_point = MultiPoint([ shape_a.representative_point(), shape_b.representative_point() ]).representative_point() if middle_point: shape_found_before = False for shape in shapes_found: shape_found_before = middle_point.almost_equals( shape, self.decimals_solutions_equals) if shape_found_before: #print 'DUPLICATE FOUND' break if not shape_found_before: shapes_found.append(middle_point) #elements[geo_type_a][element_id_a]['used'] = True #elements[geo_type_b][element_id_b]['used'] = True solution = self.buildSolution( [element_a, element_b], middle_point) solutions.append(solution)