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; };
107 FGTaxiSegment *getAddress() { return this;};
113 typedef vector<int> intVec;
114 typedef vector<int>::iterator intVecIterator;
116 /***************************************************************************************
118 **************************************************************************************/
125 intVecIterator currNode;
126 intVecIterator currRoute;
129 FGTaxiRoute() { distance = 0; currNode = nodes.begin(); currRoute = routes.begin();};
130 FGTaxiRoute(intVec nds, intVec rts, double dist) {
134 currNode = nodes.begin();
136 bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
137 bool empty () { return nodes.begin() == nodes.end(); };
139 bool next(int *nde, int *rte);
141 void first() { currNode = nodes.begin(); currRoute = routes.begin(); };
142 int size() { return nodes.size(); };
145 typedef vector<FGTaxiRoute> TaxiRouteVector;
146 typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
148 /**************************************************************************************
149 * class FGGroundNetWork
150 *************************************************************************************/
151 class FGGroundNetwork
155 FGTaxiNodeVector nodes;
156 FGTaxiSegmentVector segments;
160 TaxiRouteVector routes;
163 double totalDistance, maxDistance;
165 void printRoutingError(string);
170 void addNode (const FGTaxiNode& node);
171 void addNodes (FGParkingVec *parkings);
172 void addSegment(const FGTaxiSegment& seg);
175 bool exists() { return hasNetwork; };
176 int findNearestNode(double lat, double lon);
177 FGTaxiNode *findNode(int idx);
178 FGTaxiSegment *findSegment(int idx);
179 FGTaxiRoute findShortestRoute(int start, int end);
180 void trace(FGTaxiNode *, int, int, double dist);