]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navlist.hxx
make attribute strings lowercase with hyphen instead of underscore;
[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
31 #include <map>
32 #include <vector>
33 #include STL_STRING
34
35 #include "navrecord.hxx"
36
37 SG_USING_STD(map);
38 SG_USING_STD(vector);
39 SG_USING_STD(string);
40
41
42
43 // FGNavList ------------------------------------------------------------------
44
45
46 typedef vector < FGNavRecord* > nav_list_type;
47 typedef nav_list_type::iterator nav_list_iterator;
48 typedef nav_list_type::const_iterator nav_list_const_iterator;
49
50 typedef map < int, nav_list_type > nav_map_type;
51 typedef nav_map_type::iterator nav_map_iterator;
52 typedef nav_map_type::const_iterator nav_map_const_iterator;
53
54 typedef map < string, nav_list_type > nav_ident_map_type;
55 typedef nav_ident_map_type::iterator nav_ident_map_iterator;
56
57
58 class FGNavList {
59
60     nav_list_type carrierlist;
61     nav_map_type navaids;
62     nav_map_type navaids_by_tile;
63     nav_ident_map_type ident_navaids;
64
65     // Given a point and a list of stations, return the closest one to
66     // the specified point.
67     FGNavRecord *findNavFromList( const SGVec3d &aircraft,
68                                   const nav_list_type &stations );
69
70 public:
71
72     FGNavList();
73     ~FGNavList();
74
75     // initialize the nav list
76     bool init();
77
78     // add an entry
79     bool add( FGNavRecord *n );
80
81     /** Query the database for the specified station.  It is assumed
82       * that there will be multiple stations with matching frequencies
83       * so a position must be specified.  Lon and lat are in radians,
84       * elev is in meters.
85       */
86     FGNavRecord *findByFreq( double freq, double lon, double lat, double elev );
87
88     // locate closest item in the DB matching the requested ident
89     FGNavRecord *findByIdent( const char* ident, const double lon, const double lat );
90
91     // Find items of requested type with closest exact or subsequent ident
92     // (by ASCII code value) to that supplied.
93     // Supplying true for exact forces only exact matches to be returned (similar to above function)
94     // Returns an empty list if no match found - calling function should check for this!
95     nav_list_type findFirstByIdent( const string& ident, fg_nav_types type, bool exact = false );
96
97     // Given an Ident and optional freqency, return the first matching
98     // station.
99     FGNavRecord *findByIdentAndFreq( const char* ident,
100                                      const double freq = 0.0 );
101
102     // returns the closest entry to the give lon/lat/elev
103     FGNavRecord *findClosest( double lon_rad, double lat_rad, double elev_m, fg_nav_types type = FG_NAV_ANY );
104
105     // given a frequency returns the first matching entry
106     FGNavRecord *findStationByFreq( double frequency );
107
108     inline const nav_map_type& get_navaids() const { return navaids; }
109 };
110
111
112
113
114 // FGTACANList ----------------------------------------------------------------
115
116
117
118 typedef vector < FGTACANRecord* > tacan_list_type;
119 typedef map < int, tacan_list_type > tacan_map_type;
120 typedef map < string, tacan_list_type > tacan_ident_map_type;
121
122
123 class FGTACANList {
124
125     tacan_list_type channellist;
126     tacan_map_type channels;
127     tacan_ident_map_type ident_channels;
128
129 public:
130
131     FGTACANList();
132     ~FGTACANList();
133
134     // initialize the TACAN list
135     bool init();
136
137     // add an entry
138     bool add( FGTACANRecord *r );
139
140     // Given a TACAN Channel, return the appropriate frequency.
141     FGTACANRecord *findByChannel( const string& channel );
142
143
144 };
145 #endif // _FG_NAVLIST_HXX