]> git.mxchange.org Git - flightgear.git/blob - src/Airports/gnnode.hxx
Merge branch 'topic/tape' into next
[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 using std::string;
26 using std::vector;
27
28 class FGTaxiSegment;
29 typedef vector<FGTaxiSegment*>  FGTaxiSegmentVector;
30 typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
31
32 bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
33 bool sortByLength     (FGTaxiSegment *a, FGTaxiSegment *b);
34 double processPosition(const string& pos);
35
36 class FGTaxiNode 
37 {
38 private:
39   double lat;
40   double lon;
41   int index;
42
43   bool isOnRunway;
44   int  holdType;
45   FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
46
47   // used in way finding
48   double pathScore;
49   FGTaxiNode* previousNode;
50   FGTaxiSegment* previousSeg;
51
52 public:
53   FGTaxiNode() :
54       lat (0.0),
55       lon (0.0),
56       index(0),
57       isOnRunway(false),
58       holdType(0),
59       pathScore(0),
60       previousNode(0),
61       previousSeg(0)
62 {
63 };
64
65   FGTaxiNode(const FGTaxiNode &other) :
66       lat(other.lat),
67       lon(other.lon),
68       index(other.index),
69       isOnRunway(other.isOnRunway),
70       holdType(other.holdType),
71       next(other.next),
72       pathScore(other.pathScore),
73       previousNode(other.previousNode),
74       previousSeg(other.previousSeg)
75 {
76 };
77
78 FGTaxiNode &operator =(const FGTaxiNode &other)
79 {
80    lat          = other.lat;
81    lon          = other.lon;
82    index        = other.index;
83    isOnRunway   = other.isOnRunway;
84    holdType     = other.holdType;
85    next         = other.next;
86    pathScore    = other.pathScore;
87    previousNode = other.previousNode;
88    previousSeg  = other.previousSeg;
89    return *this;
90 };
91
92   void setIndex(int idx)                  { index = idx;                 };
93   void setLatitude (double val)           { lat = val;                   };
94   void setLongitude(double val)           { lon = val;                   };
95   void setLatitude (const string& val)    { lat = processPosition(val);  };
96   void setLongitude(const string& val)    { lon = processPosition(val);  };
97   void addSegment(FGTaxiSegment *segment) { next.push_back(segment);     };
98   void setHoldPointType(int val)          { holdType = val;              };
99   void setOnRunway(bool val)              { isOnRunway = val;            };
100
101   void setPathScore   (double val)         { pathScore    = val; };
102   void setPreviousNode(FGTaxiNode *val)    { previousNode = val; };
103   void setPreviousSeg (FGTaxiSegment *val) { previousSeg  = val; };
104
105   FGTaxiNode    *getPreviousNode()    { return previousNode; };
106   FGTaxiSegment *getPreviousSegment() { return previousSeg;  };
107
108   double getPathScore() { return pathScore; };
109   double getLatitude() { return lat;};
110   double getLongitude(){ return lon;};
111
112   SGGeod geod() const { return SGGeod::fromDeg(lon, lat); }
113
114   int getIndex() { return index; };
115   int getHoldPointType() { return holdType; };
116   bool getIsOnRunway() { return isOnRunway; };
117
118   FGTaxiNode *getAddress() { return this;};
119   FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
120   FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
121   bool operator<(const FGTaxiNode &other) const { return index < other.index; };
122
123   void sortEndSegments(bool);
124
125 };
126
127 typedef vector<FGTaxiNode*> FGTaxiNodeVector;
128 typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
129
130 #endif