コード例 #1
0
ファイル: Airspace.cpp プロジェクト: damianob/xcsoar
void
InfoBoxContentNearestAirspaceVertical::Update(InfoBoxData &data)
{
  NearestAirspace nearest = FindNearestVerticalAirspace();
  if (!nearest.IsDefined()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromArrival(nearest.distance);
  data.SetComment(nearest.airspace->GetName());
}
コード例 #2
0
ファイル: Airspace.cpp プロジェクト: kwtskran/XCSoar
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;
}
コード例 #3
0
ファイル: NearestAirspace.cpp プロジェクト: Advi42/XCSoar
 gcc_pure
 bool operator()(const NearestAirspace &a, const NearestAirspace &b) const {
   return !b.IsDefined() || a.distance < b.distance;
 }