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