Waypoint selection strategies
The design, development and test of the waypoint selection and trajectory forming algorithm was discussed with the assumption that the users provide a geographic region that they are interested in observing. The region is then divided into a grid of cells under a user configurable cell size. Then acquiring information on the reachability of cells from one another, we create a graph represented with cells as nodes and the adjacencies as edges. This helps us determine waypoints as the set of nodes to select in a topographical sort between source to destination. One of the helper libraries for the implementation, therefore, involves the following graph object.
class Vertex(object):
def __init__(self, id, point):
self.id = id
self.point = point
self.in_edges = []
self.out_edges = []
def _neighbors(self):
n = {}
for edge in self.in_edges:
n[edge.src] = edge
for edge in self.out_edges:
n[edge.dst] = edge
return n
def neighbors(self):
return self._neighbors().keys()
def __repr__(self):
return 'Vertex({}, {}, {} in {} out)'.format(self.id, self.point, len(self.in_edges), len(self.out_edges))
class Edge(object):
def __init__(self, id, src, dst):
self.id = id
self.src = src
self.dst = dst
def bounds(self):
return self.src.point.bounds().extend(self.dst.point)
def segment(self):
return geom.Segment(self.src.point, self.dst.point)
def closest_pos(self, point):
p = self.segment().project(point)
return EdgePos(self, p.distance(self.src.point))
def is_opposite(self, edge):
return edge.src == self.dst and edge.dst == self.src
def get_opposite_edge(self):
for edge in self.dst.out_edges:
if self.is_opposite(edge):
return edge
return None
def is_adjacent(self, edge):
return edge.src == self.src or edge.src == self.dst or edge.dst == self.src or edge.dst == self.dst
def orig_id(self):
if hasattr(self, 'orig_edge_id'):
return self.orig_edge_id
else:
return self.id
No comments:
Post a Comment