void AirspaceRoute::Synchronise(const Airspaces &master, const AirspacePredicate &_condition, const AGeoPoint &origin, const AGeoPoint &destination) { // @todo: also synchronise with AirspaceWarningManager to filter out items that are // acknowledged. h_min = std::min((int)origin.altitude, std::min((int)destination.altitude, h_min)); h_max = std::max((int)origin.altitude, std::max((int)destination.altitude, h_max)); // @todo: have margin for h_max to allow for climb AirspacePredicateHeightRangeExcludeTwo h_condition(h_min, h_max, origin, destination); const auto and_condition = MakeAndPredicate(h_condition, AirspacePredicateRef(_condition)); const auto predicate = WrapAirspacePredicate(and_condition); if (m_airspaces.SynchroniseInRange(master, origin.Middle(destination), 0.5 * origin.Distance(destination), predicate)) { if (!m_airspaces.IsEmpty()) dirty = true; } }
void AirspaceRoute::Synchronise(const Airspaces& master, const AGeoPoint& origin, const AGeoPoint& destination) { // @todo: also synchronise with AirspaceWarningManager to filter out items that are // acknowledged. h_min = std::min(origin.altitude, std::min(destination.altitude, h_min)); h_max = std::max(origin.altitude, std::max(destination.altitude, h_max)); // @todo: have margin for h_max to allow for climb AirspacePredicateHeightRangeExcludeTwo condition(h_min, h_max, origin, destination); if (m_airspaces.SynchroniseInRange(master, origin.Middle(destination), Half(origin.Distance(destination)), condition)) { if (m_airspaces.size()) dirty = true; } }
/* $PCAIB,<1>,<2>,<CR><LF> <1> Destination waypoint elevation in meters, format XXXXX (leading zeros will be transmitted) <2> Destination waypoint attribute word, format XXXXX (leading zeros will be transmitted) */ static bool FormatPCAIB(char *buffer, size_t buffer_size, const AGeoPoint& destination) { if (!destination.IsValid()) return false; // Generic waypoint. unsigned flags = 1 << 8; snprintf(buffer, buffer_size, "$PCAIB,%04d,%04u\r\n", (int)destination.altitude, flags); return true; }
/* $GPRMB,<1>,,,,<5>,,,,,<10>,<11>,,<13>*hh<CR><LF> <1> Position Valid (A = valid, V = invalid) <5> Destination waypoint identifier, three digits (leading zeros will be transmitted) <10> Range from present position to distination waypoint, format XXXX.X, nautical miles (leading zeros will be transmitted) <11> Bearing from present position to destination waypoint, format XXX.X, degrees true (leading zeros will be transmitted) <13> Arrival flag <A = arrival, V = not arrival) */ static bool FormatGPRMB(char *buffer, size_t buffer_size, const GeoPoint& here, const AGeoPoint &destination) { if (!here.IsValid() || !destination.IsValid()) return false; const GeoVector vector(here, destination); const bool has_arrived = vector.distance < 1000; // < 1km ? snprintf(buffer, buffer_size, "GPRMB,%c,,,,,,,,,%06.1f,%04.1f,%c", here.IsValid() ? 'A' : 'V', (double)Units::ToUserUnit(vector.distance, Unit::NAUTICAL_MILES), (double)vector.bearing.Degrees(), has_arrived ? 'A' : 'V'); return true; }