I have a set of user paths (2 dim) in a game setup that are modelled as a set of lines (arcs) and waypoints = vertices. The whole set of paths can be seen as a graph where the edges are line segments that have additional properties like length, probability, etc.
Now I have to identify the set of (straight) line segments = edges within a certain distance to the user's current position in order to find the user's position in the graph.
How to implement this as simply as possible without reinventing the wheel? How to implement the search efficiently?
I thought of using boost-graph for handling the graph and to combine it with boost-geometry. E.g. see TrajGraph which 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 to store the line segment as an edge property one could add boost geometry's model::linestring and use boost-geometry's nearest neighbour query to find the line segments. But afaik boost-geometry does not allow to attach properties to linestrings as boost-graph does. Hence how to get the edge(s) from the linestring(s)?
A simple brute-force solution might be to traverse the whole edge-list of the graph and calculate the distance to each line segment. See here and here for how to calculate the distance to a straight line segment.