]> git.mxchange.org Git - flightgear.git/blob - src/Airports/gnnode.cxx
Bugfix: Retrieval of the next radio frequency was broken. Contributed by Adrian Musceac.
[flightgear.git] / src / Airports / gnnode.cxx
1 #include "gnnode.hxx"
2 #include "groundnetwork.hxx"
3
4 #include <iostream>
5 #include <algorithm>
6 using std::sort;
7
8 /*****************************************************************************
9  * Helper function for parsing position string
10  ****************************************************************************/
11 double processPosition(const string &pos)
12 {
13   string prefix;
14   string subs;
15   string degree;
16   string decimal;
17   int sign = 1;
18   double value;
19   subs = pos;
20   prefix= subs.substr(0,1);
21   if (prefix == string("S") || (prefix == string("W")))
22     sign = -1;
23   subs    = subs.substr(1, subs.length());
24   degree  = subs.substr(0, subs.find(" ",0));
25   decimal = subs.substr(subs.find(" ",0), subs.length());
26   
27               
28   //cerr << sign << " "<< degree << " " << decimal << endl;
29   value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
30   //cerr << value <<endl;
31   //exit(1);
32   return value;
33 }
34
35 //bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
36 //  return a->hasSmallerHeadingDiff(*b);
37 //}
38
39 bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
40   return a->getLength() > b->getLength();
41 }
42
43 /**************************************************************************
44  * FGTaxiNode
45  *************************************************************************/
46 void FGTaxiNode::setElevation(double val)
47 {
48     geod.setElevationM(val);
49 }
50
51 void FGTaxiNode::setLatitude (double val)
52 {
53   geod.setLatitudeDeg(val);
54 }
55
56 void FGTaxiNode::setLongitude(double val)
57 {
58   geod.setLongitudeDeg(val);
59 }
60
61 void FGTaxiNode::setLatitude (const string& val)
62 {
63   geod.setLatitudeDeg(processPosition(val));
64 }
65
66 void FGTaxiNode::setLongitude(const string& val)
67 {
68   geod.setLongitudeDeg(processPosition(val));
69 }
70   
71 //void FGTaxiNode::sortEndSegments(bool byLength)
72 //{
73 //  if (byLength)
74 //    sort(next.begin(), next.end(), sortByLength);
75 //  else
76 //    sort(next.begin(), next.end(), sortByHeadingDiff);
77 //}
78
79