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) {}
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 }
SearchPoint::SearchPoint(const GeoPoint &loc, const TaskProjection &tp) :location(loc), flat_location(tp.ProjectInteger(loc)) #ifndef NDEBUG , projected(true) #endif { }
Airspace::Airspace(const GeoPoint &ll, const GeoPoint &ur, const TaskProjection &task_projection) :FlatBoundingBox(task_projection.ProjectInteger(ll), task_projection.ProjectInteger(ur)), airspace(nullptr) { }
Airspace::Airspace(const GeoPoint &loc, const TaskProjection &task_projection, const fixed range) :FlatBoundingBox(task_projection.ProjectInteger(loc), task_projection.ProjectRangeInteger(loc, range)), airspace(nullptr) { }
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); }
void Waypoint::Project(const TaskProjection &task_projection) { flat_location = task_projection.ProjectInteger(location); #ifndef NDEBUG flat_location_initialised = true; #endif }
void SearchPoint::Project(const TaskProjection &tp) { flat_location = tp.ProjectInteger(location); #ifndef NDEBUG projected = true; #endif }
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); }
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(); }
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); }
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); }
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; }