]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navlist.hxx
Whoops, work-around for #926 correctly.
[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
46 class FGNavList
47 {
48 public:
49   class TypeFilter : public FGPositioned::Filter
50   {
51   public:
52     TypeFilter(const FGPositioned::Type type);
53     
54     TypeFilter(const FGPositioned::Type minType,
55                const FGPositioned::Type maxType);
56     
57     virtual FGPositioned::Type minType() const {
58       return _mintype;
59     }
60     
61     virtual FGPositioned::Type maxType()  const {
62       return _maxtype;
63     }
64     
65   protected:
66     FGPositioned::Type _mintype;
67     FGPositioned::Type _maxtype;
68   };
69   
70   /**
71    filter matching VOR & ILS/LOC transmitters
72    */
73   static TypeFilter* navFilter();
74   
75   /**
76     * filter matching ILS/LOC transmitter
77    */
78   static TypeFilter* locFilter();
79   
80   static TypeFilter* ndbFilter();
81   
82   /**
83    * Filter returning TACANs and VORTACs
84    */
85   static TypeFilter* tacanFilter();
86   
87   
88   static TypeFilter* carrierFilter();
89   
90     /** Query the database for the specified station.  It is assumed
91       * that there will be multiple stations with matching frequencies
92       * so a position must be specified.
93       */
94     static FGNavRecord *findByFreq( double freq, const SGGeod& position,
95                                    TypeFilter* filter = NULL);
96
97     /**
98      * Overloaded version above - no positioned supplied so can be used with
99      * mobile TACANs which have no valid position. The first match is
100      * returned only.
101      */
102     static FGNavRecord *findByFreq( double freq, TypeFilter* filter = NULL);
103   
104     static nav_list_type findAllByFreq( double freq, const SGGeod& position,
105                                        TypeFilter* filter = NULL);
106   
107     // Given an Ident and optional frequency and type ,
108     // return a list of matching stations.
109     static nav_list_type findByIdentAndFreq( const std::string& ident,
110                                              const double freq,
111                                             TypeFilter* filter = NULL);
112
113     // Given an Ident and optional frequency and type ,
114     // return a list of matching stations sorted by distance to the given position
115     static nav_list_type findByIdentAndFreq( const SGGeod & position,
116         const std::string& ident, const double freq = 0.0,
117                                             TypeFilter* filter = NULL);
118   
119   };
120
121
122 // FGTACANList ----------------------------------------------------------------
123
124
125 typedef SGSharedPtr<FGTACANRecord> tacan_rec_ptr;
126 typedef std::vector < tacan_rec_ptr > tacan_list_type;
127 typedef std::map < int, tacan_list_type > tacan_map_type;
128 typedef std::map < std::string, tacan_list_type > tacan_ident_map_type;
129
130 class FGTACANList {
131
132     tacan_list_type channellist;
133     tacan_map_type channels;
134     tacan_ident_map_type ident_channels;
135
136 public:
137
138     FGTACANList();
139     ~FGTACANList();
140
141     // initialize the TACAN list
142     bool init();
143
144     // add an entry
145     bool add( FGTACANRecord *r );
146
147     // Given a TACAN Channel, return the appropriate frequency.
148     FGTACANRecord *findByChannel( const std::string& channel );
149
150
151 };
152 #endif // _FG_NAVLIST_HXX