示例#1
0
static void
ComputeFlarmTeam(const GeoPoint &location, const GeoPoint &reference_location,
                 const FlarmState &flarm, const FlarmId target_id,
                 TeamInfo &teamcode_info)
{
  if (!flarm.available) {
    teamcode_info.flarm_teammate_code_current = false;
    return;
  }

  const FlarmTraffic *traffic = flarm.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;
}
示例#2
0
 void SetTarget(const FlarmId &id) {
   SetTarget(data.FindTraffic(id));
 }