1 // navrecord.cxx -- generic vor/dme/ndb class
3 // Written by Curtis Olson, started May 2004.
5 // Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
28 #include <simgear/misc/sgstream.hxx>
29 #include "Navaids/navrecord.hxx"
31 FGNavRecord::FGNavRecord(void) :
33 pos(SGGeod::fromDeg(0, 0)),
46 FGNavRecord::FGNavRecord(int aTy, const std::string& aIdent,
47 const std::string& aName, const std::string& aAirport,
48 double lat, double lon, int aFreq, int aRange, double aMultiuse) :
59 pos = SGGeod::fromDeg(lon, lat);
60 cart = SGVec3d::fromGeod(pos);
63 fg_nav_types FGNavRecord::get_fg_type() const {
65 case 2: return(FG_NAV_NDB);
66 case 3: return(FG_NAV_VOR);
67 case 4: return(FG_NAV_ILS);
68 default: return(FG_NAV_ANY);
73 std::istream& operator>>( std::istream& in, FGNavRecord& n )
81 double lat, lon, elev_ft;
82 in >> lat >> lon >> elev_ft >> n.freq >> n.range >> n.multiuse
84 n.pos.setLatitudeDeg(lat);
85 n.pos.setLongitudeDeg(lon);
86 n.pos.setElevationFt(elev_ft);
87 getline( in, n.name );
89 // silently multiply adf frequencies by 100 so that adf
90 // vs. nav/loc frequency lookups can use the same code.
95 // Remove any leading spaces before the name
96 while ( n.name.substr(0,1) == " " ) {
97 n.name = n.name.erase(0,1);
100 if ( n.type >= 4 && n.type <= 9 ) {
101 // these types are always associated with an airport id
102 std::string::size_type pos = n.name.find(" ");
103 n.apt_id = n.name.substr(0, pos);
106 // Ranges are included with the latest data format, no need to
107 // assign our own defaults, unless the range is not set for some
110 if ( n.range < 0.1 ) {
111 // assign default ranges
113 if ( n.type == 2 || n.type == 3 ) {
114 n.range = FG_NAV_DEFAULT_RANGE;
115 } else if ( n.type == 4 || n.type == 5 || n.type == 6 ) {
116 n.range = FG_LOC_DEFAULT_RANGE;
117 } else if ( n.type == 12 ) {
118 n.range = FG_DME_DEFAULT_RANGE;
120 n.range = FG_LOC_DEFAULT_RANGE;
124 // transmitted ident (same as ident unless modeling a fault)
125 n.trans_ident = n.ident;
127 // generate cartesian coordinates
128 n.cart = SGVec3d::fromGeod(n.pos);
134 FGTACANRecord::FGTACANRecord(void) :
142 operator >> ( std::istream& in, FGTACANRecord& n )
144 in >> n.channel >> n.freq ;
145 //getline( in, n.name );