示例#1
0
static void
TestLookups(const Waypoints &waypoints, const GeoPoint &center)
{
  WaypointPtr waypoint;

  ok1((waypoint = waypoints.LookupId(0)) == NULL);
  ok1((waypoint = waypoints.LookupId(1)) != NULL);
  ok1(waypoint->original_id == 0);
  ok1((waypoint = waypoints.LookupId(151)) != NULL);
  ok1(waypoint->original_id == 150);
  ok1((waypoint = waypoints.LookupId(152)) == NULL);
  ok1((waypoint = waypoints.LookupId(160)) == NULL);

  ok1((waypoint = waypoints.LookupLocation(center, fixed(0))) != NULL);
  ok1(waypoint->original_id == 0);

  ok1((waypoint = waypoints.LookupName(_T("Waypoint #5"))) != NULL);
  ok1(waypoint->original_id == 4);

  ok1((waypoint = waypoints.LookupLocation(waypoint->location, fixed(10000))) != NULL);
  ok1(waypoint->original_id == 4);
}
示例#2
0
bool
AutoQNH::CalculateQNH(const NMEAInfo &basic, DerivedInfo &calculated,
                      const Waypoints &way_points)
{
    const Waypoint *next_wp;
    next_wp = way_points.LookupLocation(basic.location, fixed(1000));

    if (next_wp && next_wp->IsAirport())
        CalculateQNH(basic, calculated, next_wp->altitude);
    else if (calculated.terrain_valid)
        CalculateQNH(basic, calculated, calculated.terrain_altitude);
    else
        return false;

    return true;
}