Exemplo n.º 1
0
 IntersectingAirspaceVisitorAdapter(const GeoPoint &_loc,
                                    const GeoPoint &_end,
                                    const TaskProjection &_projection,
                                    AirspaceIntersectionVisitor &_visitor)
   :start(_loc), end(_end), projection(&_projection),
    ray(projection->ProjectInteger(start), projection->ProjectInteger(end)),
    visitor(&_visitor) {}
Exemplo n.º 2
0
void
OrderedTaskPoint::UpdateBoundingBox(const TaskProjection &task_projection)
{
  flat_bb = FlatBoundingBox(task_projection.ProjectInteger(GetLocation()));

  for (const auto &i : GetBoundary())
    flat_bb.Expand(task_projection.ProjectInteger(i));

  flat_bb.ExpandByOne(); // add 1 to fix rounding
}
Exemplo n.º 3
0
SearchPoint::SearchPoint(const GeoPoint &loc, const TaskProjection &tp)
  :location(loc), flat_location(tp.ProjectInteger(loc))
#ifndef NDEBUG
  , projected(true)
#endif
{
}
Exemplo n.º 4
0
Airspace::Airspace(const GeoPoint &ll, const GeoPoint &ur,
                   const TaskProjection &task_projection)
  :FlatBoundingBox(task_projection.ProjectInteger(ll),
                   task_projection.ProjectInteger(ur)),
   airspace(nullptr)
{
}
Exemplo n.º 5
0
Airspace::Airspace(const GeoPoint &loc, const TaskProjection &task_projection,
                   const fixed range)
  :FlatBoundingBox(task_projection.ProjectInteger(loc),
                   task_projection.ProjectRangeInteger(loc, range)),
   airspace(nullptr)
{
}
Exemplo n.º 6
0
GeoPoint 
AirspacePolygon::ClosestPoint(const GeoPoint &loc,
                              const TaskProjection &projection) const
{
  const FlatGeoPoint p = projection.ProjectInteger(loc);
  const FlatGeoPoint pb = m_border.NearestPoint(p);
  return projection.Unproject(pb);
}
Exemplo n.º 7
0
void
Waypoint::Project(const TaskProjection &task_projection)
{
  flat_location = task_projection.ProjectInteger(location);

#ifndef NDEBUG
  flat_location_initialised = true;
#endif
}
Exemplo n.º 8
0
void
SearchPoint::Project(const TaskProjection &tp)
{
  flat_location = tp.ProjectInteger(location);

#ifndef NDEBUG
  projected = true;
#endif
}
Exemplo n.º 9
0
bool
RoutePolars::Intersection(const AGeoPoint& origin, const AGeoPoint& destination,
                          const RasterMap* map, const TaskProjection& proj,
                          GeoPoint& intx) const
{
  if (map == nullptr || !map->IsDefined())
    return false;

  RouteLink e(RoutePoint(proj.ProjectInteger(destination),
                         destination.altitude),
              RoutePoint(proj.ProjectInteger(origin), origin.altitude), proj);
  if (!positive(e.d))
    return false;

  const RoughAltitude vh = CalcVHeight(e);
  intx = map->Intersection(origin, (short)(origin.altitude - GetSafetyHeight()),
                           (short)vh, destination);
  return !(intx == destination);
}
Exemplo n.º 10
0
AirspaceIntersectionVector
AirspacePolygon::Intersects(const GeoPoint &start, const GeoPoint &end,
                            const TaskProjection &projection) const
{
  const FlatRay ray(projection.ProjectInteger(start),
                    projection.ProjectInteger(end));

  AirspaceIntersectSort sorter(start, *this);

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

    const FlatRay r_seg(it->GetFlatLocation(), (it + 1)->GetFlatLocation());
    fixed t = ray.DistinctIntersection(r_seg);
    if (!negative(t))
      sorter.add(t, projection.Unproject(ray.Parametric(t)));
  }

  return sorter.all();
}
Exemplo n.º 11
0
FlatGeoPoint
RoutePolars::ReachIntercept(const int index, const AGeoPoint& origin,
                             const RasterMap* map,
                             const TaskProjection& proj) const
{
  const bool valid = map && map->IsDefined();
  const RoughAltitude altitude = origin.altitude - GetSafetyHeight();
  const AGeoPoint m_origin((GeoPoint)origin, altitude);
  const GeoPoint dest = MSLIntercept(index, m_origin, proj);
  const GeoPoint p = valid ?
    map->Intersection(m_origin, (short)altitude, (short)altitude, dest) : dest;
  return proj.ProjectInteger(p);
}
Exemplo n.º 12
0
GeoPoint
RoutePolars::MSLIntercept(const int index, const AGeoPoint& p,
                           const TaskProjection& proj) const
{
  const unsigned safe_index = ((unsigned)index) % ROUTEPOLAR_POINTS;
  const FlatGeoPoint fp = proj.ProjectInteger(p);
  const fixed d = p.altitude * polar_glide.GetPoint(safe_index).inv_gradient;
  const fixed scale = proj.GetApproximateScale();
  const int steps = int(d / scale) + 1;
  int dx, dy;
  RoutePolar::IndexToDXDY(safe_index, dx, dy);
  dx = (dx * steps) >> 7;
  dy = (dy * steps) >> 7;
  const FlatGeoPoint dp(fp.longitude + dx, fp.latitude + dy);
  return proj.Unproject(dp);
}
Exemplo n.º 13
0
bool
RoutePolars::CheckClearance(const RouteLink &e, const RasterMap* map,
                             const TaskProjection &proj, RoutePoint& inp) const
{
  if (!config.IsTerrainEnabled())
    return true;

  GeoPoint int_x;
  int int_h;
  GeoPoint start = proj.Unproject(e.first);
  GeoPoint dest = proj.Unproject(e.second);

  assert(map);

  if (!map->FirstIntersection(start, (int)e.first.altitude, dest,
                              (int)e.second.altitude, (int)CalcVHeight(e),
                              (int)climb_ceiling, (int)GetSafetyHeight(),
                              int_x, int_h))
    return true;

  inp = RoutePoint(proj.ProjectInteger(int_x), RoughAltitude(int_h));
  return false;
}