]> git.mxchange.org Git - flightgear.git/blob - src/Airports/gnnode.hxx
Make FGTaxiNode and FGParking inherit FGPositioned.
[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/structure/SGSharedPtr.hxx>
24
25 #include <Navaids/positioned.hxx>
26
27 class FGTaxiSegment;
28
29 typedef std::vector<FGTaxiSegment*>  FGTaxiSegmentVector;
30 typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
31
32 bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
33 bool sortByLength     (FGTaxiSegment *a, FGTaxiSegment *b);
34
35 class FGTaxiNode : public FGPositioned
36 {
37 protected:
38   int index;
39
40   bool isOnRunway;
41   int  holdType;
42   FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
43
44   // used in way finding - should really move to a dynamic struct
45   double pathScore;
46   FGTaxiNode* previousNode;
47   FGTaxiSegment* previousSeg;
48
49
50 public:    
51   FGTaxiNode(PositionedID aGuid, int index, const SGGeod& pos, bool aOnRunway, int aHoldType);
52   virtual ~FGTaxiNode();
53   
54   void setElevation(double val);
55   void addSegment(FGTaxiSegment *segment) { next.push_back(segment);     };
56
57   void setPathScore   (double val)         { pathScore    = val; };
58   void setPreviousNode(FGTaxiNode *val)    { previousNode = val; };
59   void setPreviousSeg (FGTaxiSegment *val) { previousSeg  = val; };
60
61   FGTaxiNode    *getPreviousNode()    { return previousNode; };
62   FGTaxiSegment *getPreviousSegment() { return previousSeg;  };
63
64   double getPathScore() { return pathScore; };
65
66   double getElevationM (double refelev);
67   double getElevationFt(double refelev);
68   
69   int getIndex() const { return index; };
70   int getHoldPointType() const { return holdType; };
71   bool getIsOnRunway() const { return isOnRunway; };
72
73   const FGTaxiSegmentVector& arcs() const
74   { return next; }
75   
76   /// find the arg which leads from this node to another.
77   /// returns NULL if no such arc exists.
78   FGTaxiSegment* getArcTo(FGTaxiNode* aEnd) const;
79   
80   bool operator<(const FGTaxiNode &other) const { return index < other.index; };
81
82
83 };
84
85 typedef SGSharedPtr<FGTaxiNode> FGTaxiNode_ptr;
86 typedef std::vector<FGTaxiNode_ptr> FGTaxiNodeVector;
87 typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
88
89 #endif