当前位置: 首页>>代码示例>>C++>>正文


C++ TrafficList::FindTraffic方法代码示例

本文整理汇总了C++中TrafficList::FindTraffic方法的典型用法代码示例。如果您正苦于以下问题:C++ TrafficList::FindTraffic方法的具体用法?C++ TrafficList::FindTraffic怎么用?C++ TrafficList::FindTraffic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TrafficList的用法示例。


在下文中一共展示了TrafficList::FindTraffic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static void
ComputeFlarmTeam(const GeoPoint &location, const GeoPoint &reference_location,
                 const TrafficList &traffic_list, const FlarmId target_id,
                 TeamInfo &teamcode_info)
{
  const FlarmTraffic *traffic = traffic_list.FindTraffic(target_id);
  if (traffic == NULL || !traffic->location_available) {
    teamcode_info.flarm_teammate_code_current = false;
    return;
  }

  // Set Teammate location to FLARM contact location
  teamcode_info.teammate_location = traffic->location;
  teamcode_info.teammate_vector = location.DistanceBearing(traffic->location);
  teamcode_info.teammate_available = true;

  // Calculate distance and bearing from teammate to reference waypoint

  GeoVector v = reference_location.DistanceBearing(traffic->location);

  // Calculate TeamCode and save it in Calculated
  teamcode_info.flarm_teammate_code.Update(v.bearing, v.distance);
  teamcode_info.flarm_teammate_code_available = true;
  teamcode_info.flarm_teammate_code_current = true;
}
开发者ID:snip,项目名称:XCSoar,代码行数:25,代码来源:GlideComputer.cpp

示例2: SetTarget

 void SetTarget(const FlarmId &id) {
   SetTarget(data.FindTraffic(id));
 }
开发者ID:damianob,项目名称:xcsoar,代码行数:3,代码来源:FlarmTrafficWindow.hpp

示例3: ReadBearing

void
ParsePFLAA(NMEAInputLine &line, TrafficList &flarm, double clock)
{
    flarm.modified.Update(clock);

    // PFLAA,<AlarmLevel>,<RelativeNorth>,<RelativeEast>,<RelativeVertical>,
    //   <IDType>,<ID>,<Track>,<TurnRate>,<GroundSpeed>,<ClimbRate>,<AcftType>
    FlarmTraffic traffic;
    traffic.alarm_level = (FlarmTraffic::AlarmType)
                          line.Read((int)FlarmTraffic::AlarmType::NONE);

    double value;
    bool stealth = false;

    if (!line.ReadChecked(value))
        // Relative North is required !
        return;
    traffic.relative_north = value;

    if (!line.ReadChecked(value))
        // Relative East is required !
        return;
    traffic.relative_east = value;

    if (!line.ReadChecked(value))
        // Relative Altitude is required !
        return;
    traffic.relative_altitude = value;

    line.Skip(); /* id type */

    // 5 id, 6 digit hex
    char id_string[16];
    line.Read(id_string, 16);
    traffic.id = FlarmId::Parse(id_string, nullptr);

    Angle track;
    traffic.track_received = ReadBearing(line, track);
    if (!traffic.track_received) {
        // Field is empty in stealth mode
        stealth = true;
        traffic.track = Angle::Zero();
    } else
        traffic.track = track;

    traffic.turn_rate_received = line.ReadChecked(value);
    if (!traffic.turn_rate_received) {
        // Field is empty in stealth mode
        traffic.turn_rate = 0;
    } else
        traffic.turn_rate = value;

    traffic.speed_received = line.ReadChecked(value);
    if (!traffic.speed_received) {
        // Field is empty in stealth mode
        stealth = true;
        traffic.speed = 0;
    } else
        traffic.speed = value;

    traffic.climb_rate_received = line.ReadChecked(value);
    if (!traffic.climb_rate_received) {
        // Field is empty in stealth mode
        stealth = true;
        traffic.climb_rate = 0;
    } else
        traffic.climb_rate = value;

    traffic.stealth = stealth;

    unsigned type = line.Read(0);
    if (type > 15 || type == 14)
        traffic.type = FlarmTraffic::AircraftType::UNKNOWN;
    else
        traffic.type = (FlarmTraffic::AircraftType)type;

    FlarmTraffic *flarm_slot = flarm.FindTraffic(traffic.id);
    if (flarm_slot == nullptr) {
        flarm_slot = flarm.AllocateTraffic();
        if (flarm_slot == nullptr)
            // no more slots available
            return;

        flarm_slot->Clear();
        flarm_slot->id = traffic.id;

        flarm.new_traffic.Update(clock);
    }

    // set time of fix to current time
    flarm_slot->valid.Update(clock);

    flarm_slot->Update(traffic);
}
开发者ID:ahsparrow,项目名称:xcsoar,代码行数:94,代码来源:StaticParser.cpp


注:本文中的TrafficList::FindTraffic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。