Exemple #1
0
void
InfoBoxContentNearestAirspaceVertical::Update(InfoBoxData &data)
{
  NearestAirspace nearest = FindNearestVerticalAirspace();
  if (!nearest.IsDefined()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromArrival(nearest.distance);
  data.SetComment(nearest.airspace->GetName());
}
Exemple #2
0
static int
l_airspace_index(lua_State *L)
{
  const char *name = lua_tostring(L, 2);
  if (name == nullptr)
    return 0;
  else if (StringIsEqual(name, "nearest_vertical_distance")) {
    NearestAirspace nearest = NearestAirspace::FindVertical(CommonInterface::Basic(),
                                                            CommonInterface::Calculated(),
                                                            glide_computer->GetAirspaceWarnings(),
                                                            airspace_database);
    if (!nearest.IsDefined()) return 0;
    Lua::Push(L, nearest.distance);
  } else if (StringIsEqual(name, "nearest_vertical_name")) {
    NearestAirspace nearest = NearestAirspace::FindVertical(CommonInterface::Basic(),
                                                            CommonInterface::Calculated(),
                                                            glide_computer->GetAirspaceWarnings(),
                                                            airspace_database);
    if (!nearest.IsDefined()) return 0;
    Lua::Push(L, nearest.airspace->GetName());
  } else if (StringIsEqual(name, "nearest_horizontal_distance")) {
    NearestAirspace nearest = NearestAirspace::FindHorizontal(CommonInterface::Basic(),
                                                              glide_computer->GetAirspaceWarnings(),
                                                              airspace_database);
    if (!nearest.IsDefined()) return 0;
    Lua::Push(L, nearest.distance);
  } else if (StringIsEqual(name, "nearest_horizontal_name")) {
    NearestAirspace nearest = NearestAirspace::FindHorizontal(CommonInterface::Basic(),
                                                              glide_computer->GetAirspaceWarnings(),
                                                              airspace_database);
    if (!nearest.IsDefined()) return 0;
    Lua::Push(L, nearest.airspace->GetName());
  } else
    return 0;

  return 1;
}
Exemple #3
0
 gcc_pure
 bool operator()(const NearestAirspace &a, const NearestAirspace &b) const {
   return !b.IsDefined() || a.distance < b.distance;
 }