bool
IsAirspaceAltitudeVisible(const AbstractAirspace &airspace,
                          const AltitudeState &state,
                          const AirspaceComputerSettings &computer_settings,
                          const AirspaceRendererSettings &renderer_settings)
{
  /// @todo airspace visibility did use ToMSL(..., map.Calculated().TerrainAlt); 

  switch (renderer_settings.altitude_mode) {
  case AirspaceDisplayMode::ALLON:
    return true;

  case AirspaceDisplayMode::CLIP:
    return airspace.GetBase().GetAltitude(state) <= fixed(renderer_settings.clip_altitude);

  case AirspaceDisplayMode::AUTO:
    return airspace.GetBase().IsBelow(state, fixed(computer_settings.warnings.altitude_warning_margin))
      && airspace.GetTop().IsAbove(state, fixed(computer_settings.warnings.altitude_warning_margin));

  case AirspaceDisplayMode::ALLBELOW:
    return airspace.GetBase().IsBelow(state, fixed(computer_settings.warnings.altitude_warning_margin));

  case AirspaceDisplayMode::INSIDE:
    return (airspace.GetBase().IsBelow(state) && airspace.GetTop().IsAbove(state));

  case AirspaceDisplayMode::ALLOFF:
    return false;
  }
  return true;
}
Exemple #2
0
 void Visit(const AbstractAirspace &as) {
     if (do_report) {
         *fout << as;
         *fout << "# Name: " << as.GetName()
               << "Base: " << as.GetBase()
               << " Top: " << as.GetTop()
               << "\n";
     }
 }
Exemple #3
0
 virtual bool operator()(const AbstractAirspace &airspace) const {
   return CheckAirspace(airspace) &&
     /* skip airspaces that we already entered */
     !airspace.Inside(location) &&
     /* check altitude; hard-coded margin of 50m (for now) */
     (!altitude_available ||
      (airspace.GetBase().IsBelow(altitude, fixed(50)) &&
       airspace.GetTop().IsAbove(altitude, fixed(50))));
 }
bool
AirspaceVisiblePredicate::IsAltitudeVisible(const AbstractAirspace& airspace) const
{
  /// @todo airspace visibility did use ToMSL(..., map.Calculated().TerrainAlt); 

  switch (renderer_settings.altitude_mode) {
  case ALLON:
    return true;
  case CLIP:
    return airspace.GetBase().GetAltitude(state) <= fixed(renderer_settings.clip_altitude);
  case AUTO:
    return airspace.GetBase().IsBelow(state, fixed(computer_settings.warnings.AltWarningMargin))
      && airspace.GetTop().IsAbove(state, fixed(computer_settings.warnings.AltWarningMargin));
  case ALLBELOW:
    return airspace.GetBase().IsBelow(state, fixed(computer_settings.warnings.AltWarningMargin));
  case INSIDE:
    return (airspace.GetBase().IsBelow(state) && airspace.GetTop().IsAbove(state));

  case ALLOFF:
    return false;
  }
  return true;
}
Exemple #5
0
  void visit_abstract(const AbstractAirspace &as) {
    assert(!m_intersections.empty());

    GeoPoint point = m_intersections[0].first;

    RouteLink l = rpolar.GenerateIntermediate(link.first,
                                               RoutePoint(proj.project(point), link.second.altitude),
                                               proj);

    if (l.second.altitude < RoughAltitude(as.GetBase().altitude) ||
        l.second.altitude > RoughAltitude(as.GetTop().altitude))
      return;

    if (negative(min_distance) || (l.d < min_distance)) {
      min_distance = l.d;
      nearest = std::make_pair(&as, l.second);
    }
  }
  void Check(const AbstractAirspace &airspace) {
    if (!active_predicate(airspace))
      return;

    /* check delta below */
    fixed base = airspace.GetBase().GetAltitude(altitude);
    fixed base_delta = base - altitude.altitude;
    if (!negative(base_delta) && base_delta < fabs(nearest_delta)) {
      nearest = &airspace;
      nearest_delta = base_delta;
    }

    /* check delta above */
    fixed top = airspace.GetTop().GetAltitude(altitude);
    fixed top_delta = altitude.altitude - top;
    if (!negative(top_delta) && top_delta < fabs(nearest_delta)) {
      nearest = &airspace;
      nearest_delta = -top_delta;
    }
  }
Exemple #7
0
  void Visit(const AbstractAirspace &as) override {
    assert(!intersections.empty());

    GeoPoint point = intersections[0].first;

    RouteLink l =
      rpolar.GenerateIntermediate(link.first,
                                  RoutePoint(proj.ProjectInteger(point),
                                             link.second.altitude),
                                  proj);

    if (l.second.altitude < as.GetBase().altitude ||
        l.second.altitude > as.GetTop().altitude)
      return;

    if (min_distance < 0 || l.d < min_distance) {
      min_distance = l.d;
      nearest = std::make_pair(&as, l.second);
    }
  }
bool
AirspacePredicateHeightRange::check_height(const AbstractAirspace& t) const
{
  return (int)t.GetTop().altitude >= h_min &&
         (int)t.GetBase().altitude <= h_max;
}
bool
AirspacePredicateHeightRange::check_height(const AbstractAirspace& t) const
{
  return RoughAltitude(t.GetTop().altitude) >= h_min &&
    RoughAltitude(t.GetBase().altitude) <= h_max;
}
Exemple #10
0
tstring
AirspaceFormatter::GetVerticalText(const AbstractAirspace &airspace)
{
  return _T("Base: ") + airspace.GetBase().GetAsText(false) +
         _T(" Top: ") + airspace.GetTop().GetAsText(false);
}