]> git.mxchange.org Git - flightgear.git/blob - src/ATC/commlist.hxx
Added FindByCode (airport ICAO code) to commlist. This is basically a wrapper around...
[flightgear.git] / src / ATC / commlist.hxx
1 // commlist.hxx -- comm frequency lookup class
2 //
3 // Written by David Luff and Alexander Kappes, started Jan 2003.
4 // Based on navlist.hxx by Curtis Olson, started April 2000.
5 //
6 // Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 /*****************************************************************
23 *
24 * FGCommList is used to store communication frequency information
25 * for the ATC and AI subsystems.  Two maps are maintained - one
26 * searchable by location and one searchable by frequency.  The
27 * data structure returned from the search is the ATCData struct
28 * defined in ATC.hxx, containing location, frequency, name, range
29 * and type of the returned station.
30 *
31 ******************************************************************/
32
33 #ifndef _FG_COMMLIST_HXX
34 #define _FG_COMMLIST_HXX
35
36
37 #include <simgear/compiler.h>
38 #include <simgear/misc/sg_path.hxx>
39
40 #include <map>
41 #include <list>
42 #include <string>
43
44 #include "ATC.hxx"
45 #include "atis.hxx"
46
47 SG_USING_STD(map);
48 SG_USING_STD(vector);
49 SG_USING_STD(string);
50
51 // A list of ATC stations
52 typedef list < ATCData > comm_list_type;
53 typedef comm_list_type::iterator comm_list_iterator;
54 typedef comm_list_type::const_iterator comm_list_const_iterator;
55
56 // A map of ATC station lists
57 typedef map < int, comm_list_type > comm_map_type;
58 typedef comm_map_type::iterator comm_map_iterator;
59 typedef comm_map_type::const_iterator comm_map_const_iterator;
60
61
62 class FGCommList {
63         
64 public:
65
66     FGCommList();
67     ~FGCommList();
68
69     // load all comm frequencies and build the map
70     bool init( SGPath path );
71
72     // query the database for the specified frequency, lon and lat are
73     // in degrees, elev is in meters.
74         // If no atc_type is specified, it returns true if any non-invalid type is found.
75         // If atc_type is specifed, returns true only if the specified type is found.
76         // Returns the station closest to the supplied position.
77         // The data found is written into the passed-in ATCData structure.
78     bool FindByFreq( double lon, double lat, double elev, double freq, ATCData* ad, atc_type tp = INVALID );
79         
80     // query the database by location, lon and lat are
81     // in degrees, elev is in meters
82         // Returns the number of stations of the specified type that are in range, and pushes them into stations
83         // If atc_type is specifed, returns the number of all stations in range, and pushes them into stations
84         // ** stations is erased before use **
85     int FindByPos( double lon, double lat, double elev, comm_list_type* stations, atc_type tp = INVALID );
86         
87         // Find by Airport code.
88         bool FindByCode( string ICAO, ATCData& ad, atc_type tp = INVALID );
89
90     // Return the callsign for an ATIS transmission given transmission time and airpord id
91         // This maybe should get moved somewhere else!!
92     int GetCallSign( string apt_id, int hours, int mins );
93         
94 private:
95         
96         // Comm stations mapped by frequency
97         comm_map_type commlist_freq;    
98         
99         // Comm stations mapped by bucket
100         comm_map_type commlist_bck;
101
102         // Load comms from a specified path (which must include the filename)   
103         bool LoadComms(SGPath path);
104
105 //----------- This stuff is left over from atislist.[ch]xx and maybe should move somewhere else
106         // Add structure and map for storing a log of atis transmissions
107         // made in this session of FlightGear.  This allows the callsign
108         // to be allocated correctly wrt time.
109         typedef struct {
110                 int hours;
111                 int mins;
112                 int callsign;
113         } atis_transmission_type;
114
115     typedef map < string, atis_transmission_type > atis_log_type;
116     typedef atis_log_type::iterator atis_log_iterator;
117     typedef atis_log_type::const_iterator atis_log_const_iterator;
118
119     atis_log_type atislog;
120 //-----------------------------------------------------------------------------------------------
121
122 };
123
124
125 extern FGCommList *current_commlist;
126
127
128 #endif // _FG_COMMLIST_HXX