]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navlist.hxx
More route-manager functionality moved to Nasal.
[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
30 #include <simgear/structure/SGSharedPtr.hxx>
31
32 #include <map>
33 #include <vector>
34 #include <string>
35
36 #include "navrecord.hxx"
37
38 // forward decls
39 class SGGeod;
40
41 // FGNavList ------------------------------------------------------------------
42
43 typedef SGSharedPtr<FGNavRecord> nav_rec_ptr;
44 typedef std::vector < nav_rec_ptr > nav_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 std::map < int, nav_list_type > nav_map_type;
49 typedef nav_map_type::iterator nav_map_iterator;
50 typedef nav_map_type::const_iterator nav_map_const_iterator;
51
52 class FGNavList {
53
54     nav_list_type carrierlist;
55     nav_map_type navaids;
56
57     // Given a point and a list of stations, return the closest one to
58     // the specified point.
59     FGNavRecord *findNavFromList( const SGGeod &aircraft,
60                                   const nav_list_type &stations );
61
62 public:
63
64     FGNavList();
65     ~FGNavList();
66
67     // initialize the nav list
68     bool init();
69
70     // add an entry
71     bool add( FGNavRecord *n );
72
73     /** Query the database for the specified station.  It is assumed
74       * that there will be multiple stations with matching frequencies
75       * so a position must be specified.
76       */
77     FGNavRecord *findByFreq( double freq, const SGGeod& position);
78
79     nav_list_type findAllByFreq( double freq, const SGGeod& position, 
80                                 const FGPositioned::Type type = FGPositioned::INVALID);
81   
82     // Given an Ident and optional freqency and type , 
83     // return a list of matching stations.
84     const nav_list_type findByIdentAndFreq( const std::string& ident,
85         const double freq = 0.0, const FGPositioned::Type = FGPositioned::INVALID );
86
87     // Given an Ident and optional freqency and type , 
88     // return a list of matching stations sorted by distance to the given position
89     const nav_list_type findByIdentAndFreq( const SGGeod & position,
90         const std::string& ident, const double freq = 0.0, 
91         const FGPositioned::Type = FGPositioned::INVALID );
92
93     // given a frequency returns the first matching entry
94     FGNavRecord *findStationByFreq( double frequency );
95   
96   class TypeFilter : public FGPositioned::Filter
97   {
98   public:
99     TypeFilter(const FGPositioned::Type type);
100     
101     virtual FGPositioned::Type minType() const {
102       return _mintype;
103     }
104     
105     virtual FGPositioned::Type maxType()  const {
106       return _maxtype;
107     }
108   private:
109     FGPositioned::Type _mintype;
110     FGPositioned::Type _maxtype;
111   };
112 };
113
114
115
116
117 // FGTACANList ----------------------------------------------------------------
118
119
120 typedef SGSharedPtr<FGTACANRecord> tacan_rec_ptr;
121 typedef std::vector < tacan_rec_ptr > tacan_list_type;
122 typedef std::map < int, tacan_list_type > tacan_map_type;
123 typedef std::map < std::string, tacan_list_type > tacan_ident_map_type;
124
125 class FGTACANList {
126
127     tacan_list_type channellist;
128     tacan_map_type channels;
129     tacan_ident_map_type ident_channels;
130
131 public:
132
133     FGTACANList();
134     ~FGTACANList();
135
136     // initialize the TACAN list
137     bool init();
138
139     // add an entry
140     bool add( FGTACANRecord *r );
141
142     // Given a TACAN Channel, return the appropriate frequency.
143     FGTACANRecord *findByChannel( const std::string& channel );
144
145
146 };
147 #endif // _FG_NAVLIST_HXX