def add(self, way, nodes): """Add a new way to the list. Should any of the middle nodes be an intersection then the way is split at this point before adding it to the list. """ # find all nodes that are forced intersecions splitidx = [ x for x in range(len(nodes)) if nodes[x] in self.intersections ] if len(splitidx) == 0 or splitidx[0] != 0: splitidx[:0] = [0] if splitidx[-1] != len(nodes) - 1: splitidx.append(len(nodes) - 1) for i in range(len(splitidx) - 1): w = FusableWay(way, nodes[splitidx[i]:splitidx[i + 1] + 1]) self.ways.add(w) for n in (w.first(), w.last()): if n in self.pointlist: self.pointlist[n].append(w) else: self.pointlist[n] = [w]