const Airspace * Airspaces::find_nearest(const GeoPoint &location, const AirspacePredicate &condition) const { if (empty()) return NULL; const Airspace bb_target(location, task_projection); const int mrange = task_projection.project_range(location, fixed(30000)); const AirspacePredicateAdapter predicate(condition); std::pair<AirspaceTree::const_iterator, AirspaceTree::distance_type> found = airspace_tree.find_nearest_if(bb_target, BBDist(0, mrange), predicate); return found.first != airspace_tree.end() ? &*found.first : NULL; }
const Airspace * Airspaces::FindNearest(const GeoPoint &location, const AirspacePredicate &condition) const { if (IsEmpty()) return nullptr; const Airspace bb_target(location, task_projection); const int projected_range = task_projection.ProjectRangeInteger(location, fixed(30000)); const AirspacePredicateAdapter predicate(condition); std::pair<AirspaceTree::const_iterator, AirspaceTree::distance_type> found = airspace_tree.find_nearest_if(bb_target, BBDist(0, projected_range), predicate); return found.first != airspace_tree.end() ? &*found.first : nullptr; }
/** * \todo document this! * * @param a * @param b * @param dim * * @return Distance on axis */ distance_type operator()(const int a, const int b, const size_t dim) const { return BBDist(dim, max((dim < 2) ? (b - a) : (a - b), 0)); }
/** * Return accumulated distance. * Typically this expects all dimensions to be added * before calculating the distance. * * @return Absolute value (accumulated) distance */ gcc_pure BBDist sqrt() const { return BBDist((int)isqrt4(d)); }