You need to write a function to find a vertex given a position. The graph type that you have defined uses std::vector to store vertices, so the function will have to iterate through it and compare the queried position to each WayPoint. Something like this could do:
std::pair<WayPointID, bool> find_vertex(const WayPoint& wp, const WayPointGraph& graph)
{
for (WayPointID id = 0; id < boost::num_vertices(graph); ++id)
{
if (equal(graph[id], wp))
return std::make_pair(id, true);
}
return std::make_pair(0, false);
}
Note that the function returns a pair (Id + boolean flag) to indicate whether the search succeeded or not, so you would use it as follows:
bool vertex_found;
WayPointID start;
std::tie (start, vertex_found) = find_vertex(begin, graphe);
if (!vertex_found)
// do something about it
Also the function uses the following to compare positions:
bool equal(const std::pair<float, float>& p1, const std::pair<float, float>& p2)
{
const float EPS = 1e-6;
return (std::fabs(p1.first - p2.first) < EPS &&
std::fabs(p1.second - p2.second) < EPS);
}