Esempio n. 1
0
static void
TestRangeVisitor(const Waypoints &waypoints, const GeoPoint &location,
                      fixed distance, unsigned expected_results)
{
  WaypointPredicateCounter::Predicate predicate = CloserThan(distance, location);
  WaypointPredicateCounter distance_counter(predicate);
  waypoints.VisitWithinRange(location, distance, distance_counter);
  ok1(distance_counter.GetCounter() == expected_results);
}
Esempio n. 2
0
static void
FillList(WaypointList &list, const Waypoints &src,
         GeoPoint location, Angle heading, const WaypointFilterData &filter)
{
  list.clear();

  if (!filter.IsDefined() && src.size() >= 500)
    return;

  FilterWaypointVisitor visitor(filter, location, heading, list);

  if (filter.distance_index > 0)
    src.VisitWithinRange(location, Units::ToSysDistance(
        distance_filter_items[filter.distance_index]), visitor);
  else
    src.VisitNamePrefix(filter.name, visitor);

  if (filter.distance_index > 0 || filter.direction_index > 0)
    std::sort(list.begin(), list.end(), WaypointDistanceCompare(location));
}
Esempio n. 3
0
void
MapItemListBuilder::AddWaypoints(const Waypoints &waypoints)
{
  WaypointListBuilderVisitor waypoint_list_builder(list);
  waypoints.VisitWithinRange(location, range, waypoint_list_builder);
}
Esempio n. 4
0
void WaypointListBuilder::Visit(const Waypoints &waypoints) {
  if (filter.distance > 0)
    waypoints.VisitWithinRange(location, filter.distance, *this);
  else
    waypoints.VisitNamePrefix(filter.name, *this);
}