]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navlist.hxx
Moved random ground cover object management code (userdata.[ch]xx) over
[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 - curt@flightgear.org
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 "nav.hxx"
36
37 SG_USING_STD(map);
38 SG_USING_STD(vector);
39 SG_USING_STD(string);
40
41 class FGNavList {
42
43     // convenience types
44     typedef vector < FGNav* > 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 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     typedef map < string, nav_list_type > nav_ident_map_type;
53         
54     nav_map_type navaids;
55     nav_ident_map_type ident_navaids;
56         
57     // Given a point and a list of stations, return the closest one to
58     // the specified point.
59     FGNav *findNavFromList( const Point3D &aircraft, 
60                             const nav_list_type &stations );
61         
62 public:
63
64     FGNavList();
65     ~FGNavList();
66
67     // load the navaids and build the map
68     bool init( SGPath path );
69
70     // Query the database for the specified frequency.  It is assumed
71     // that there will be multiple stations with matching frequencies
72     // so a position must be specified.  Lon and lat are in degrees,
73     // elev is in meters.
74     FGNav *findByFreq( double freq, double lon, double lat, double elev );
75
76     // locate closest item in the DB matching the requested ident
77     FGNav *findByIdent( const char* ident, const double lon, const double lat );
78
79     // Given an Ident and optional freqency, return the first matching
80     // station.
81     FGNav *findByIdentAndFreq( const char* ident, const double freq = 0.0 );
82 };
83
84
85 extern FGNavList *current_navlist;
86
87
88 #endif // _FG_NAVLIST_HXX