]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navrecord.cxx
Clean up/simplify NasalPositioned_cppbind
[flightgear.git] / src / Navaids / navrecord.cxx
1 // navrecord.cxx -- generic vor/dme/ndb class
2 //
3 // Written by Curtis Olson, started May 2004.
4 //
5 // Copyright (C) 2004  Curtis L. Olson - http://www.flightgear.org/~curt
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 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24   #include "config.h"
25 #endif
26
27 #include <istream>
28
29 #include <simgear/misc/sgstream.hxx>
30 #include <simgear/misc/sg_path.hxx>
31 #include <simgear/structure/exception.hxx>
32 #include <simgear/debug/logstream.hxx>
33 #include <simgear/sg_inlines.h>
34 #include <simgear/props/props.hxx>
35
36
37 #include <Navaids/navrecord.hxx>
38 #include <Navaids/navdb.hxx>
39 #include <Airports/runways.hxx>
40 #include <Airports/airport.hxx>
41 #include <Airports/xmlloader.hxx>
42 #include <Main/fg_props.hxx>
43
44 FGNavRecord::FGNavRecord(PositionedID aGuid, Type aTy, const std::string& aIdent,
45   const std::string& aName, const SGGeod& aPos,
46   int aFreq, int aRange, double aMultiuse, PositionedID aRunway) :
47   FGPositioned(aGuid, aTy, aIdent, aPos),
48   freq(aFreq),
49   range(aRange),
50   multiuse(aMultiuse),
51   mName(aName),
52   mRunway(aRunway),
53   serviceable(true)
54
55 }
56
57 FGRunwayRef FGNavRecord::runway() const
58 {
59   return loadById<FGRunway>(mRunway);
60 }
61
62 double FGNavRecord::localizerWidth() const
63 {
64   if (!mRunway) {
65     return 6.0;
66   }
67   
68   FGRunway* rwy = runway();
69   SGVec3d thresholdCart(SGVec3d::fromGeod(rwy->threshold()));
70   double axisLength = dist(cart(), thresholdCart);
71   double landingLength = dist(thresholdCart, SGVec3d::fromGeod(rwy->end()));
72   
73 // Reference: http://dcaa.slv.dk:8000/icaodocs/
74 // ICAO standard width at threshold is 210 m = 689 feet = approx 700 feet.
75 // ICAO 3.1.1 half course = DDM = 0.0775
76 // ICAO 3.1.3.7.1 Sensitivity 0.00145 DDM/m at threshold
77 //  implies peg-to-peg of 214 m ... we will stick with 210.
78 // ICAO 3.1.3.7.1 "Course sector angle shall not exceed 6 degrees."
79               
80 // Very short runway:  less than 1200 m (4000 ft) landing length:
81   if (landingLength < 1200.0) {
82 // ICAO fudges localizer sensitivity for very short runways.
83 // This produces a non-monotonic sensitivity-versus length relation.
84     axisLength += 1050.0;
85   }
86
87 // Example: very short: San Diego   KMYF (Montgomery Field) ILS RWY 28R
88 // Example: short:      Tom's River KMJX (Robert J. Miller) ILS RWY 6
89 // Example: very long:  Denver      KDEN (Denver)           ILS RWY 16R
90   double raw_width = 210.0 / axisLength * SGD_RADIANS_TO_DEGREES;
91   return raw_width < 6.0? raw_width : 6.0;
92
93 }
94
95 FGTACANRecord::FGTACANRecord(void) :
96     channel(""),
97     freq(0)
98     
99 {
100 }
101
102 std::istream&
103 operator >> ( std::istream& in, FGTACANRecord& n )
104 {
105     in >> n.channel >> n.freq ;
106     //getline( in, n.name );
107
108     return in;
109 }