]> git.mxchange.org Git - flightgear.git/blob - src/Airports/gnnode.hxx
c64b51fd0fb51248a2d92d97229f3cbaa095b1b5
[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 protected:
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
48 public:
49   FGTaxiNode() :
50       index(0),
51       isOnRunway(false),
52       holdType(0),
53       pathScore(0),
54       previousNode(0),
55       previousSeg(0)
56 {
57 };
58
59   FGTaxiNode(const FGTaxiNode &other) :
60       geod(other.geod),
61       index(other.index),
62       isOnRunway(other.isOnRunway),
63       holdType(other.holdType),
64       next(other.next),
65       pathScore(other.pathScore),
66       previousNode(other.previousNode),
67       previousSeg(other.previousSeg)
68 {
69 };
70
71 FGTaxiNode &operator =(const FGTaxiNode &other)
72 {
73    geod                               = other.geod;
74    index                              = other.index;
75    isOnRunway                         = other.isOnRunway;
76    holdType                           = other.holdType;
77    next                               = other.next;
78    pathScore                          = other.pathScore;
79    previousNode                       = other.previousNode;
80    previousSeg                        = other.previousSeg;
81    return *this;
82 };
83
84   void setIndex(int idx)                  { index = idx;                 };
85   void setLatitude (double val);
86   void setLongitude(double val);
87   void setElevation(double val);
88   void setLatitude (const std::string& val);
89   void setLongitude(const std::string& val);
90   void addSegment(FGTaxiSegment *segment) { next.push_back(segment);     };
91   void setHoldPointType(int val)          { holdType = val;              };
92   void setOnRunway(bool val)              { isOnRunway = val;            };
93
94   void setPathScore   (double val)         { pathScore    = val; };
95   void setPreviousNode(FGTaxiNode *val)    { previousNode = val; };
96   void setPreviousSeg (FGTaxiSegment *val) { previousSeg  = val; };
97
98   FGTaxiNode    *getPreviousNode()    { return previousNode; };
99   FGTaxiSegment *getPreviousSegment() { return previousSeg;  };
100
101   double getPathScore() { return pathScore; };
102   double getLatitude() { return geod.getLatitudeDeg();};
103   double getLongitude(){ return geod.getLongitudeDeg();};
104   double getElevationM (double refelev=0);
105   double getElevationFt(double refelev=0);
106
107   const SGGeod& getGeod() const { return geod; }
108
109   int getIndex() const { return index; };
110   int getHoldPointType() const { return holdType; };
111   bool getIsOnRunway() const { return isOnRunway; };
112
113   FGTaxiNode *getAddress() { return this;};
114   FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
115   FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
116   bool operator<(const FGTaxiNode &other) const { return index < other.index; };
117
118
119 };
120
121 typedef std::vector<FGTaxiNode*> FGTaxiNodeVector;
122 typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
123
124 #endif