]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navlist.hxx
Finish conversion of FGRunway to a real class - all public members are gone.
[flightgear.git] / src / Navaids / navlist.hxx
1 // navlist.hxx -- navaids management class
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000  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
24 #ifndef _FG_NAVLIST_HXX
25 #define _FG_NAVLIST_HXX
26
27
28 #include <simgear/compiler.h>
29 #include <simgear/misc/sg_path.hxx>
30 #include <simgear/structure/SGSharedPtr.hxx>
31 #include <simgear/structure/SGReferenced.hxx>
32
33 #include <map>
34 #include <vector>
35 #include <string>
36
37 #include "navrecord.hxx"
38
39 using std::map;
40 using std::vector;
41 using std::string;
42
43
44
45 // FGNavList ------------------------------------------------------------------
46
47 typedef SGSharedPtr<FGNavRecord> nav_rec_ptr;
48 typedef vector < nav_rec_ptr > nav_list_type;
49 typedef nav_list_type::iterator nav_list_iterator;
50 typedef nav_list_type::const_iterator nav_list_const_iterator;
51
52 typedef map < int, nav_list_type > nav_map_type;
53 typedef nav_map_type::iterator nav_map_iterator;
54 typedef nav_map_type::const_iterator nav_map_const_iterator;
55
56 typedef map < string, nav_list_type > nav_ident_map_type;
57 typedef nav_ident_map_type::iterator nav_ident_map_iterator;
58
59
60 class FGNavList {
61
62     nav_list_type carrierlist;
63     nav_map_type navaids;
64     nav_map_type navaids_by_tile;
65     nav_ident_map_type ident_navaids;
66
67     // Given a point and a list of stations, return the closest one to
68     // the specified point.
69     FGNavRecord *findNavFromList( const SGVec3d &aircraft,
70                                   const nav_list_type &stations );
71
72 public:
73
74     FGNavList();
75     ~FGNavList();
76
77     // initialize the nav list
78     bool init();
79
80     // add an entry
81     bool add( FGNavRecord *n );
82
83     /** Query the database for the specified station.  It is assumed
84       * that there will be multiple stations with matching frequencies
85       * so a position must be specified.  Lon and lat are in radians,
86       * elev is in meters.
87       */
88     FGNavRecord *findByFreq( double freq, double lon, double lat, double elev );
89
90     // locate closest item in the DB matching the requested ident
91     FGNavRecord *findByIdent( const char* ident, const double lon, const double lat );
92
93     // Given an Ident and optional freqency, return the first matching
94     // station.
95     FGNavRecord *findByIdentAndFreq( const char* ident,
96                                      const double freq = 0.0 );
97
98     // returns the closest entry to the give lon/lat/elev
99     FGNavRecord *findClosest( double lon_rad, double lat_rad, double elev_m, 
100       FGPositioned::Type type = FG_NAV_ANY );
101
102     // given a frequency returns the first matching entry
103     FGNavRecord *findStationByFreq( double frequency );
104
105     inline const nav_map_type& get_navaids() const { return navaids; }
106 };
107
108
109
110
111 // FGTACANList ----------------------------------------------------------------
112
113
114 typedef SGSharedPtr<FGTACANRecord> tacan_rec_ptr;
115 typedef vector < tacan_rec_ptr > tacan_list_type;
116 typedef map < int, tacan_list_type > tacan_map_type;
117 typedef map < string, tacan_list_type > tacan_ident_map_type;
118
119
120 class FGTACANList {
121
122     tacan_list_type channellist;
123     tacan_map_type channels;
124     tacan_ident_map_type ident_channels;
125
126 public:
127
128     FGTACANList();
129     ~FGTACANList();
130
131     // initialize the TACAN list
132     bool init();
133
134     // add an entry
135     bool add( FGTACANRecord *r );
136
137     // Given a TACAN Channel, return the appropriate frequency.
138     FGTACANRecord *findByChannel( const string& channel );
139
140
141 };
142 #endif // _FG_NAVLIST_HXX