本文整理汇总了C++中MoreData::NavAltitudeAvailable方法的典型用法代码示例。如果您正苦于以下问题:C++ MoreData::NavAltitudeAvailable方法的具体用法?C++ MoreData::NavAltitudeAvailable怎么用?C++ MoreData::NavAltitudeAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoreData
的用法示例。
在下文中一共展示了MoreData::NavAltitudeAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fixed
/**
* Reads the current terrain height
*/
void
GlideComputerAirData::TerrainHeight(const MoreData &basic,
TerrainInfo &calculated)
{
if (!basic.location_available || terrain == NULL) {
calculated.terrain_valid = false;
calculated.terrain_altitude = fixed_zero;
calculated.altitude_agl_valid = false;
calculated.altitude_agl = fixed_zero;
return;
}
short Alt = terrain->GetTerrainHeight(basic.location);
if (RasterBuffer::IsSpecial(Alt)) {
if (RasterBuffer::IsWater(Alt))
/* assume water is 0m MSL; that's the best guess */
Alt = 0;
else {
calculated.terrain_valid = false;
calculated.terrain_altitude = fixed_zero;
calculated.altitude_agl_valid = false;
calculated.altitude_agl = fixed_zero;
return;
}
}
calculated.terrain_valid = true;
calculated.terrain_altitude = fixed(Alt);
if (basic.NavAltitudeAvailable()) {
calculated.altitude_agl = basic.nav_altitude - calculated.terrain_altitude;
calculated.altitude_agl_valid = true;
} else
calculated.altitude_agl_valid = false;
}
示例2: point
void
TraceComputer::Update(const ComputerSettings &settings_computer,
const MoreData &basic, const DerivedInfo &calculated)
{
/* time warps are handled by the Trace class */
if (!basic.time_available || !basic.location_available ||
!basic.NavAltitudeAvailable() ||
!calculated.flight.flying)
return;
// either olc or basic trace requires trace_full
if (settings_computer.contest.enable ||
settings_computer.task.enable_trace) {
const TracePoint point(basic);
mutex.Lock();
full.push_back(point);
mutex.Unlock();
// only olc requires trace_sprint
if (settings_computer.contest.enable)
sprint.push_back(point);
}
}
示例3:
/**
* Logs GPS fixes for stats
* @return True if valid fix (fix distance <= 200m), False otherwise
*/
bool
StatsComputer::DoLogging(const MoreData &basic,
const DerivedInfo &calculated)
{
/// @todo consider putting this sanity check inside Parser
bool location_jump = basic.location_available && last_location.IsValid() &&
basic.location.DistanceS(last_location) > 200;
last_location = basic.location_available
? basic.location : GeoPoint::Invalid();
if (location_jump || !basic.location_available)
// prevent bad fixes from being logged or added to OLC store
return false;
if (calculated.flight.flying &&
stats_clock.CheckAdvance(basic.time, PERIOD)) {
flightstats.AddAltitudeTerrain(calculated.flight.flight_time,
calculated.terrain_altitude);
if (basic.NavAltitudeAvailable())
flightstats.AddAltitude(calculated.flight.flight_time,
basic.nav_altitude);
if (calculated.task_stats.IsPirkerSpeedAvailable())
flightstats.AddTaskSpeed(calculated.flight.flight_time,
calculated.task_stats.get_pirker_speed());
}
return true;
}
示例4: NearestAirspace
gcc_pure
NearestAirspace
NearestAirspace::FindHorizontal(const MoreData &basic,
const ProtectedAirspaceWarningManager &airspace_warnings,
const Airspaces &airspace_database)
{
if (!basic.location_available)
/* can't check for airspaces without a GPS fix */
return NearestAirspace();
/* find the nearest airspace */
//consider only active airspaces
const auto outside_and_active =
MakeAndPredicate(ActiveAirspacePredicate(&airspace_warnings),
OutsideAirspacePredicate(AGeoPoint(basic.location, 0)));
//if altitude is available, filter airspaces in same height as airplane
if (basic.NavAltitudeAvailable()) {
/* check altitude; hard-coded margin of 50m (for now) */
const auto outside_and_active_and_height =
MakeAndPredicate(outside_and_active,
AirspacePredicateHeightRange(basic.nav_altitude - 50,
basic.nav_altitude + 50));
const auto predicate = WrapAirspacePredicate(outside_and_active_and_height);
return ::FindHorizontal(basic.location, airspace_database, predicate);
} else {
/* only filter outside and active */
const auto predicate = WrapAirspacePredicate(outside_and_active);
return ::FindHorizontal(basic.location, airspace_database, predicate);
}
}
示例5: HorizontalAirspaceCondition
HorizontalAirspaceCondition(const MoreData &basic,
const DerivedInfo &calculated)
:location(basic.location),
altitude_available(basic.NavAltitudeAvailable())
{
if (altitude_available) {
altitude.altitude = basic.nav_altitude;
altitude.altitude_agl = calculated.altitude_agl;
}
}
示例6:
const AircraftState
ToAircraftState(const MoreData &info, const DerivedInfo &calculated)
{
AircraftState aircraft;
/* SPEED_STATE */
aircraft.ground_speed = info.ground_speed;
aircraft.true_airspeed = info.true_airspeed;
/* ALTITUDE_STATE */
aircraft.altitude = info.NavAltitudeAvailable()
? info.nav_altitude
: 0.;
aircraft.working_band_fraction = calculated.common_stats.height_fraction_working;
aircraft.altitude_agl =
info.NavAltitudeAvailable() && calculated.terrain_valid
? calculated.altitude_agl
: 0.;
/* VARIO_INFO */
aircraft.vario = info.brutto_vario;
aircraft.netto_vario = info.netto_vario;
/* AIRCRAFT_STATE */
aircraft.time = info.time_available ? info.time : -1.;
aircraft.location = info.location_available
? info.location
: GeoPoint::Invalid();
aircraft.track = info.track;
aircraft.g_load = info.acceleration.available
? info.acceleration.g_load
: 1.;
aircraft.wind = calculated.GetWindOrZero();
aircraft.flying = calculated.flight.flying;
return aircraft;
}
示例7: Reset
void
GlideRatioComputer::Compute(const MoreData &basic,
const DerivedInfo &calculated,
VarioInfo &vario_info,
const ComputerSettings &settings)
{
if (!basic.NavAltitudeAvailable()) {
Reset();
vario_info.gr = INVALID_GR;
vario_info.average_gr = 0;
return;
}
if (!last_location_available) {
/* need two consecutive valid locations; if the previous one
wasn't valid, skip this iteration and try the next one */
Reset();
vario_info.gr = INVALID_GR;
vario_info.average_gr = 0;
last_location = basic.location;
last_location_available = basic.location_available;
last_altitude = basic.nav_altitude;
return;
}
if (!basic.location_available.Modified(last_location_available))
return;
auto DistanceFlown = basic.location.DistanceS(last_location);
// Glide ratio over ground
vario_info.gr =
UpdateGR(vario_info.gr, DistanceFlown,
last_altitude - basic.nav_altitude, 0.1);
if (calculated.flight.flying && !calculated.circling) {
if (!gr_calculator_initialised) {
gr_calculator_initialised = true;
gr_calculator.Initialize(settings);
}
gr_calculator.Add((int)DistanceFlown, (int)basic.nav_altitude);
vario_info.average_gr = gr_calculator.Calculate();
} else
gr_calculator_initialised = false;
last_location = basic.location;
last_location_available = basic.location_available;
last_altitude = basic.nav_altitude;
}
示例8: protect
void
TrackingGlue::OnTimer(const MoreData &basic, const DerivedInfo &calculated)
{
#ifdef HAVE_SKYLINES_TRACKING
skylines.Tick(basic);
#endif
#ifdef HAVE_LIVETRACK24
if (!settings.livetrack24.enabled)
/* disabled by configuration */
/* note that we are allowed to read "settings" without locking the
mutex, because the background thread never writes to this
attribute */
return;
if (!basic.time_available || !basic.gps.real || !basic.location_available)
/* can't track without a valid GPS fix */
return;
if (!clock.CheckUpdate(settings.interval * 1000))
/* later */
return;
ScopeLock protect(mutex);
if (IsBusy())
/* still running, skip this submission */
return;
date_time = basic.date_time_utc;
if (!date_time.IsDatePlausible())
/* use "today" if the GPS didn't provide a date */
(BrokenDate &)date_time = BrokenDate::TodayUTC();
location = basic.location;
/* XXX use nav_altitude? */
altitude = basic.NavAltitudeAvailable() && basic.nav_altitude > 0
? (unsigned)basic.nav_altitude
: 0u;
ground_speed = basic.ground_speed_available
? (unsigned)Units::ToUserUnit(basic.ground_speed, Unit::KILOMETER_PER_HOUR)
: 0u;
track = basic.track_available
? basic.track
: Angle::Zero();
last_flying = flying;
flying = calculated.flight.flying;
Trigger();
#endif
}
示例9: UpdateGR
void
GlideComputerAirData::GR(const MoreData &basic, const MoreData &last_basic,
const DerivedInfo &calculated, VarioInfo &vario_info)
{
if (!basic.NavAltitudeAvailable() || !last_basic.NavAltitudeAvailable()) {
vario_info.ld_vario = INVALID_GR;
vario_info.gr = INVALID_GR;
return;
}
if (basic.HasTimeRetreatedSince(last_basic)) {
vario_info.ld_vario = INVALID_GR;
vario_info.gr = INVALID_GR;
}
const bool time_advanced = basic.HasTimeAdvancedSince(last_basic);
if (time_advanced) {
fixed DistanceFlown = basic.location.Distance(last_basic.location);
// Glide ratio over ground
vario_info.gr =
UpdateGR(vario_info.gr, DistanceFlown,
last_basic.nav_altitude - basic.nav_altitude, fixed(0.1));
if (calculated.flight.flying && !calculated.circling)
gr_calculator.Add((int)DistanceFlown, (int)basic.nav_altitude);
}
// Lift / drag instantaneous from vario, updated every reading..
if (basic.total_energy_vario_available && basic.airspeed_available &&
calculated.flight.flying) {
vario_info.ld_vario =
UpdateGR(vario_info.ld_vario, basic.indicated_airspeed,
-basic.total_energy_vario, fixed(0.3));
} else {
vario_info.ld_vario = INVALID_GR;
}
}
示例10: day
void
WarningComputer::Update(const ComputerSettings &settings_computer,
const MoreData &basic,
const DerivedInfo &calculated,
AirspaceWarningsInfo &result)
{
if (!basic.time_available)
return;
const fixed dt = delta_time.Update(basic.time, fixed(1), fixed(20));
if (negative(dt))
/* time warp */
Reset();
if (!positive(dt))
return;
airspaces.SetFlightLevels(settings_computer.pressure);
AirspaceActivity day(calculated.date_time_local.day_of_week);
airspaces.SetActivity(day);
if (!settings_computer.airspace.enable_warnings ||
!basic.location_available || !basic.NavAltitudeAvailable()) {
if (initialised) {
initialised = false;
protected_manager.Clear();
}
return;
}
const AircraftState as = ToAircraftState(basic, calculated);
ProtectedAirspaceWarningManager::ExclusiveLease lease(protected_manager);
lease->SetConfig(settings_computer.airspace.warnings);
if (!initialised) {
initialised = true;
lease->Reset(as);
}
if (lease->Update(as, settings_computer.polar.glide_polar_task,
calculated.task_stats,
calculated.circling,
uround(dt)))
result.latest.Update(basic.clock);
}
示例11: max
void
GlideComputerAirData::MaxHeightGain(const MoreData &basic,
DerivedInfo &calculated)
{
if (!basic.NavAltitudeAvailable() || !calculated.flight.flying)
return;
if (positive(calculated.min_altitude)) {
fixed height_gain = basic.nav_altitude - calculated.min_altitude;
calculated.max_height_gain = max(height_gain, calculated.max_height_gain);
} else {
calculated.min_altitude = basic.nav_altitude;
}
calculated.min_altitude = min(basic.nav_altitude, calculated.min_altitude);
}
示例12: Reach
void
RouteComputer::ProcessRoute(const MoreData &basic, DerivedInfo &calculated,
const GlideSettings &settings,
const RoutePlannerConfig &config,
const GlidePolar &glide_polar,
const GlidePolar &safety_polar)
{
if (!basic.location_available || !basic.NavAltitudeAvailable())
return;
protected_route_planner.SetPolars(settings, glide_polar, safety_polar,
calculated.GetWindOrZero());
Reach(basic, calculated, config);
TerrainWarning(basic, calculated, config);
}
示例13: fixed
void
ThermalBandComputer::Compute(const MoreData &basic,
const DerivedInfo &calculated,
ThermalBandInfo &tbi,
const ComputerSettings &settings)
{
if (!basic.NavAltitudeAvailable())
return;
const fixed h_safety =
settings.task.route_planner.safety_height_terrain +
calculated.GetTerrainBaseFallback();
tbi.working_band_height = basic.TE_altitude - h_safety;
if (negative(tbi.working_band_height)) {
tbi.working_band_fraction = fixed(0);
return;
}
const fixed max_height = tbi.max_thermal_height;
if (positive(max_height))
tbi.working_band_fraction = tbi.working_band_height / max_height;
else
tbi.working_band_fraction = fixed(1);
tbi.working_band_ceiling = std::max(max_height + h_safety,
basic.TE_altitude);
last_vario_available.FixTimeWarp(basic.brutto_vario_available);
if (basic.brutto_vario_available.Modified(last_vario_available)) {
last_vario_available = basic.brutto_vario_available;
// JMW TODO accuracy: Should really work out dt here,
// but i'm assuming constant time steps
if (tbi.max_thermal_height == fixed(0))
tbi.max_thermal_height = tbi.working_band_height;
// only do this if in thermal and have been climbing
if (calculated.circling && calculated.turning &&
positive(calculated.average))
tbi.Add(tbi.working_band_height, basic.brutto_vario);
}
}
示例14:
void
CirclingComputer::MaxHeightGain(const MoreData &basic,
const FlyingState &flight,
CirclingInfo &circling_info)
{
if (!basic.NavAltitudeAvailable() || !flight.flying)
return;
if (min_altitude > 0) {
auto height_gain = basic.nav_altitude - min_altitude;
circling_info.max_height_gain =
std::max(height_gain, circling_info.max_height_gain);
} else {
min_altitude = basic.nav_altitude;
}
min_altitude = std::min(basic.nav_altitude, min_altitude);
}
示例15: UpdateLD
void
GlideComputerAirData::CruiseLD(const MoreData &basic, DerivedInfo &calculated)
{
if (!calculated.circling && basic.NavAltitudeAvailable()) {
if (negative(calculated.cruise_start_time)) {
calculated.cruise_start_location = basic.location;
calculated.cruise_start_altitude = basic.nav_altitude;
calculated.cruise_start_time = basic.time;
} else {
fixed DistanceFlown =
basic.location.Distance(calculated.cruise_start_location);
calculated.cruise_ld =
UpdateLD(calculated.cruise_ld, DistanceFlown,
calculated.cruise_start_altitude - basic.nav_altitude,
fixed_half);
}
}
}