2003-02-06 10:42:43 +00:00
|
|
|
// commlist.hxx -- comm frequency lookup class
|
|
|
|
//
|
|
|
|
// Written by David Luff and Alexander Kappes, started Jan 2003.
|
|
|
|
// Based on navlist.hxx by Curtis Olson, started April 2000.
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
2003-02-06 10:42:43 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
*
|
|
|
|
* FGCommList is used to store communication frequency information
|
|
|
|
* for the ATC and AI subsystems. Two maps are maintained - one
|
|
|
|
* searchable by location and one searchable by frequency. The
|
|
|
|
* data structure returned from the search is the ATCData struct
|
|
|
|
* defined in ATC.hxx, containing location, frequency, name, range
|
|
|
|
* and type of the returned station.
|
|
|
|
*
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef _FG_COMMLIST_HXX
|
|
|
|
#define _FG_COMMLIST_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <simgear/misc/sg_path.hxx>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "ATC.hxx"
|
|
|
|
#include "atis.hxx"
|
|
|
|
|
2005-02-02 19:16:51 +00:00
|
|
|
SG_USING_STD(list);
|
2003-02-06 10:42:43 +00:00
|
|
|
SG_USING_STD(map);
|
|
|
|
SG_USING_STD(vector);
|
|
|
|
SG_USING_STD(string);
|
|
|
|
|
|
|
|
// A list of ATC stations
|
|
|
|
typedef list < ATCData > comm_list_type;
|
|
|
|
typedef comm_list_type::iterator comm_list_iterator;
|
|
|
|
typedef comm_list_type::const_iterator comm_list_const_iterator;
|
|
|
|
|
|
|
|
// A map of ATC station lists
|
|
|
|
typedef map < int, comm_list_type > comm_map_type;
|
|
|
|
typedef comm_map_type::iterator comm_map_iterator;
|
|
|
|
typedef comm_map_type::const_iterator comm_map_const_iterator;
|
|
|
|
|
|
|
|
|
|
|
|
class FGCommList {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
FGCommList();
|
|
|
|
~FGCommList();
|
|
|
|
|
|
|
|
// load all comm frequencies and build the map
|
2005-10-25 13:49:55 +00:00
|
|
|
bool init( const SGPath& path );
|
2003-02-06 10:42:43 +00:00
|
|
|
|
|
|
|
// query the database for the specified frequency, lon and lat are
|
2003-03-06 14:06:34 +00:00
|
|
|
// in degrees, elev is in meters.
|
|
|
|
// If no atc_type is specified, it returns true if any non-invalid type is found.
|
|
|
|
// If atc_type is specifed, returns true only if the specified type is found.
|
|
|
|
// Returns the station closest to the supplied position.
|
2003-02-06 10:42:43 +00:00
|
|
|
// The data found is written into the passed-in ATCData structure.
|
|
|
|
bool FindByFreq( double lon, double lat, double elev, double freq, ATCData* ad, atc_type tp = INVALID );
|
|
|
|
|
2003-10-10 15:14:09 +00:00
|
|
|
// query the database by location, lon and lat are in degrees, elev is in meters, range is in nautical miles.
|
|
|
|
// Returns the number of stations of the specified atc_type tp that are in range of the position defined by
|
|
|
|
// lon, lat and elev, and pushes them into stations.
|
2003-03-09 17:35:16 +00:00
|
|
|
// If no atc_type is specifed, returns the number of all stations in range, and pushes them into stations
|
2003-02-06 10:42:43 +00:00
|
|
|
// ** stations is erased before use **
|
2003-03-09 17:35:16 +00:00
|
|
|
int FindByPos( double lon, double lat, double elev, double range, comm_list_type* stations, atc_type tp = INVALID );
|
2003-03-06 14:06:34 +00:00
|
|
|
|
2003-03-11 13:24:35 +00:00
|
|
|
// Returns the distance in meters to the closest station of a given type,
|
|
|
|
// with the details written into ATCData& ad. If no type is specifed simply
|
|
|
|
// returns the distance to the closest station of any type.
|
|
|
|
// Returns -9999 if no stations found within max_range in nautical miles (default 100 miles).
|
|
|
|
// Note that the search algorithm starts at 10 miles and multiplies by 10 thereafter, so if
|
|
|
|
// say 300 miles is specifed 10, then 100, then 1000 will be searched, breaking at first result
|
|
|
|
// and giving up after 1000.
|
|
|
|
// !!!Be warned that searching anything over 100 miles will pause the sim unacceptably!!!
|
|
|
|
// (The ability to search longer ranges should be used during init only).
|
|
|
|
double FindClosest( double lon, double lat, double elev, ATCData& ad, atc_type tp = INVALID, double max_range = 100.0 );
|
|
|
|
|
2003-03-06 14:06:34 +00:00
|
|
|
// Find by Airport code.
|
2005-10-25 13:49:55 +00:00
|
|
|
bool FindByCode( const string& ICAO, ATCData& ad, atc_type tp = INVALID );
|
2003-02-06 10:42:43 +00:00
|
|
|
|
2003-03-09 17:35:16 +00:00
|
|
|
// Return the callsign for an ATIS transmission given transmission time and airport id
|
2003-02-06 10:42:43 +00:00
|
|
|
// This maybe should get moved somewhere else!!
|
2005-10-25 13:49:55 +00:00
|
|
|
int GetCallSign( const string& apt_id, int hours, int mins );
|
2003-02-06 10:42:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Comm stations mapped by frequency
|
|
|
|
comm_map_type commlist_freq;
|
|
|
|
|
|
|
|
// Comm stations mapped by bucket
|
|
|
|
comm_map_type commlist_bck;
|
|
|
|
|
|
|
|
// Load comms from a specified path (which must include the filename)
|
2005-10-25 13:49:55 +00:00
|
|
|
bool LoadComms(const SGPath& path);
|
2003-02-06 10:42:43 +00:00
|
|
|
|
|
|
|
//----------- This stuff is left over from atislist.[ch]xx and maybe should move somewhere else
|
|
|
|
// Add structure and map for storing a log of atis transmissions
|
|
|
|
// made in this session of FlightGear. This allows the callsign
|
|
|
|
// to be allocated correctly wrt time.
|
|
|
|
typedef struct {
|
|
|
|
int hours;
|
|
|
|
int mins;
|
|
|
|
int callsign;
|
|
|
|
} atis_transmission_type;
|
|
|
|
|
|
|
|
typedef map < string, atis_transmission_type > atis_log_type;
|
|
|
|
typedef atis_log_type::iterator atis_log_iterator;
|
|
|
|
typedef atis_log_type::const_iterator atis_log_const_iterator;
|
|
|
|
|
|
|
|
atis_log_type atislog;
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern FGCommList *current_commlist;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FG_COMMLIST_HXX
|