30#include <simgear/math/sg_geodesy.hxx>
31#include <simgear/structure/exception.hxx>
37PolyLine::PolyLine(Type aTy,
const SGGeodVec& aPoints) :
41 assert(!aPoints.empty());
56 assert(aIndex <= m_data.size());
57 return m_data[aIndex];
63 if (aRawPoints.size() < 2) {
67 const double maxDistanceSquaredM = 40000 * 40000;
69 SGVec3d chunkStartCart = SGVec3d::fromGeod(aRawPoints.front());
71 SGGeodVec::const_iterator it = aRawPoints.begin();
73 while (it != aRawPoints.end()) {
74 SGVec3d ptCart = SGVec3d::fromGeod(*it);
75 double d2 = distSqr(chunkStartCart, ptCart);
78 if ((chunk.size() >= 2) && (d2 > maxDistanceSquaredM)) {
80 result.push_back(
new PolyLine(aTy, chunk));
81 chunkStartCart = ptCart;
85 chunk.push_back(*it++);
91 if (chunk.size() > 1) {
92 result.push_back(
new PolyLine(aTy, chunk));
100 return new PolyLine(aTy, aRawPoints);
104 PolyLineList::const_iterator end)
106 flightgear::PolyLineList::const_iterator it;
107 for (it=begin; it != end; ++it) {
108 (*it)->addToSpatialIndex();
121 SGGeodVec::const_iterator it;
122 for (it = m_data.begin(); it != m_data.end(); ++it) {
123 SGVec3d cart = SGVec3d::fromGeod(*it);
124 result.expandBy(cart);
138 {
return (aTy == m_type); }
151 std::set<PolyLineRef> resultSet;
153 SGVec3d cart = SGVec3d::fromGeod(aPos);
154 double cutoffM = aRangeNm * SG_NM_TO_METER;
158 while (!deque.empty()) {
166 for (
auto ref : lines) {
167 if (aFilter.
pass(ref->type())) {
168 resultSet.insert(ref);
174 result.insert(result.end(), resultSet.begin(), resultSet.end());
std::vector< SGGeod > SGGeodVec
virtual bool pass(PolyLine::Type aTy) const
SingleTypeFilter(PolyLine::Type aTy)
Octree node base class, tracks its bounding box and provides various queries relating to it.
void addPolyLine(const PolyLineRef &)
virtual void visitForLines(const SGVec3d &aPos, double aCutoff, PolyLineList &aLines, FindLinesDeque &aQ) const
virtual Node * findNodeForBox(const SGBoxd &box) const
virtual bool pass(Type aTy) const =0
unsigned int numPoints() const
number of points in this line - at least two.
void addToSpatialIndex() const
SGGeod point(unsigned int aIndex) const
static PolyLineList linesNearPos(const SGGeod &aPos, double aRangeNm, Type aTy)
retrieve all the lines within a range of a search point.
static void bulkAddToSpatialIndex(PolyLineList::const_iterator begin, PolyLineList::const_iterator end)
SGBoxd cartesianBox() const
static PolyLineList createChunked(Type aTy, const SGGeodVec &aRawPoints)
create poly line objects from raw input points and a type.
static PolyLineRef create(Type aTy, const SGGeodVec &aRawPoints)
std::deque< Node * > FindLinesDeque
Node * globalTransientOctree()
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
std::vector< PolyLineRef > PolyLineList
std::vector< SGGeod > SGGeodVec
SGSharedPtr< PolyLine > PolyLineRef