c++ - Find all linesegments=edges within a certain distance to a point in a graph, how to combine boost-graph with boost-geometry? -
i have set of user paths (2 dim) in game setup modelled set of lines (arcs) , waypoints = vertices. whole set of paths can seen graph edges line segments have additional properties length, probability, etc.
now have identify set of (straight) line segments = edges within distance user's current position in order find user's position in graph.
how implement possible without reinventing wheel? how implement search efficiently?
i thought of using boost-graph handling graph , combine boost-geometry. e.g. see trajgraph uses bundled properties in boost-graph:
struct tvertex { float x, y; //vertex=waypoint position }; struct tarc_segment { float len, curvature, prob; //line segment=edge properties }; typedef adjacency_list<vecs, vecs, directeds, tvertex, tarc_segment> trajgraph;
now in order store line segment edge property 1 add boost geometry's model::linestring , use boost-geometry's nearest neighbour query find line segments. afaik boost-geometry not allow attach properties linestrings boost-graph does. hence how edge(s) linestring(s)?
a simple brute-force solution might traverse whole edge-list of graph , calculate distance each line segment. see here , here how calculate distance straight line segment.
it possible attach properties linestrings in boost.geometry, boost.geometry made doing such things. can derive boost::geometry::model::linestring, or implement other range-based structure (e.g. std::vector) , register linestring. see c03 example.
for relation boost.graph, see 1 of examples in boost.geometry: 07_a or 07_b similar thing done. done there storing boost.geometry linestring boost.graph edge (with property), other properties, way of doing this.
Comments
Post a Comment