Пример #1
0
AirspaceIntersectionVector
AirspaceIntersectSort::all()
{
  AirspaceIntersectionVector res;

  GeoPoint p_last = m_start;
  bool waiting = false;
  bool start = true;
  while (!m_q.empty()) {
    const GeoPoint p_this = m_q.top().second;
    const GeoPoint p_mid = start
      ? p_last
      : p_last.Interpolate(p_this, fixed(0.5));

    // when inside, checking midpoint is ok, otherwise we should
    // check just beyond the last location

    if (m_airspace->Inside(p_mid)) {
      res.push_back(std::make_pair(p_last, p_this));
      waiting = false;
    } else {
      if (m_q.top().first >= fixed(1))
        // exit on reaching first point out of range
        break;

      waiting = true;
    }

    // advance
    p_last = p_this;
    m_q.pop();
    start = false;
  }

  // fill last point if not matched 
  if (waiting)
    res.push_back(std::make_pair(p_last, p_last));

  return res;
}
Пример #2
0
bool
AbstractAirspace::Intercept(const AircraftState &state,
                            const GeoPoint &end,
                            const FlatProjection &projection,
                            const AirspaceAircraftPerformance &perf,
                            AirspaceInterceptSolution &solution) const
{
  AirspaceIntersectionVector vis = Intersects(state.location, end,
                                              projection);
  if (vis.empty())
    return false;

  AirspaceInterceptSolution this_solution =
    AirspaceInterceptSolution::Invalid();
  for (const auto &i : vis)
    Intercept(state, perf, this_solution, i.first, i.second);

  if (!this_solution.IsValid())
    return false;

  solution = this_solution;
  return true;
}
bool 
AbstractAirspace::intercept(const AIRCRAFT_STATE &state,
                            const GeoVector& vec,
                            const AirspaceAircraftPerformance& perf,
                            AirspaceInterceptSolution &solution) const
{
  AirspaceIntersectionVector vis = intersects(state.Location, vec);
  if (vis.empty()) {
    return false;
  }

  AirspaceInterceptSolution this_solution;
  for (AirspaceIntersectionVector::const_iterator it = vis.begin();
       it != vis.end(); ++it) {
    intercept(state, perf, this_solution, it->first, it->second);
  }

  if (this_solution.valid()) {
    solution = this_solution;
    return true;
  } else {
    return false;
  }
}