]> git.mxchange.org Git - flightgear.git/blob - src/Airports/dynamicloader.cxx
initialize release_keys array
[flightgear.git] / src / Airports / dynamicloader.cxx
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 #include "dynamicloader.hxx"
17
18 FGAirportDynamicsXMLLoader::FGAirportDynamicsXMLLoader(FGAirportDynamics* dyn):
19     XMLVisitor(), _dynamics(dyn) {}
20
21 void  FGAirportDynamicsXMLLoader::startXML () {
22   //cout << "Start XML" << endl;
23 }
24
25 void  FGAirportDynamicsXMLLoader::endXML () {
26   //cout << "End XML" << endl;
27 }
28
29 void  FGAirportDynamicsXMLLoader::startElement (const char * name, const XMLAttributes &atts) {
30   // const char *attval;
31   FGParking park;
32   FGTaxiNode taxiNode;
33   FGTaxiSegment taxiSegment;
34   int index = 0;
35   taxiSegment.setIndex(index);
36   //cout << "Start element " << name << endl;
37   string attname;
38   string value;
39   string gateName;
40   string gateNumber;
41   string attval;
42   string lat;
43   string lon;
44   int holdPointType;
45   
46   if (name == string("Parking"))
47     {
48       for (int i = 0; i < atts.size(); i++)
49         {
50           //cout << "  " << atts.getName(i) << '=' << atts.getValue(i) << endl; 
51           attname = atts.getName(i);
52           if (attname == string("index"))
53             park.setIndex(atoi(atts.getValue(i)));
54           else if (attname == string("type"))
55             park.setType(atts.getValue(i));
56          else if (attname == string("name"))
57            gateName = atts.getValue(i);
58           else if (attname == string("number"))
59             gateNumber = atts.getValue(i);
60           else if (attname == string("lat"))
61            park.setLatitude(atts.getValue(i));
62           else if (attname == string("lon"))
63             park.setLongitude(atts.getValue(i)); 
64           else if (attname == string("heading"))
65             park.setHeading(atof(atts.getValue(i)));
66           else if (attname == string("radius")) {
67             string radius = atts.getValue(i);
68             if (radius.find("M") != string::npos)
69               radius = radius.substr(0, radius.find("M",0));
70             //cerr << "Radius " << radius <<endl;
71             park.setRadius(atof(radius.c_str()));
72           }
73            else if (attname == string("airlineCodes"))
74              park.setCodes(atts.getValue(i));
75         }
76       park.setName((gateName+gateNumber));
77       _dynamics->addParking(park);
78     }
79   if (name == string("node")) 
80     {
81       for (int i = 0; i < atts.size() ; i++)
82         {
83           attname = atts.getName(i);
84           if (attname == string("index"))
85             taxiNode.setIndex(atoi(atts.getValue(i)));
86           if (attname == string("lat"))
87             taxiNode.setLatitude(atts.getValue(i));
88           if (attname == string("lon"))
89             taxiNode.setLongitude(atts.getValue(i));
90           if (attname == string("isOnRunway"))
91             taxiNode.setOnRunway((bool) atoi(atts.getValue(i)));
92           if (attname == string("holdPointType")) {
93             attval = atts.getValue(i);
94             if (attval==string("none")) {
95                 holdPointType=0;
96             } else if (attval==string("normal")) {
97                  holdPointType=1;
98             } else if (attval==string("CAT II/III")) {
99                  holdPointType=3;
100             } else if (attval==string("PushBack")) {
101                  holdPointType=3;
102             }
103             //cerr << "Setting Holding point to " << holdPointType << endl;
104             taxiNode.setHoldPointType(holdPointType);
105           }
106         }
107       _dynamics->getGroundNetwork()->addNode(taxiNode);
108     }
109   if (name == string("arc")) 
110     {
111       taxiSegment.setIndex(++index);
112       for (int i = 0; i < atts.size() ; i++)
113         {
114           attname = atts.getName(i);
115           if (attname == string("begin"))
116             taxiSegment.setStartNodeRef(atoi(atts.getValue(i)));
117           if (attname == string("end"))
118             taxiSegment.setEndNodeRef(atoi(atts.getValue(i)));
119           if (attname == string("isPushBackRoute"))
120             taxiSegment.setPushBackType((bool) atoi(atts.getValue(i)));
121         }
122       _dynamics->getGroundNetwork()->addSegment(taxiSegment);
123     }
124   // sort by radius, in asending order, so that smaller gates are first in the list
125 }
126
127 void  FGAirportDynamicsXMLLoader::endElement (const char * name) {
128   //cout << "End element " << name << endl;
129
130 }
131
132 void  FGAirportDynamicsXMLLoader::data (const char * s, int len) {
133   string token = string(s,len);
134   //cout << "Character data " << string(s,len) << endl;
135   //if ((token.find(" ") == string::npos && (token.find('\n')) == string::npos))
136     //value += token;
137   //else
138     //value = string("");
139 }
140
141 void  FGAirportDynamicsXMLLoader::pi (const char * target, const char * data) {
142   //cout << "Processing instruction " << target << ' ' << data << endl;
143 }
144
145 void  FGAirportDynamicsXMLLoader::warning (const char * message, int line, int column) {
146   SG_LOG(SG_IO, SG_WARN, "Warning: " << message << " (" << line << ',' << column << ')');
147 }
148
149 void  FGAirportDynamicsXMLLoader::error (const char * message, int line, int column) {
150   SG_LOG(SG_IO, SG_ALERT, "Error: " << message << " (" << line << ',' << column << ')');
151 }