| 1 | /** |
| 2 | * routePath.hxx - convert a route to straight line segments, for graphical |
| 3 | * output or display. |
| 4 | */ |
| 5 | |
| 6 | // Written by James Turner, started 2010. |
| 7 | // |
| 8 | // Copyright (C) 2010 Curtis L. Olson |
| 9 | // |
| 10 | // This program is free software; you can redistribute it and/or |
| 11 | // modify it under the terms of the GNU General Public License as |
| 12 | // published by the Free Software Foundation; either version 2 of the |
| 13 | // License, or (at your option) any later version. |
| 14 | // |
| 15 | // This program is distributed in the hope that it will be useful, but |
| 16 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | // General Public License for more details. |
| 19 | // |
| 20 | // You should have received a copy of the GNU General Public License |
| 21 | // along with this program; if not, write to the Free Software |
| 22 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 | |
| 24 | #ifndef FG_ROUTE_PATH_HXX |
| 25 | #define FG_ROUTE_PATH_HXX |
| 26 | |
| 27 | #include <memory> |
| 28 | #include <Navaids/route.hxx> |
| 29 | |
| 30 | namespace flightgear |
| 31 | { |
| 32 | class Hold; |
| 33 | class FlightPlan; |
| 34 | class Via; |
| 35 | |
| 36 | typedef std::vector<SGGeod> SGGeodVec; |
| 37 | } |
| 38 | |
| 39 | class RoutePath |
| 40 | { |
| 41 | public: |
| 42 | RoutePath(const flightgear::FlightPlan* fp); |
| 43 | ~RoutePath(); |
| 44 | |
| 45 | RoutePath(const RoutePath& other); |
| 46 | RoutePath& operator=(const RoutePath& other); |
| 47 | |
| 48 | flightgear::SGGeodVec pathForIndex(int index) const; |
| 49 | |
| 50 | SGGeod positionForIndex(int index) const; |
| 51 | |
| 52 | SGGeod positionForDistanceFrom(int index, double distanceM) const; |
| 53 | |
| 54 | double trackForIndex(int index) const; |
| 55 | |
| 56 | double distanceForIndex(int index) const; |
| 57 | |
| 58 | double distanceBetweenIndices(int from, int to) const; |
| 59 | |
| 60 | private: |
| 61 | class RoutePathPrivate; |
| 62 | |
| 63 | void commonInit(); |
| 64 | |
| 65 | double computeDistanceForIndex(int index) const; |
| 66 | |
| 67 | double distanceForVia(flightgear::Via *via, int index) const; |
| 68 | |
| 69 | |
| 70 | flightgear::SGGeodVec pathForHold(flightgear::Hold* hold) const; |
| 71 | flightgear::SGGeodVec pathForVia(flightgear::Via* via, int index) const; |
| 72 | SGGeod positionAlongVia(flightgear::Via* via, int previousIndex, double distanceM) const; |
| 73 | |
| 74 | void interpolateGreatCircle(const SGGeod& aFrom, const SGGeod& aTo, |
| 75 | flightgear::SGGeodVec& r) const; |
| 76 | |
| 77 | |
| 78 | std::unique_ptr<RoutePathPrivate> d; |
| 79 | }; |
| 80 | |
| 81 | #endif |