예제 #1
0
const SearchPointVector&
AbstractAirspace::GetClearance(const TaskProjection &projection) const
{
  #define RADIUS 5

  if (!m_clearance.empty())
    return m_clearance;

  m_clearance = m_border;
  if (!m_is_convex)
    m_clearance.PruneInterior();

  FlatBoundingBox bb = m_clearance.CalculateBoundingbox();
  FlatGeoPoint center = bb.GetCenter();

  for (auto i= m_clearance.begin(); i != m_clearance.end(); ++i) {
    FlatGeoPoint p = i->get_flatLocation();
    FlatRay r(center, p);
    int mag = r.Magnitude();
    int mag_new = mag + RADIUS;
    p = r.Parametric((fixed)mag_new / mag);
    *i = SearchPoint(projection.unproject(p), p);
  }

  return m_clearance;
}
예제 #2
0
void write_spv (const SearchPointVector& spv)
{
  for (auto v = spv.begin(); v != spv.end(); ++v) {
    write_point(*v, v->get_flatLocation(), "spv");
  }
  printf("spv\n");
  fflush(stdout);
}
예제 #3
0
void write_border (const AbstractAirspace& as)
{
  const SearchPointVector& spv = as.GetPoints();
  for (auto v = spv.begin(); v != spv.end(); ++v)
    write_point(*v, v->get_flatLocation(), "polygon");

  printf("polygon\n");
  write_spv(as.GetClearance());
  fflush(stdout);
}
예제 #4
0
AirspaceIntersectionVector
AirspacePolygon::Intersects(const GeoPoint &start, const GeoPoint &end) const
{
  const FlatRay ray(m_task_projection->project(start),
                    m_task_projection->project(end));

  AirspaceIntersectSort sorter(start, end, *this);

  for (auto it = m_border.begin(); it + 1 != m_border.end(); ++it) {

    const FlatRay r_seg(it->get_flatLocation(), (it + 1)->get_flatLocation());
    fixed t;
    if (ray.IntersectsDistinct(r_seg, t))
      sorter.add(t, m_task_projection->unproject(ray.Parametric(t)));
  }

  return sorter.all();
}
예제 #5
0
 /** 
  * Calculate approximate squared (flat projected) distance between this point
  * and another
  * 
  * @param tp Point to calculate distance to
  * 
  * @return Approximate squared distance
  */
 gcc_pure
 unsigned approx_sq_dist(const TracePoint& tp) const {
   return dsqr(get_flatLocation().Longitude-tp.get_flatLocation().Longitude)+
     dsqr(get_flatLocation().Latitude-tp.get_flatLocation().Latitude);
 }