]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/route.cxx
Expose waypoint source (airport/runway/navaid) to Nasal
[flightgear.git] / src / Navaids / route.cxx
1 // route.cxx - classes supporting waypoints and route structures
2
3 // Written by James Turner, started 2009.
4 //
5 // Copyright (C) 2009  Curtis L. Olson
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
24
25 #include "route.hxx"
26
27 // std
28 #include <map>
29 #include <fstream>
30
31 // Boost
32 #include <boost/algorithm/string/case_conv.hpp>
33 #include <boost/algorithm/string.hpp>
34
35 // SimGear
36 #include <simgear/structure/exception.hxx>
37 #include <simgear/xml/easyxml.hxx>
38 #include <simgear/misc/sg_path.hxx>
39 #include <simgear/magvar/magvar.hxx>
40 #include <simgear/timing/sg_time.hxx>
41
42 // FlightGear
43 #include <Main/globals.hxx>
44 #include <Navaids/procedure.hxx>
45 #include <Navaids/waypoint.hxx>
46 #include <Airports/simple.hxx>
47
48 using std::string;
49 using std::vector;
50 using std::endl;
51 using std::fstream;
52
53 namespace flightgear {
54
55 const double NO_MAG_VAR = -1000.0; // an impossible mag-var value
56
57 Waypt::Waypt(Route* aOwner) :
58   _altitudeFt(0.0),
59   _speed(0.0),
60   _altRestrict(RESTRICT_NONE),
61   _speedRestrict(RESTRICT_NONE),
62   _owner(aOwner),
63   _flags(0),
64   _magVarDeg(NO_MAG_VAR)
65 {
66 }
67
68 Waypt::~Waypt()
69 {
70 }
71   
72 std::string Waypt::ident() const
73 {
74   return "";
75 }
76   
77 bool Waypt::flag(WayptFlag aFlag) const
78 {
79   return ((_flags & aFlag) != 0);
80 }
81         
82 void Waypt::setFlag(WayptFlag aFlag, bool aV)
83 {
84   _flags = (_flags & ~aFlag);
85   if (aV) _flags |= aFlag;
86 }
87
88 bool Waypt::matches(Waypt* aOther) const
89 {
90   assert(aOther);
91   if (ident() != aOther->ident()) { // cheap check first
92     return false;
93   }
94   
95   return matches(aOther->position());
96 }
97
98
99 bool Waypt::matches(const SGGeod& aPos) const
100 {
101   double d = SGGeodesy::distanceM(position(), aPos);
102   return (d < 100.0); // 100 metres seems plenty
103 }
104
105 void Waypt::setAltitude(double aAlt, RouteRestriction aRestrict)
106 {
107   _altitudeFt = aAlt;
108   _altRestrict = aRestrict;
109 }
110
111 void Waypt::setSpeed(double aSpeed, RouteRestriction aRestrict)
112 {
113   _speed = aSpeed;
114   _speedRestrict = aRestrict;
115 }
116
117 double Waypt::speedKts() const
118 {
119   assert(_speedRestrict != SPEED_RESTRICT_MACH);
120   return speed();
121 }
122   
123 double Waypt::speedMach() const
124 {
125   assert(_speedRestrict == SPEED_RESTRICT_MACH);
126   return speed();
127 }
128   
129 std::pair<double, double>
130 Waypt::courseAndDistanceFrom(const SGGeod& aPos) const
131 {
132   if (flag(WPT_DYNAMIC)) {
133     return std::make_pair(0.0, 0.0);
134   }
135   
136   double course, az2, distance;
137   SGGeodesy::inverse(aPos, position(), course, az2, distance);
138   return std::make_pair(course, distance);
139 }
140
141 double Waypt::magvarDeg() const
142 {
143   if (_magVarDeg == NO_MAG_VAR) {
144     // derived classes with a default pos must override this method
145     assert(!(position() == SGGeod()));
146     
147     double jd = globals->get_time_params()->getJD();
148     _magVarDeg = sgGetMagVar(position(), jd) * SG_RADIANS_TO_DEGREES;
149   }
150   
151   return _magVarDeg;
152 }
153   
154 double Waypt::headingRadialDeg() const
155 {
156   return 0.0;
157 }
158   
159 ///////////////////////////////////////////////////////////////////////////
160 // persistence
161
162 static RouteRestriction restrictionFromString(const char* aStr)
163 {
164   std::string l = boost::to_lower_copy(std::string(aStr));
165
166   if (l == "at") return RESTRICT_AT;
167   if (l == "above") return RESTRICT_ABOVE;
168   if (l == "below") return RESTRICT_BELOW;
169   if (l == "none") return RESTRICT_NONE;
170   if (l == "mach") return SPEED_RESTRICT_MACH;
171   
172   if (l.empty()) return RESTRICT_NONE;
173   throw sg_io_exception("unknown restriction specification:" + l, 
174     "Route restrictFromString");
175 }
176
177 static const char* restrictionToString(RouteRestriction aRestrict)
178 {
179   switch (aRestrict) {
180   case RESTRICT_AT: return "at";
181   case RESTRICT_BELOW: return "below";
182   case RESTRICT_ABOVE: return "above";
183   case RESTRICT_NONE: return "none";
184   case SPEED_RESTRICT_MACH: return "mach";
185   
186   default:
187     throw sg_exception("invalid route restriction",
188       "Route restrictToString");
189   }
190 }
191
192 Waypt* Waypt::createInstance(Route* aOwner, const std::string& aTypeName)
193 {
194   Waypt* r = NULL;
195   if (aTypeName == "basic") {
196     r = new BasicWaypt(aOwner);
197   } else if (aTypeName == "navaid") {
198     r = new NavaidWaypoint(aOwner);
199   } else if (aTypeName == "offset-navaid") {
200     r = new OffsetNavaidWaypoint(aOwner);
201   } else if (aTypeName == "hold") {
202     r = new Hold(aOwner);
203   } else if (aTypeName == "runway") {
204     r = new RunwayWaypt(aOwner);
205   } else if (aTypeName == "hdgToAlt") {
206     r = new HeadingToAltitude(aOwner);
207   } else if (aTypeName == "dmeIntercept") {
208     r = new DMEIntercept(aOwner);
209   } else if (aTypeName == "radialIntercept") {
210     r = new RadialIntercept(aOwner);
211   } else if (aTypeName == "vectors") {
212     r = new ATCVectors(aOwner);
213   } 
214
215   if (!r || (r->type() != aTypeName)) {
216     throw sg_exception("broken factory method for type:" + aTypeName,
217       "Waypt::createInstance");
218   }
219   
220   return r;
221 }
222
223 WayptRef Waypt::createFromProperties(Route* aOwner, SGPropertyNode_ptr aProp)
224 {
225   if (!aProp->hasChild("type")) {
226     throw sg_io_exception("bad props node, no type provided", 
227       "Waypt::createFromProperties");
228   }
229   
230   WayptRef nd(createInstance(aOwner, aProp->getStringValue("type")));
231   nd->initFromProperties(aProp);
232   return nd;
233 }
234   
235 void Waypt::saveAsNode(SGPropertyNode* n) const
236 {
237   n->setStringValue("type", type());
238   writeToProperties(n);
239 }
240
241 void Waypt::initFromProperties(SGPropertyNode_ptr aProp)
242 {
243   if (aProp->hasChild("generated")) {
244     setFlag(WPT_GENERATED, aProp->getBoolValue("generated")); 
245   }
246   
247   if (aProp->hasChild("overflight")) {
248     setFlag(WPT_OVERFLIGHT, aProp->getBoolValue("overflight")); 
249   }
250   
251   if (aProp->hasChild("arrival")) {
252     setFlag(WPT_ARRIVAL, aProp->getBoolValue("arrival")); 
253   }
254   
255   if (aProp->hasChild("departure")) {
256     setFlag(WPT_DEPARTURE, aProp->getBoolValue("departure")); 
257   }
258   
259   if (aProp->hasChild("miss")) {
260     setFlag(WPT_MISS, aProp->getBoolValue("miss")); 
261   }
262   
263   if (aProp->hasChild("alt-restrict")) {
264     _altRestrict = restrictionFromString(aProp->getStringValue("alt-restrict"));
265     _altitudeFt = aProp->getDoubleValue("altitude-ft");
266   }
267   
268   if (aProp->hasChild("speed-restrict")) {
269     _speedRestrict = restrictionFromString(aProp->getStringValue("speed-restrict"));
270     _speed = aProp->getDoubleValue("speed");
271   }
272   
273   
274 }
275
276 void Waypt::writeToProperties(SGPropertyNode_ptr aProp) const
277 {
278   if (flag(WPT_OVERFLIGHT)) {
279     aProp->setBoolValue("overflight", true);
280   }
281
282   if (flag(WPT_DEPARTURE)) {
283     aProp->setBoolValue("departure", true);
284   }
285   
286   if (flag(WPT_ARRIVAL)) {
287     aProp->setBoolValue("arrival", true);
288   }
289   
290   if (flag(WPT_MISS)) {
291     aProp->setBoolValue("miss", true);
292   }
293   
294   if (flag(WPT_GENERATED)) {
295     aProp->setBoolValue("generated", true);
296   }
297   
298   if (_altRestrict != RESTRICT_NONE) {
299     aProp->setStringValue("alt-restrict", restrictionToString(_altRestrict));
300     aProp->setDoubleValue("altitude-ft", _altitudeFt);
301   }
302   
303   if (_speedRestrict != RESTRICT_NONE) {
304     aProp->setStringValue("speed-restrict", restrictionToString(_speedRestrict));
305     aProp->setDoubleValue("speed", _speed);
306   }
307 }
308
309 void Route::dumpRouteToFile(const WayptVec& aRoute, const std::string& aName)
310 {
311   SGPath p = "/Users/jmt/Desktop/" + aName + ".kml";
312   std::fstream f;
313   f.open(p.str().c_str(), fstream::out | fstream::app);
314   if (!f.is_open()) {
315     SG_LOG(SG_GENERAL, SG_WARN, "unable to open:" << p.str());
316     return;
317   }
318   
319 // pre-amble
320   f << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
321       "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
322     "<Document>\n";
323
324   dumpRouteToLineString(aName, aRoute, f);
325   
326 // post-amble
327   f << "</Document>\n" 
328     "</kml>" << endl;
329   f.close();
330 }
331
332 void Route::dumpRouteToLineString(const std::string& aIdent,
333   const WayptVec& aRoute, std::ostream& aStream)
334 {
335   // preamble
336   aStream << "<Placemark>\n";
337   aStream << "<name>" << aIdent << "</name>\n";
338   aStream << "<LineString>\n";
339   aStream << "<tessellate>1</tessellate>\n";
340   aStream << "<coordinates>\n";
341   
342   // waypoints
343   for (unsigned int i=0; i<aRoute.size(); ++i) {
344     SGGeod pos = aRoute[i]->position();
345     aStream << pos.getLongitudeDeg() << "," << pos.getLatitudeDeg() << " " << endl;
346   }
347   
348   // postable
349   aStream << "</coordinates>\n"
350     "</LineString>\n"
351     "</Placemark>\n" << endl;
352 }
353
354 ///////////////////////////////////////////////////////////////////////////
355
356 class NavdataVisitor : public XMLVisitor {
357 public:
358   NavdataVisitor(FGAirport* aApt, const SGPath& aPath);
359
360 protected:
361   virtual void startXML (); 
362   virtual void endXML   ();
363   virtual void startElement (const char * name, const XMLAttributes &atts);
364   virtual void endElement (const char * name);
365   virtual void data (const char * s, int len);
366   virtual void pi (const char * target, const char * data);
367   virtual void warning (const char * message, int line, int column);
368   virtual void error (const char * message, int line, int column);
369
370 private:
371   Waypt* buildWaypoint();
372   void processRunways(ArrivalDeparture* aProc, const XMLAttributes &atts);
373  
374   void finishApproach();
375   void finishSid();
376   void finishStar();
377   
378   FGAirport* _airport;
379   SGPath _path;
380   string _text; ///< last element text value
381   
382   SID* _sid;
383   STAR* _star;
384   Approach* _approach;
385
386   WayptVec _waypoints; ///< waypoint list for current approach/sid/star
387   WayptVec _transWaypts; ///< waypoint list for current transition
388   
389   string _wayptName;
390   string _wayptType;
391   string _ident; // id of segment under construction
392   string _transIdent;
393   double _longitude, _latitude, _altitude, _speed;
394   RouteRestriction _altRestrict;
395   
396   double _holdRadial; // inbound hold radial, or -1 if radial is 'inbound'
397   double _holdTD; ///< hold time (seconds) or distance (nm), based on flag below
398   bool _holdRighthanded;
399   bool _holdDistance; // true, TD is distance in nm; false, TD is time in seconds
400   
401   double _course, _radial, _dmeDistance;
402 };
403
404 void Route::loadAirportProcedures(const SGPath& aPath, FGAirport* aApt)
405 {
406   assert(aApt);
407   try {
408     NavdataVisitor visitor(aApt, aPath);
409     readXML(aPath.str(), visitor);
410   } catch (sg_io_exception& ex) {
411     SG_LOG(SG_GENERAL, SG_WARN, "failured parsing procedures: " << aPath.str() <<
412       "\n\t" << ex.getMessage() << "\n\tat:" << ex.getLocation().asString());
413   } catch (sg_exception& ex) {
414     SG_LOG(SG_GENERAL, SG_WARN, "failured parsing procedures: " << aPath.str() <<
415       "\n\t" << ex.getMessage());
416   }
417 }
418
419 NavdataVisitor::NavdataVisitor(FGAirport* aApt, const SGPath& aPath):
420   _airport(aApt),
421   _path(aPath),
422   _sid(NULL),
423   _star(NULL),
424   _approach(NULL)
425 {
426 }
427
428 void NavdataVisitor::startXML()
429 {
430 }
431
432 void NavdataVisitor::endXML()
433 {
434 }
435
436 void NavdataVisitor::startElement(const char* name, const XMLAttributes &atts)
437 {
438   _text.clear();
439   string tag(name);
440   if (tag == "Airport") {
441     string icao(atts.getValue("ICAOcode"));
442     if (_airport->ident() != icao) {
443       throw sg_format_exception("Airport and ICAO mismatch", icao, _path.str());
444     }
445   } else if (tag == "Sid") {
446     string ident(atts.getValue("Name"));
447     _sid = new SID(ident);
448     _waypoints.clear();
449     processRunways(_sid, atts);
450   } else if (tag == "Star") {
451     string ident(atts.getValue("Name"));
452     _star = new STAR(ident);
453     _waypoints.clear();
454     processRunways(_star, atts);
455   } else if ((tag == "Sid_Waypoint") ||
456       (tag == "App_Waypoint") ||
457       (tag == "Star_Waypoint") ||
458       (tag == "AppTr_Waypoint") ||
459       (tag == "SidTr_Waypoint") ||
460       (tag == "RwyTr_Waypoint"))
461   {
462     // reset waypoint data
463     _speed = 0.0;
464     _altRestrict = RESTRICT_NONE;
465     _altitude = 0.0;
466   } else if (tag == "Approach") {
467     _ident = atts.getValue("Name");
468     _waypoints.clear();
469     _approach = new Approach(_ident);
470   } else if ((tag == "Sid_Transition") || 
471              (tag == "App_Transition") ||
472              (tag == "Star_Transition")) {
473     _transIdent = atts.getValue("Name");
474     _transWaypts.clear();
475   } else if (tag == "RunwayTransition") {
476     _transIdent = atts.getValue("Runway");
477     _transWaypts.clear();
478   } else {
479     
480   }
481 }
482
483 void NavdataVisitor::processRunways(ArrivalDeparture* aProc, const XMLAttributes &atts)
484 {
485   string v("All");
486   if (atts.hasAttribute("Runways")) {
487     v = atts.getValue("Runways");
488   }
489   
490   if (v == "All") {
491     for (unsigned int r=0; r<_airport->numRunways(); ++r) {
492       aProc->addRunway(_airport->getRunwayByIndex(r));
493     }
494     return;
495   }
496   
497   vector<string> rwys;
498   boost::split(rwys, v, boost::is_any_of(" ,"));
499   for (unsigned int r=0; r<rwys.size(); ++r) {
500     FGRunway* rwy = _airport->getRunwayByIdent(rwys[r]);
501     aProc->addRunway(rwy);
502   }
503 }
504
505 void NavdataVisitor::endElement(const char* name)
506 {
507   string tag(name);
508   if ((tag == "Sid_Waypoint") ||
509       (tag == "App_Waypoint") ||
510       (tag == "Star_Waypoint"))
511   {
512     _waypoints.push_back(buildWaypoint());
513   } else if ((tag == "AppTr_Waypoint") || 
514              (tag == "SidTr_Waypoint") ||
515              (tag == "RwyTr_Waypoint") ||
516              (tag == "StarTr_Waypoint")) 
517   {
518     _transWaypts.push_back(buildWaypoint());
519   } else if (tag == "Sid_Transition") {
520     assert(_sid);
521     // SID waypoints are stored backwards, to share code with STARs
522     std::reverse(_transWaypts.begin(), _transWaypts.end());
523     Transition* t = new Transition(_transIdent, _sid, _transWaypts);
524     _sid->addTransition(t);
525   } else if (tag == "Star_Transition") {
526     assert(_star);
527     Transition* t = new Transition(_transIdent, _star, _transWaypts);
528     _star->addTransition(t);
529   } else if (tag == "App_Transition") {
530     assert(_approach);
531     Transition* t = new Transition(_transIdent, _approach, _transWaypts);
532     _approach->addTransition(t);
533   } else if (tag == "RunwayTransition") {
534     ArrivalDeparture* ad;
535     if (_sid) {
536       // SID waypoints are stored backwards, to share code with STARs
537       std::reverse(_transWaypts.begin(), _transWaypts.end());
538       ad = _sid;
539     } else {
540       ad = _star;
541     }
542     
543     Transition* t = new Transition(_transIdent, ad, _transWaypts);
544     FGRunwayRef rwy = _airport->getRunwayByIdent(_transIdent);
545     ad->addRunwayTransition(rwy, t);
546   } else if (tag == "Approach") {
547     finishApproach();
548   } else if (tag == "Sid") {
549     finishSid();
550   } else if (tag == "Star") {
551     finishStar();  
552   } else if (tag == "Longitude") {
553     _longitude = atof(_text.c_str());
554   } else if (tag == "Latitude") {
555     _latitude = atof(_text.c_str());
556   } else if (tag == "Name") {
557     _wayptName = _text;
558   } else if (tag == "Type") {
559     _wayptType = _text;
560   } else if (tag == "Speed") {
561     _speed = atoi(_text.c_str());
562   } else if (tag == "Altitude") {
563     _altitude = atof(_text.c_str());
564   } else if (tag == "AltitudeRestriction") {
565     if (_text == "at") {
566       _altRestrict = RESTRICT_AT;
567     } else if (_text == "above") {
568       _altRestrict = RESTRICT_ABOVE;
569     } else if (_text == "below") {
570       _altRestrict = RESTRICT_BELOW;
571     } else {
572       throw sg_format_exception("Unrecognized altitude restriction", _text);
573     }
574   } else if (tag == "Hld_Rad_or_Inbd") {
575     if (_text == "Inbd") {
576       _holdRadial = -1.0;
577     }
578   } else if (tag == "Hld_Time_or_Dist") {
579     _holdDistance = (_text == "Dist");
580   } else if (tag == "Hld_Rad_value") {
581     _holdRadial = atof(_text.c_str());
582   } else if (tag == "Hld_Turn") {
583     _holdRighthanded = (_text == "Right");
584   } else if (tag == "Hld_td_value") {
585     _holdTD = atof(_text.c_str());
586   } else if (tag == "Hdg_Crs_value") {
587     _course = atof(_text.c_str());
588   } else if (tag == "DMEtoIntercept") {
589     _dmeDistance = atof(_text.c_str());
590   } else if (tag == "RadialtoIntercept") {
591     _radial = atof(_text.c_str());
592   } else {
593     
594   }
595 }
596
597 Waypt* NavdataVisitor::buildWaypoint()
598 {
599   Waypt* wp = NULL;
600   if (_wayptType == "Normal") {
601     // new LatLonWaypoint
602     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude));
603     wp = new BasicWaypt(pos, _wayptName, NULL);
604   } else if (_wayptType == "Runway") {
605     string ident = _wayptName.substr(2);
606     FGRunwayRef rwy = _airport->getRunwayByIdent(ident);
607     wp = new RunwayWaypt(rwy, NULL);
608   } else if (_wayptType == "Hold") {
609     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude));
610     Hold* h = new Hold(pos, _wayptName, NULL);
611     wp = h;
612     if (_holdRighthanded) {
613       h->setRightHanded();
614     } else {
615       h->setLeftHanded();
616     }
617     
618     if (_holdDistance) {
619       h->setHoldDistance(_holdTD);
620     } else {
621       h->setHoldTime(_holdTD * 60.0);
622     }
623     
624     if (_holdRadial >= 0.0) {
625       h->setHoldRadial(_holdRadial);
626     }
627   } else if (_wayptType == "Vectors") {
628     wp = new ATCVectors(NULL, _airport);
629   } else if ((_wayptType == "Intc") || (_wayptType == "VorRadialIntc")) {
630     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude));
631     wp = new RadialIntercept(NULL, _wayptName, pos, _course, _radial);
632   } else if (_wayptType == "DmeIntc") {
633     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude));
634     wp = new DMEIntercept(NULL, _wayptName, pos, _course, _dmeDistance);
635   } else if (_wayptType == "ConstHdgtoAlt") {
636     wp = new HeadingToAltitude(NULL, _wayptName, _course);
637   } else {
638     SG_LOG(SG_GENERAL, SG_ALERT, "implement waypoint type:" << _wayptType);
639     throw sg_format_exception("Unrecognized waypt type", _wayptType);
640   }
641   
642   assert(wp);
643   if ((_altitude > 0.0) && (_altRestrict != RESTRICT_NONE)) {
644     wp->setAltitude(_altitude,_altRestrict);
645   }
646   
647   if (_speed > 0.0) {
648     wp->setSpeed(_speed, RESTRICT_AT); // or _BELOW?
649   }
650   
651   return wp;
652 }
653
654 void NavdataVisitor::finishApproach()
655 {
656   WayptVec::iterator it;
657   FGRunwayRef rwy;
658   
659 // find the runway node
660   for (it = _waypoints.begin(); it != _waypoints.end(); ++it) {
661     FGPositionedRef navid = (*it)->source();
662     if (!navid) {
663       continue;
664     }
665     
666     if (navid->type() == FGPositioned::RUNWAY) {
667       rwy = (FGRunway*) navid.get();
668       break;
669     }
670   }
671   
672   if (!rwy) {
673     throw sg_format_exception("Malformed approach, no runway waypt", _ident);
674   }
675   
676   WayptVec primary(_waypoints.begin(), it);
677   // erase all points up to and including the runway, to leave only the
678   // missed segments
679   _waypoints.erase(_waypoints.begin(), ++it);
680   
681   _approach->setRunway(rwy);
682   _approach->setPrimaryAndMissed(primary, _waypoints);
683   _airport->addApproach(_approach);
684   _approach = NULL;
685 }
686
687 void NavdataVisitor::finishSid()
688 {
689   // reverse order, because that's how we deal with commonality between
690   // STARs and SIDs. SID::route undoes  this
691   std::reverse(_waypoints.begin(), _waypoints.end());
692   _sid->setCommon(_waypoints);
693   _airport->addSID(_sid);
694   _sid = NULL;
695 }
696
697 void NavdataVisitor::finishStar()
698 {
699   _star->setCommon(_waypoints);
700   _airport->addSTAR(_star);
701   _star = NULL;
702 }
703
704 void NavdataVisitor::data (const char * s, int len)
705 {
706   _text += string(s, len);
707 }
708
709
710 void NavdataVisitor::pi (const char * target, const char * data) {
711   //cout << "Processing instruction " << target << ' ' << data << endl;
712 }
713
714 void NavdataVisitor::warning (const char * message, int line, int column) {
715   SG_LOG(SG_IO, SG_WARN, "Warning: " << message << " (" << line << ',' << column << ')');
716 }
717
718 void NavdataVisitor::error (const char * message, int line, int column) {
719   SG_LOG(SG_IO, SG_ALERT, "Error: " << message << " (" << line << ',' << column << ')');
720 }
721
722 } // of namespace flightgear