]> git.mxchange.org Git - flightgear.git/blob - src/Airports/simple.hxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Airports / simple.hxx
1 // simple.hxx -- a really simplistic class to manage airport ID,
2 //                 lat, lon of the center of one of it's runways, and 
3 //                 elevation in feet.
4 //
5 // Written by Curtis Olson, started April 1998.
6 //
7 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 //
23 // $Id$
24
25
26 #ifndef _SIMPLE_HXX
27 #define _SIMPLE_HXX
28
29
30 #ifndef __cplusplus                                                          
31 # error This library requires C++
32 #endif                                   
33
34
35 #ifdef HAVE_CONFIG_H
36 #  include <config.h>
37 #endif
38
39 #include <simgear/compiler.h>
40
41 #include STL_STRING
42 #include <set>
43
44 // Forward declarations.
45 class c4_Storage;
46 class c4_View;
47
48 SG_USING_STD(string);
49 SG_USING_STD(set);
50
51 class FGAirport {
52
53 public:
54
55     FGAirport( const string& name = "",
56                double lon = 0.0,
57                double lat = 0.0,
58                double ele = 0.0 )
59         : id(name), longitude(lon), latitude(lat), elevation(ele) {}
60
61     bool operator < ( const FGAirport& a ) const {
62         return id < a.id;
63     }
64
65 public:
66
67     string id;
68     double longitude;
69     double latitude;
70     double elevation;
71
72 };
73
74
75 class FGAirports {
76
77 private:
78
79     c4_Storage *storage;
80     c4_View *vAirport;
81
82 public:
83
84     // Constructor
85     FGAirports( const string& file );
86
87     // Destructor
88     ~FGAirports();
89
90     // search for the specified id.
91     // Returns true if successful, otherwise returns false.
92     // On success, airport data is returned thru "airport" pointer.
93     // "airport" is not changed if "apt" is not found.
94     bool search( const string& id, FGAirport* airport ) const;
95     FGAirport search( const string& id ) const;
96 };
97
98
99 class FGAirportsUtil {
100 public:
101 #ifdef SG_NO_DEFAULT_TEMPLATE_ARGS
102     typedef set< FGAirport, less< FGAirport > > container;
103 #else
104     typedef set< FGAirport > container;
105 #endif
106     typedef container::iterator iterator;
107     typedef container::const_iterator const_iterator;
108
109 private:
110     container airports;
111
112 public:
113
114     // Constructor
115     FGAirportsUtil();
116
117     // Destructor
118     ~FGAirportsUtil();
119
120     // load the data
121     int load( const string& file );
122
123     // save the data in metakit format
124     bool dump_mk4( const string& file );
125
126     // search for the specified id.
127     // Returns true if successful, otherwise returns false.
128     // On success, airport data is returned thru "airport" pointer.
129     // "airport" is not changed if "id" is not found.
130     bool search( const string& id, FGAirport* airport ) const;
131     FGAirport search( const string& id ) const;
132 };
133
134
135 #endif // _SIMPLE_HXX
136
137