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_
27 #include <simgear/compiler.h>
35 #include "parking.hxx"
37 class FGTaxiSegment; // forward reference
39 typedef vector<FGTaxiSegment> FGTaxiSegmentVector;
40 typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
41 typedef vector<FGTaxiSegment>::iterator FGTaxiSegmentVectorIterator;
42 typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
44 /**************************************************************************************
46 *************************************************************************************/
53 FGTaxiSegmentPointerVector next; // a vector to all the segments leaving from this node
57 FGTaxiNode(double, double, int);
59 void setIndex(int idx) { index = idx;};
60 void setLatitude (double val) { lat = val;};
61 void setLongitude(double val) { lon = val;};
62 void setLatitude (const string& val) { lat = processPosition(val); };
63 void setLongitude(const string& val) { lon = processPosition(val); };
64 void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
66 double getLatitude() { return lat;};
67 double getLongitude(){ return lon;};
69 int getIndex() { return index; };
70 FGTaxiNode *getAddress() { return this;};
71 FGTaxiSegmentPointerVectorIterator getBeginRoute() { return next.begin(); };
72 FGTaxiSegmentPointerVectorIterator getEndRoute() { return next.end(); };
75 typedef vector<FGTaxiNode> FGTaxiNodeVector;
76 typedef vector<FGTaxiNode>::iterator FGTaxiNodeVectorIterator;
78 /***************************************************************************************
80 **************************************************************************************/
93 FGTaxiSegment(FGTaxiNode *, FGTaxiNode *, int);
95 void setIndex (int val) { index = val; };
96 void setStartNodeRef (int val) { startNode = val; };
97 void setEndNodeRef (int val) { endNode = val; };
99 void setStart(FGTaxiNodeVector *nodes);
100 void setEnd (FGTaxiNodeVector *nodes);
101 void setTrackDistance();
103 FGTaxiNode * getEnd() { return end;};
104 double getLength() { return length; };
105 int getIndex() { return index; };
111 typedef vector<int> intVec;
112 typedef vector<int>::iterator intVecIterator;
119 intVecIterator currNode;
122 FGTaxiRoute() { distance = 0; currNode = nodes.begin(); };
123 FGTaxiRoute(intVec nds, double dist) { nodes = nds; distance = dist; currNode = nodes.begin();};
124 bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
125 bool empty () { return nodes.begin() == nodes.end(); };
128 void first() { currNode = nodes.begin(); };
129 int size() { return nodes.size(); };
132 typedef vector<FGTaxiRoute> TaxiRouteVector;
133 typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
135 /**************************************************************************************
136 * class FGGroundNetWork
137 *************************************************************************************/
138 class FGGroundNetwork
142 FGTaxiNodeVector nodes;
143 FGTaxiSegmentVector segments;
146 TaxiRouteVector routes;
149 double totalDistance, maxDistance;
154 void addNode (const FGTaxiNode& node);
155 void addNodes (FGParkingVec *parkings);
156 void addSegment(const FGTaxiSegment& seg);
159 bool exists() { return hasNetwork; };
160 int findNearestNode(double lat, double lon);
161 FGTaxiNode *findNode(int idx);
162 FGTaxiRoute findShortestRoute(int start, int end);
163 void trace(FGTaxiNode *, int, int, double dist);