1 // groundnet.hxx - A number of classes to handle taxiway
2 // assignments by the AI code
4 // Written by Durk Talsma, started June 2005.
6 // Copyright (C) 2004 Durk Talsma.
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #ifndef _GROUNDNETWORK_HXX_
25 #define _GROUNDNETWORK_HXX_
33 #include "parking.hxx"
35 class FGTaxiSegment; // forward reference
37 typedef vector<FGTaxiSegment> FGTaxiSegmentVector;
38 typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
39 typedef vector<FGTaxiSegment>::iterator FGTaxiSegmentVectorIterator;
40 typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
42 /**************************************************************************************
44 *************************************************************************************/
51 FGTaxiSegmentPointerVector next; // a vector to all the segments leaving from this node
55 FGTaxiNode(double, double, int);
57 void setIndex(int idx) { index = idx;};
58 void setLatitude (double val) { lat = val;};
59 void setLongitude(double val) { lon = val;};
60 void setLatitude (const string& val) { lat = processPosition(val); };
61 void setLongitude(const string& val) { lon = processPosition(val); };
62 void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
64 double getLatitude() { return lat;};
65 double getLongitude(){ return lon;};
67 int getIndex() { return index; };
68 FGTaxiNode *getAddress() { return this;};
69 FGTaxiSegmentPointerVectorIterator getBeginRoute() { return next.begin(); };
70 FGTaxiSegmentPointerVectorIterator getEndRoute() { return next.end(); };
73 typedef vector<FGTaxiNode> FGTaxiNodeVector;
74 typedef vector<FGTaxiNode>::iterator FGTaxiNodeVectorIterator;
76 /***************************************************************************************
78 **************************************************************************************/
91 FGTaxiSegment(FGTaxiNode *, FGTaxiNode *, int);
93 void setIndex (int val) { index = val; };
94 void setStartNodeRef (int val) { startNode = val; };
95 void setEndNodeRef (int val) { endNode = val; };
97 void setStart(FGTaxiNodeVector *nodes);
98 void setEnd (FGTaxiNodeVector *nodes);
99 void setTrackDistance();
101 FGTaxiNode * getEnd() { return end;};
102 double getLength() { return length; };
103 int getIndex() { return index; };
109 typedef vector<int> intVec;
110 typedef vector<int>::iterator intVecIterator;
117 intVecIterator currNode;
120 FGTaxiRoute() { distance = 0; currNode = nodes.begin(); };
121 FGTaxiRoute(intVec nds, double dist) { nodes = nds; distance = dist; currNode = nodes.begin();};
122 bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
123 bool empty () { return nodes.begin() == nodes.end(); };
126 void first() { currNode = nodes.begin(); };
127 int size() { return nodes.size(); };
130 typedef vector<FGTaxiRoute> TaxiRouteVector;
131 typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
133 /**************************************************************************************
134 * class FGGroundNetWork
135 *************************************************************************************/
136 class FGGroundNetwork
140 FGTaxiNodeVector nodes;
141 FGTaxiSegmentVector segments;
144 TaxiRouteVector routes;
147 double totalDistance, maxDistance;
152 void addNode (const FGTaxiNode& node);
153 void addNodes (FGParkingVec *parkings);
154 void addSegment(const FGTaxiSegment& seg);
157 bool exists() { return hasNetwork; };
158 int findNearestNode(double lat, double lon);
159 FGTaxiNode *findNode(int idx);
160 FGTaxiRoute findShortestRoute(int start, int end);
161 void trace(FGTaxiNode *, int, int, double dist);