2 * Polyline - store geographic line-segments */
4 // Written by James Turner, started 2013.
6 // Copyright (C) 2013 James Turner <zakalawe@mac.com>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef FG_POLY_LINE_HXX
23 #define FG_POLY_LINE_HXX
27 #include <simgear/sg_inlines.h>
28 #include <simgear/structure/SGSharedPtr.hxx>
29 #include <simgear/math/SGMath.hxx>
30 #include <simgear/math/SGBox.hxx>
31 #include <simgear/math/SGGeometryFwd.hxx>
36 typedef std::vector<SGGeod> SGGeodVec;
40 typedef SGSharedPtr<PolyLine> PolyLineRef;
42 typedef std::vector<PolyLineRef> PolyLineList;
45 * @class Store geographical linear data, with a type code.
47 * This is a basic in-memory model of GIS line data, without support for
48 * many features; especially there is no support for per-node attributes.
50 * PolyLines are added to the spatial index and can be queried by passing
51 * a search centre and cutoff distance.
53 class PolyLine : public SGReferenced
62 NATIONAL_BOUNDARY, /// aka a border
63 REGIONAL_BOUNDARY, /// state / province / country / department
67 // airspace types in the future
75 * number of points in this line - at least two.
77 unsigned int numPoints() const;
79 SGGeod point(unsigned int aIndex) const;
81 const SGGeodVec& points() const
85 * create poly line objects from raw input points and a type.
86 * input points will be subdivided so the bounding area of each
87 * polyline stays within some threshold.
90 static PolyLineList createChunked(Type aTy, const SGGeodVec& aRawPoints);
92 static PolyLineRef create(Type aTy, const SGGeodVec& aRawPoints);
94 static void bulkAddToSpatialIndex(const PolyLineList& lines);
97 * retrieve all the lines within a range of a search point.
98 * lines are returned if any point is near the search location.
100 static PolyLineList linesNearPos(const SGGeod& aPos, double aRangeNm, Type aTy);
105 virtual bool pass(Type aTy) const = 0;
108 static PolyLineList linesNearPos(const SGGeod& aPos, double aRangeNm, const TypeFilter& aFilter);
110 SGBoxd cartesianBox() const;
112 void addToSpatialIndex() const;
116 PolyLine(Type aTy, const SGGeodVec& aPoints);
125 } // of namespace flightgear