]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navlist.hxx
aa9970026d3d6ffdade1c87071b872e51c8f1dd3
[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., 675 Mass Ave, Cambridge, MA 02139, 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 // convenience types
43 typedef vector < FGNavRecord* > nav_list_type;
44 typedef vector < FGTACANRecord* > tacan_list_type;
45 typedef nav_list_type::iterator nav_list_iterator;
46 typedef nav_list_type::const_iterator nav_list_const_iterator;
47
48 typedef map < int, nav_list_type > nav_map_type;
49 typedef map < int, tacan_list_type > tacan_map_type;
50 typedef nav_map_type::iterator nav_map_iterator;
51 typedef nav_map_type::const_iterator nav_map_const_iterator;
52
53 typedef map < string, nav_list_type > nav_ident_map_type;
54 typedef map < string, tacan_list_type > tacan_ident_map_type;
55
56 class FGNavList {
57
58     nav_list_type navlist;
59     nav_list_type carrierlist;
60     nav_map_type navaids;
61     nav_map_type navaids_by_tile;
62     nav_ident_map_type ident_navaids;
63         
64     // Given a point and a list of stations, return the closest one to
65     // the specified point.
66     FGNavRecord *findNavFromList( const Point3D &aircraft, 
67                                   const nav_list_type &stations );
68         
69 public:
70
71     FGNavList();
72     ~FGNavList();
73
74     // initialize the nav list
75     bool init();
76
77     // add an entry
78     bool add( FGNavRecord *n );
79     //bool add( FGTACANRecord *r );
80
81     // Query the database for the specified frequency.  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 degrees,
84     // elev is in meters.
85     FGNavRecord *findByFreq( double freq, double lon, double lat, double elev );
86
87     // Query the database for the specified frequency.  It is assumed
88     // that there will be multiple stations with matching frequencies
89     // so a position must be specified.  Lon and lat are in degrees,
90     // elev is in meters.
91     FGNavRecord *findByLoc( double lon, double lat, double elev );
92
93     // locate closest item in the DB matching the requested ident
94     FGNavRecord *findByIdent( const char* ident, const double lon, const double lat );
95
96     // Given an Ident and optional freqency, return the first matching
97     // station.
98     FGNavRecord *findByIdentAndFreq( const char* ident,
99                                      const double freq = 0.0 );
100
101     // returns the closest entry to the give lon/lat/elev
102     FGNavRecord *findClosest( double lon_rad, double lat_rad, double elev_m );
103
104     // given a frequency returns the first matching entry
105     FGNavRecord *findStationByFreq( double frequency );
106
107     inline nav_map_type get_navaids() const { return navaids; }
108 };
109
110 class FGTACANList {
111
112     tacan_list_type channellist;
113     //nav_list_type carrierlist;
114     tacan_map_type channels;
115     //nav_map_type navaids_by_tile;
116     tacan_ident_map_type ident_channels;
117         
118     // Given a point and a list of stations, return the closest one to
119     // the specified point.
120     /*FGNavRecord *findNavFromList( const Point3D &aircraft, 
121                                   const nav_list_type &stations );*/
122         
123 public:
124
125     FGTACANList();
126     ~FGTACANList();
127
128     // initialize the TACAN list
129     bool init();
130
131     // add an entry
132     
133     bool add( FGTACANRecord *r );
134     
135     // Given a TACAN Channel, return the appropriate frequency.  
136     FGTACANRecord *findByChannel( string channel );
137
138     
139 };
140 #endif // _FG_NAVLIST_HXX