FGAirportList is gone. Everything should work as before, especially the
AirportList dialog. (It would now be possible to trivially implement a VOR or NDB named search, if anyone wants such a thing).
This commit is contained in:
parent
b58c8b6f19
commit
f1b10eddfa
11 changed files with 41 additions and 173 deletions
|
@ -57,7 +57,7 @@ static FGPositioned::Type fptypeFromRobinType(int aType)
|
|||
}
|
||||
}
|
||||
|
||||
FGAirport* addAirport(FGAirportList *airports, const string& apt_id, const string& apt_name,
|
||||
FGAirport* addAirport(const string& apt_id, const string& apt_name,
|
||||
int rwy_count, double rwy_lat_accum, double rwy_lon_accum, double last_rwy_heading,
|
||||
double apt_elev, SGGeod& tower, bool got_tower, int type)
|
||||
{
|
||||
|
@ -82,17 +82,14 @@ FGAirport* addAirport(FGAirportList *airports, const string& apt_id, const strin
|
|||
tower = SGGeod::fromDegFt(lon + fudge_lon, lat + fudge_lat, apt_elev + tower_height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return airports->add(apt_id, SGGeod::fromDegFt(lon, lat, apt_elev), tower, apt_name, false,
|
||||
return new FGAirport(apt_id, SGGeod::fromDegFt(lon, lat, apt_elev), tower, apt_name, false,
|
||||
fptypeFromRobinType(type));
|
||||
}
|
||||
|
||||
// Load the airport data base from the specified aptdb file. The
|
||||
// metar file is used to mark the airports as having metar available
|
||||
// or not.
|
||||
bool fgAirportDBLoad( FGAirportList *airports,
|
||||
const string &aptdb_file, const string &metar_file )
|
||||
bool fgAirportDBLoad( const string &aptdb_file, const string &metar_file )
|
||||
{
|
||||
//
|
||||
// Load the apt.dat file
|
||||
|
@ -166,7 +163,7 @@ bool fgAirportDBLoad( FGAirportList *airports,
|
|||
SG_LOG( SG_GENERAL, SG_BULK, "Next airport = " << id << " "
|
||||
<< elev );
|
||||
|
||||
FGAirport* apt = addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
||||
FGAirport* apt = addAirport(last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
||||
last_rwy_heading, last_apt_elev, last_tower, got_tower, last_apt_type);
|
||||
|
||||
for (unsigned int r=0; r< runways.size(); ++r) {
|
||||
|
@ -269,7 +266,7 @@ bool fgAirportDBLoad( FGAirportList *airports,
|
|||
}
|
||||
|
||||
// add the last airport being processed if any
|
||||
addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
||||
addAirport( last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
||||
last_rwy_heading, last_apt_elev, last_tower, got_tower, last_apt_type);
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
// Load the airport data base from the specified aptdb file. The
|
||||
// metar file is used to mark the airports as having metar available
|
||||
// or not.
|
||||
bool fgAirportDBLoad( FGAirportList *airports, const string &aptdb_file, const std::string &metar_file );
|
||||
bool fgAirportDBLoad( const string &aptdb_file, const std::string &metar_file );
|
||||
|
||||
|
||||
#endif // _FG_APT_LOADER_HXX
|
||||
|
|
|
@ -28,29 +28,19 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
#include "simple.hxx"
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/sg_inlines.h>
|
||||
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Airports/runways.hxx>
|
||||
#include <Airports/dynamics.hxx>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "simple.hxx"
|
||||
#include "xmlloader.hxx"
|
||||
|
||||
using std::sort;
|
||||
using std::random_shuffle;
|
||||
#include <Airports/xmlloader.hxx>
|
||||
|
||||
// magic import of a helper which uses FGPositioned internals
|
||||
extern char** searchAirportNamesAndIdents(const std::string& aFilter);
|
||||
|
@ -151,19 +141,6 @@ FGAirport::getIteratorForRunwayIdent(const string& aIdent) const
|
|||
return it; // end()
|
||||
}
|
||||
|
||||
static double normaliseBearing(double aBearing)
|
||||
{
|
||||
while (aBearing < -180) {
|
||||
aBearing += 360.0;
|
||||
}
|
||||
|
||||
while (aBearing > 180.0) {
|
||||
aBearing -= 360.0;
|
||||
}
|
||||
|
||||
return aBearing;
|
||||
}
|
||||
|
||||
FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
|
||||
{
|
||||
Runway_iterator it = mRunways.begin();
|
||||
|
@ -179,7 +156,8 @@ FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
|
|||
for (; it != mRunways.end(); ++it) {
|
||||
double good = (*it)->score(lengthWeight, widthWeight, surfaceWeight);
|
||||
|
||||
double dev = normaliseBearing(aHeading - (*it)->headingDeg());
|
||||
double dev = aHeading - (*it)->headingDeg();
|
||||
SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
|
||||
double bad = fabs(deviationWeight * dev) + 1e-20;
|
||||
double quality = good / bad;
|
||||
|
||||
|
@ -308,49 +286,6 @@ char** FGAirport::searchNamesAndIdents(const std::string& aFilter)
|
|||
return searchAirportNamesAndIdents(aFilter);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FGAirportList
|
||||
*****************************************************************************/
|
||||
|
||||
FGAirportList::FGAirportList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FGAirportList::~FGAirportList( void )
|
||||
{
|
||||
for (unsigned int i = 0; i < airports_array.size(); ++i) {
|
||||
delete airports_array[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add an entry to the list
|
||||
FGAirport* FGAirportList::add( const string &id, const SGGeod& location, const SGGeod& tower_location,
|
||||
const string &name, bool has_metar, FGPositioned::Type aType)
|
||||
{
|
||||
FGAirport* a = new FGAirport(id, location, tower_location, name, has_metar, aType);
|
||||
// try and read in an auxilary file
|
||||
airports_array.push_back( a );
|
||||
return a;
|
||||
}
|
||||
|
||||
int
|
||||
FGAirportList::size () const
|
||||
{
|
||||
return airports_array.size();
|
||||
}
|
||||
|
||||
|
||||
const FGAirport *FGAirportList::getAirport( unsigned int index ) const
|
||||
{
|
||||
if (index < airports_array.size()) {
|
||||
return(airports_array[index]);
|
||||
} else {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// find basic airport location info from airport database
|
||||
const FGAirport *fgFindAirportID( const string& id)
|
||||
{
|
||||
|
|
|
@ -156,40 +156,6 @@ private:
|
|||
std::vector<FGRunwayPtr> mTaxiways;
|
||||
};
|
||||
|
||||
typedef std::vector < FGAirport * > airport_list;
|
||||
typedef airport_list::iterator airport_list_iterator;
|
||||
typedef airport_list::const_iterator const_airport_list_iterator;
|
||||
|
||||
|
||||
|
||||
class FGAirportList {
|
||||
private:
|
||||
|
||||
airport_list airports_array;
|
||||
|
||||
public:
|
||||
// Constructor (new)
|
||||
FGAirportList();
|
||||
|
||||
// Destructor
|
||||
~FGAirportList();
|
||||
|
||||
// add an entry to the list
|
||||
FGAirport* add( const std::string& id, const SGGeod& location, const SGGeod& tower,
|
||||
const std::string& name, bool has_metar, FGPositioned::Type aType);
|
||||
|
||||
/**
|
||||
* Return the number of airports in the list.
|
||||
*/
|
||||
int size() const;
|
||||
|
||||
/**
|
||||
* Return a specific airport, by position.
|
||||
*/
|
||||
const FGAirport *getAirport( unsigned int index ) const;
|
||||
|
||||
};
|
||||
|
||||
// find basic airport location info from airport database
|
||||
const FGAirport *fgFindAirportID( const std::string& id);
|
||||
|
||||
|
|
|
@ -2,17 +2,14 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <locale>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Airports/simple.hxx>
|
||||
|
||||
#include "AirportList.hxx"
|
||||
|
||||
|
||||
AirportList::AirportList(int x, int y, int width, int height) :
|
||||
puaList(x, y, width, height),
|
||||
GUI_ID(FGCLASS_AIRPORTLIST),
|
||||
_airports(globals->get_airports()),
|
||||
_content(0)
|
||||
{
|
||||
create_list();
|
||||
|
@ -28,28 +25,9 @@ AirportList::~AirportList()
|
|||
void
|
||||
AirportList::create_list()
|
||||
{
|
||||
const std::ctype<char> &ct = std::use_facet<std::ctype<char> >(std::locale());
|
||||
int num_apt = _airports->size();
|
||||
char **content = new char *[num_apt + 1];
|
||||
|
||||
int n = 0;
|
||||
for (int i = 0; i < num_apt; i++) {
|
||||
const FGAirport *apt = _airports->getAirport(i);
|
||||
std::string entry(' ' + apt->getName() + " (" + apt->getId() + ')');
|
||||
|
||||
if (!_filter.empty()) {
|
||||
std::string upper(entry.data());
|
||||
ct.toupper((char *)upper.data(), (char *)upper.data() + upper.size());
|
||||
|
||||
if (upper.find(_filter) == std::string::npos)
|
||||
continue;
|
||||
}
|
||||
|
||||
content[n] = new char[entry.size() + 1];
|
||||
strcpy(content[n], entry.c_str());
|
||||
n++;
|
||||
}
|
||||
content[n] = 0;
|
||||
char **content = FGAirport::searchNamesAndIdents(_filter);
|
||||
int n = (content[0] != NULL) ? 1 : 0;
|
||||
|
||||
// work around plib 2006/04/18 bug: lists with no entries cause crash on arrow-up
|
||||
newList(n > 0 ? content : 0);
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ public:
|
|||
virtual void setValue(const char *);
|
||||
|
||||
private:
|
||||
FGAirportList *_airports;
|
||||
char **_content;
|
||||
std::string _filter;
|
||||
};
|
||||
|
|
|
@ -577,7 +577,6 @@ void KLN89::DrawMap(bool draw_avs) {
|
|||
// Annotation then gets drawn by Nav page, NOT this function.
|
||||
|
||||
if(_drawApt && draw_avs) {
|
||||
airport_list apt;
|
||||
/*
|
||||
bool have_apt = _overlays->FindArpByRegion(&apt, bottomLeft.lat(), bottomLeft.lon(), topRight.lat(), topRight.lon());
|
||||
//cout << "Vors enclosed are: ";
|
||||
|
|
|
@ -965,10 +965,7 @@ fgInitNav ()
|
|||
SGPath p_metar( globals->get_fg_root() );
|
||||
p_metar.append( "Airports/metar.dat" );
|
||||
|
||||
FGAirportList *airports = new FGAirportList();
|
||||
globals->set_airports( airports );
|
||||
|
||||
fgAirportDBLoad( airports, aptdb.str(), p_metar.str() );
|
||||
fgAirportDBLoad( aptdb.str(), p_metar.str() );
|
||||
|
||||
FGNavList *navlist = new FGNavList;
|
||||
FGNavList *loclist = new FGNavList;
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include <Navaids/awynet.hxx>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Scenery/tilemgr.hxx>
|
||||
#include <Airports/simple.hxx>
|
||||
#include <Navaids/navlist.hxx>
|
||||
#include <Navaids/fixlist.hxx>
|
||||
|
||||
|
@ -83,7 +82,6 @@ FGGlobals::FGGlobals() :
|
|||
route_mgr( NULL ),
|
||||
current_panel( NULL ),
|
||||
soundmgr( NULL ),
|
||||
airports( NULL ),
|
||||
ATC_mgr( NULL ),
|
||||
AI_mgr( NULL ),
|
||||
controls( NULL ),
|
||||
|
@ -133,7 +131,6 @@ FGGlobals::~FGGlobals()
|
|||
delete route_mgr;
|
||||
delete current_panel;
|
||||
delete soundmgr;
|
||||
delete airports;
|
||||
|
||||
delete ATC_mgr;
|
||||
delete AI_mgr;
|
||||
|
|
|
@ -54,7 +54,6 @@ class SGEventMgr;
|
|||
class SGSubsystemMgr;
|
||||
class SGSubsystem;
|
||||
|
||||
class FGAirportList;
|
||||
class FGAIMgr;
|
||||
class FGATCMgr;
|
||||
class FGAircraftModel;
|
||||
|
@ -137,9 +136,6 @@ private:
|
|||
// sound manager
|
||||
SGSoundMgr *soundmgr;
|
||||
|
||||
// Simple Airport List
|
||||
FGAirportList *airports;
|
||||
|
||||
// ATC manager
|
||||
FGATCMgr *ATC_mgr;
|
||||
|
||||
|
@ -243,9 +239,6 @@ public:
|
|||
inline SGMaterialLib *get_matlib() const { return matlib; }
|
||||
inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
|
||||
|
||||
inline FGAirportList *get_airports() const { return airports; }
|
||||
inline void set_airports( FGAirportList *a ) {airports = a; }
|
||||
|
||||
inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
|
||||
inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
|
||||
|
||||
|
|
|
@ -370,6 +370,7 @@ char** searchAirportNamesAndIdents(const std::string& aFilter)
|
|||
// may get very large and smart-pointer-atomicity-locking then becomes a
|
||||
// bottleneck for this case.
|
||||
std::vector<FGPositioned*> matches;
|
||||
std::string upper;
|
||||
|
||||
for (; it != end; ++it) {
|
||||
FGPositioned::Type ty = it->second->type();
|
||||
|
@ -377,10 +378,12 @@ char** searchAirportNamesAndIdents(const std::string& aFilter)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (hasFilter &&
|
||||
(it->second->name().find(aFilter) == std::string::npos) &&
|
||||
(it->second->ident().find(aFilter) == std::string::npos)) {
|
||||
continue;
|
||||
if (hasFilter && (it->second->ident().find(aFilter) == std::string::npos)) {
|
||||
upper = it->second->name(); // string copy, sadly
|
||||
ct.toupper((char *)upper.data(), (char *)upper.data() + upper.size());
|
||||
if (upper.find(aFilter) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
matches.push_back(it->second);
|
||||
|
@ -396,23 +399,27 @@ char** searchAirportNamesAndIdents(const std::string& aFilter)
|
|||
|
||||
// nasty code to avoid excessive string copying and allocations.
|
||||
// We format results as follows (note whitespace!):
|
||||
// ' name-of-airport-chars (icao)'
|
||||
// ' name-of-airport-chars (ident)'
|
||||
// so the total length is:
|
||||
// 1 + strlen(name) + 4 + 4 (for the ICAO) + 1 + 1 (for the null)
|
||||
// 1 + strlen(name) + 4 + 4 (for the ident) + 1 + 1 (for the null)
|
||||
// which gives a grand total of 11 + the length of the name.
|
||||
|
||||
// note the ident is sometimes only three letters for non-ICAO small strips
|
||||
for (unsigned int i=0; i<numMatches; ++i) {
|
||||
int nameLength = matches[i]->name().size();
|
||||
int icaoLength = matches[i]->ident().size();
|
||||
char* entry = new char[nameLength + 11];
|
||||
entry[0] = ' ';
|
||||
memcpy(entry + 1, matches[i]->name().c_str(), nameLength);
|
||||
entry[nameLength + 1] = ' ';
|
||||
entry[nameLength + 2] = ' ';
|
||||
entry[nameLength + 3] = ' ';
|
||||
entry[nameLength + 4] = '(';
|
||||
memcpy(entry + nameLength + 5, matches[i]->ident().c_str(), 4);
|
||||
entry[nameLength + 9] = ')';
|
||||
entry[nameLength + 10] = 0;
|
||||
char* dst = entry;
|
||||
*dst++ = ' ';
|
||||
memcpy(dst, matches[i]->name().c_str(), nameLength);
|
||||
dst += nameLength;
|
||||
*dst++ = ' ';
|
||||
*dst++ = ' ';
|
||||
*dst++ = ' ';
|
||||
*dst++ = '(';
|
||||
memcpy(dst, matches[i]->ident().c_str(), icaoLength);
|
||||
dst += icaoLength;
|
||||
*dst++ = ')';
|
||||
*dst++ = 0;
|
||||
result[i] = entry;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue