]> git.mxchange.org Git - flightgear.git/blob - src/Airports/gnnode.hxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Airports / gnnode.hxx
1 // This program is free software; you can redistribute it and/or
2 // modify it under the terms of the GNU General Public License as
3 // published by the Free Software Foundation; either version 2 of the
4 // License, or (at your option) any later version.
5 //
6 // This program is distributed in the hope that it will be useful, but
7 // WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9 // General Public License for more details.
10 //
11 // You should have received a copy of the GNU General Public License
12 // along with this program; if not, write to the Free Software
13 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14 //
15
16 #ifndef _GN_NODE_HXX_
17 #define _GN_NODE_HXX_
18
19 #include <vector>
20 #include <string>
21
22 #include <simgear/compiler.h>
23 #include <simgear/math/sg_geodesy.hxx>
24
25 class FGTaxiSegment;
26 typedef std::vector<FGTaxiSegment*>  FGTaxiSegmentVector;
27 typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
28
29 bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
30 bool sortByLength     (FGTaxiSegment *a, FGTaxiSegment *b);
31
32 class FGTaxiNode 
33 {
34 private:
35   SGGeod geod;
36   int index;
37
38   bool isOnRunway;
39   int  holdType;
40   FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
41
42   // used in way finding
43   double pathScore;
44   FGTaxiNode* previousNode;
45   FGTaxiSegment* previousSeg;
46
47 public:
48   FGTaxiNode() :
49       index(0),
50       isOnRunway(false),
51       holdType(0),
52       pathScore(0),
53       previousNode(0),
54       previousSeg(0)
55 {
56 };
57
58   FGTaxiNode(const FGTaxiNode &other) :
59       geod(other.geod),
60       index(other.index),
61       isOnRunway(other.isOnRunway),
62       holdType(other.holdType),
63       next(other.next),
64       pathScore(other.pathScore),
65       previousNode(other.previousNode),
66       previousSeg(other.previousSeg)
67 {
68 };
69
70 FGTaxiNode &operator =(const FGTaxiNode &other)
71 {
72    geod          = other.geod;
73    index        = other.index;
74    isOnRunway   = other.isOnRunway;
75    holdType     = other.holdType;
76    next         = other.next;
77    pathScore    = other.pathScore;
78    previousNode = other.previousNode;
79    previousSeg  = other.previousSeg;
80    return *this;
81 };
82
83   void setIndex(int idx)                  { index = idx;                 };
84   void setLatitude (double val);
85   void setLongitude(double val);
86   void setElevation(double val);
87   void setLatitude (const std::string& val);
88   void setLongitude(const std::string& val);
89   void addSegment(FGTaxiSegment *segment) { next.push_back(segment);     };
90   void setHoldPointType(int val)          { holdType = val;              };
91   void setOnRunway(bool val)              { isOnRunway = val;            };
92
93   void setPathScore   (double val)         { pathScore    = val; };
94   void setPreviousNode(FGTaxiNode *val)    { previousNode = val; };
95   void setPreviousSeg (FGTaxiSegment *val) { previousSeg  = val; };
96
97   FGTaxiNode    *getPreviousNode()    { return previousNode; };
98   FGTaxiSegment *getPreviousSegment() { return previousSeg;  };
99
100   double getPathScore() { return pathScore; };
101   double getLatitude() { return geod.getLatitudeDeg();};
102   double getLongitude(){ return geod.getLongitudeDeg();};
103   double getElevation() { return geod.getElevationM();};
104
105   const SGGeod& getGeod() const { return geod; }
106
107   int getIndex() { return index; };
108   int getHoldPointType() { return holdType; };
109   bool getIsOnRunway() { return isOnRunway; };
110
111   FGTaxiNode *getAddress() { return this;};
112   FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
113   FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
114   bool operator<(const FGTaxiNode &other) const { return index < other.index; };
115
116   //void sortEndSegments(bool);
117
118 };
119
120 typedef std::vector<FGTaxiNode*> FGTaxiNodeVector;
121 typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
122
123 #endif