Exemplo n.º 1
0
    def merge_node_set_into_node(self, original: Node, attached: Set[Node]):
        # border attribute should be true if any are borders
        original.is_border = any([i.is_border for i in attached])

        # all nodes in attached should be removed from grid
        for i in attached:
            if i.position != original.position:
                i.deleted = True

        # position should cover all attached
        original.position = set.union(*[i.position for i in attached])

        # final outflow is the outflow for all nodes except outflows to itself
        all_possible_outflows = []
        for i in attached:
            for j in i.outflow:
                if not overlaps(j.position, original.position):
                    if not any([overlaps(j.position, k.position) for k in all_possible_outflows]):
                        all_possible_outflows.append(j)

        original.outflow = all_possible_outflows
Exemplo n.º 2
0
 def to_node(self, row: int, col: int, altitude: float):
     node = Node()
     node.altitude = altitude
     node.position = {(row, col)}
     node.deleted = False
     return node