1
0
Fork 0

Clean up/prepare for porting NasalPositioned to cppbind

This commit is contained in:
Thomas Geymayer 2013-03-04 16:31:37 +01:00
parent 6bf47cd248
commit 45e3b7e2d1
28 changed files with 387 additions and 266 deletions

View file

@ -196,7 +196,7 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET; _ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
if (material) { if (material) {
const vector<string>& names = material->get_names(); const std::vector<std::string>& names = material->get_names();
_solid = material->get_solid(); _solid = material->get_solid();

View file

@ -29,8 +29,8 @@ private:
int mRangeNM; int mRangeNM;
int mFreqKhz; int mFreqKhz;
PositionedID mAirport; PositionedID mAirport;
}; };
} // of namespace flightgear } // of namespace flightgear
#endif // of FG_ATC_COMM_STATION_HXX #endif // of FG_ATC_COMM_STATION_HXX

View file

@ -41,8 +41,8 @@
//class FGATCController; //class FGATCController;
typedef vector<FGATCController*> AtcVec; typedef std::vector<FGATCController*> AtcVec;
typedef vector<FGATCController*>::iterator AtcVecIterator; typedef std::vector<FGATCController*>::iterator AtcVecIterator;
class FGATCManager : public SGSubsystem class FGATCManager : public SGSubsystem
{ {

View file

@ -21,9 +21,7 @@
#ifndef _TRAFFIC_CONTROL_HXX_ #ifndef _TRAFFIC_CONTROL_HXX_
#define _TRAFFIC_CONTROL_HXX_ #define _TRAFFIC_CONTROL_HXX_
#include <string> #include <Airports/airports_fwd.hxx>
#include <vector>
#include <list>
#include <osg/Geode> #include <osg/Geode>
#include <osg/Geometry> #include <osg/Geometry>
@ -37,15 +35,26 @@
#include <simgear/structure/SGReferenced.hxx> #include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx> #include <simgear/structure/SGSharedPtr.hxx>
class FGAIAircraft;
typedef std::vector<FGAIAircraft*> AircraftVec;
typedef std::vector<FGAIAircraft*>::iterator AircraftVecIterator;
class FGAIFlightPlan;
typedef std::vector<FGAIFlightPlan*> FlightPlanVec;
typedef std::vector<FGAIFlightPlan*>::iterator FlightPlanVecIterator;
typedef std::map<std::string, FlightPlanVec> FlightPlanVecMap;
class FGTrafficRecord;
typedef std::list<FGTrafficRecord> TrafficVector;
typedef std::list<FGTrafficRecord>::iterator TrafficVectorIterator;
class ActiveRunway;
typedef std::vector<ActiveRunway> ActiveRunwayVec;
typedef std::vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
typedef std::vector<int> intVec; typedef std::vector<int> intVec;
typedef std::vector<int>::iterator intVecIterator; typedef std::vector<int>::iterator intVecIterator;
class FGAIFlightPlan; // forward reference
class FGGroundNetwork; // forward reference
class FGAIAircraft; // forward reference
class FGAirportDynamics;
/************************************************************************************** /**************************************************************************************
* class FGATCInstruction * class FGATCInstruction
* like class FGATC Controller, this class definition should go into its own file * like class FGATC Controller, this class definition should go into its own file
@ -306,15 +315,6 @@ public:
int getPriority() const { return priority; }; int getPriority() const { return priority; };
}; };
typedef std::list<FGTrafficRecord> TrafficVector;
typedef std::list<FGTrafficRecord>::iterator TrafficVectorIterator;
typedef std::vector<time_t> TimeVector;
typedef std::vector<time_t>::iterator TimeVectorIterator;
typedef std::vector<FGAIAircraft*> AircraftVec;
typedef std::vector<FGAIAircraft*>::iterator AircraftVecIterator;
/*********************************************************************** /***********************************************************************
* Active runway, a utility class to keep track of which aircraft has * Active runway, a utility class to keep track of which aircraft has
* clearance for a given runway. * clearance for a given runway.
@ -368,9 +368,6 @@ public:
void printDepartureCue(); void printDepartureCue();
}; };
typedef std::vector<ActiveRunway> ActiveRunwayVec;
typedef std::vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
/** /**
* class FGATCController * class FGATCController
* NOTE: this class serves as an abstraction layer for all sorts of ATC controllers. * NOTE: this class serves as an abstraction layer for all sorts of ATC controllers.

View file

@ -711,10 +711,10 @@ void FGATIS::genFacilityInfo(void)
// Note that at this point, multi-word facility names // Note that at this point, multi-word facility names
// will sometimes contain hyphens, not spaces. // will sometimes contain hyphens, not spaces.
vector<string> name_words; std::vector<std::string> name_words;
boost::split(name_words, name, boost::is_any_of(" -")); boost::split(name_words, name, boost::is_any_of(" -"));
for (vector<string>::const_iterator wordp = name_words.begin(); for( std::vector<string>::const_iterator wordp = name_words.begin();
wordp != name_words.end(); wordp++) { wordp != name_words.end(); wordp++) {
string word(*wordp); string word(*wordp);
// Remap some abbreviations that occur in apt.dat, to // Remap some abbreviations that occur in apt.dat, to

View file

@ -18,6 +18,7 @@ set(SOURCES
) )
set(HEADERS set(HEADERS
airports_fwd.hxx
apt_loader.hxx apt_loader.hxx
dynamicloader.hxx dynamicloader.hxx
dynamics.hxx dynamics.hxx

View file

@ -58,15 +58,18 @@ using std::pair;
using namespace flightgear; using namespace flightgear;
/*************************************************************************** /***************************************************************************
* FGAirport * FGAirport
***************************************************************************/ ***************************************************************************/
AirportCache FGAirport::airportCache; AirportCache FGAirport::airportCache;
FGAirport::FGAirport(PositionedID aGuid, const string &id, const SGGeod& location, FGAirport::FGAirport( PositionedID aGuid,
const string &name, bool has_metar, Type aType) : const std::string &id,
const SGGeod& location,
const std::string &name,
bool has_metar,
Type aType ):
FGPositioned(aGuid, aType, id, location), FGPositioned(aGuid, aType, id, location),
_name(name), _name(name),
_has_metar(has_metar), _has_metar(has_metar),
@ -126,45 +129,83 @@ FGAirportDynamics * FGAirport::getDynamics()
return _dynamics; return _dynamics;
} }
//------------------------------------------------------------------------------
unsigned int FGAirport::numRunways() const unsigned int FGAirport::numRunways() const
{ {
loadRunways(); loadRunways();
return mRunways.size(); return mRunways.size();
} }
//------------------------------------------------------------------------------
unsigned int FGAirport::numHelipads() const unsigned int FGAirport::numHelipads() const
{ {
loadHelipads(); loadHelipads();
return mHelipads.size(); return mHelipads.size();
} }
//------------------------------------------------------------------------------
FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const
{ {
loadRunways(); loadRunways();
return loadById<FGRunway>(mRunways, aIndex);
assert(aIndex >= 0 && aIndex < mRunways.size());
return (FGRunway*) flightgear::NavDataCache::instance()->loadById(mRunways[aIndex]);
} }
//------------------------------------------------------------------------------
FGHelipad* FGAirport::getHelipadByIndex(unsigned int aIndex) const FGHelipad* FGAirport::getHelipadByIndex(unsigned int aIndex) const
{ {
loadHelipads(); loadHelipads();
return loadById<FGHelipad>(mHelipads, aIndex);
assert(aIndex >= 0 && aIndex < mHelipads.size());
return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(mHelipads[aIndex]);
} }
bool FGAirport::hasRunwayWithIdent(const string& aIdent) const //------------------------------------------------------------------------------
FGRunwayMap FGAirport::getRunwayMap() const
{
loadRunways();
FGRunwayMap map;
double minLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft");
BOOST_FOREACH(PositionedID id, mRunways)
{
FGRunway* rwy = loadById<FGRunway>(id);
// ignore unusably short runways
// TODO other methods don't check this...
if( rwy->lengthFt() >= minLengthFt )
map[ rwy->ident() ] = rwy;
}
return map;
}
//------------------------------------------------------------------------------
FGHelipadMap FGAirport::getHelipadMap() const
{
loadHelipads();
FGHelipadMap map;
BOOST_FOREACH(PositionedID id, mHelipads)
{
FGHelipad* rwy = loadById<FGHelipad>(id);
map[ rwy->ident() ] = rwy;
}
return map;
}
//------------------------------------------------------------------------------
bool FGAirport::hasRunwayWithIdent(const std::string& aIdent) const
{ {
return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent) != 0; return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent) != 0;
} }
bool FGAirport::hasHelipadWithIdent(const string& aIdent) const bool FGAirport::hasHelipadWithIdent(const std::string& aIdent) const
{ {
return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::HELIPAD, aIdent) != 0; return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::HELIPAD, aIdent) != 0;
} }
FGRunway* FGAirport::getRunwayByIdent(const string& aIdent) const //------------------------------------------------------------------------------
FGRunway* FGAirport::getRunwayByIdent(const std::string& aIdent) const
{ {
PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent); PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent);
if (id == 0) { if (id == 0) {
@ -172,10 +213,11 @@ FGRunway* FGAirport::getRunwayByIdent(const string& aIdent) const
throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent"); throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
} }
return (FGRunway*) flightgear::NavDataCache::instance()->loadById(id); return loadById<FGRunway>(id);
} }
FGHelipad* FGAirport::getHelipadByIdent(const string& aIdent) const //------------------------------------------------------------------------------
FGHelipad* FGAirport::getHelipadByIdent(const std::string& aIdent) const
{ {
PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::HELIPAD, aIdent); PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::HELIPAD, aIdent);
if (id == 0) { if (id == 0) {
@ -183,10 +225,10 @@ FGHelipad* FGAirport::getHelipadByIdent(const string& aIdent) const
throw sg_range_exception("unknown helipad " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent"); throw sg_range_exception("unknown helipad " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
} }
return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(id); return loadById<FGHelipad>(id);
} }
//------------------------------------------------------------------------------
FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
{ {
loadRunways(); loadRunways();
@ -201,7 +243,7 @@ FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
double deviationWeight = param->getDoubleValue("deviation-weight", 1); double deviationWeight = param->getDoubleValue("deviation-weight", 1);
BOOST_FOREACH(PositionedID id, mRunways) { BOOST_FOREACH(PositionedID id, mRunways) {
FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id); FGRunway* rwy = loadById<FGRunway>(id);
double good = rwy->score(lengthWeight, widthWeight, surfaceWeight); double good = rwy->score(lengthWeight, widthWeight, surfaceWeight);
double dev = aHeading - rwy->headingDeg(); double dev = aHeading - rwy->headingDeg();
SG_NORMALIZE_RANGE(dev, -180.0, 180.0); SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
@ -217,6 +259,7 @@ FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
return result; return result;
} }
//------------------------------------------------------------------------------
FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
{ {
loadRunways(); loadRunways();
@ -225,7 +268,7 @@ FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
double currentLowestDev = 180.0; double currentLowestDev = 180.0;
BOOST_FOREACH(PositionedID id, mRunways) { BOOST_FOREACH(PositionedID id, mRunways) {
FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id); FGRunway* rwy = loadById<FGRunway>(id);
double inboundCourse = SGGeodesy::courseDeg(aPos, rwy->end()); double inboundCourse = SGGeodesy::courseDeg(aPos, rwy->end());
double dev = inboundCourse - rwy->headingDeg(); double dev = inboundCourse - rwy->headingDeg();
@ -242,12 +285,13 @@ FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
} }
//------------------------------------------------------------------------------
bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
{ {
loadRunways(); loadRunways();
BOOST_FOREACH(PositionedID id, mRunways) { BOOST_FOREACH(PositionedID id, mRunways) {
FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id); FGRunway* rwy = loadById<FGRunway>(id);
if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) { if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) {
return true; // we're done! return true; // we're done!
} }
@ -256,6 +300,7 @@ bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
return false; return false;
} }
//------------------------------------------------------------------------------
FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
{ {
loadRunways(); loadRunways();
@ -263,7 +308,7 @@ FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
FGRunwayList r; FGRunwayList r;
BOOST_FOREACH(PositionedID id, mRunways) { BOOST_FOREACH(PositionedID id, mRunways) {
FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id); FGRunway* rwy = loadById<FGRunway>(id);
FGRunway* recip = rwy->reciprocalRunway(); FGRunway* recip = rwy->reciprocalRunway();
if (recip) { if (recip) {
FGRunwayList::iterator it = std::find(r.begin(), r.end(), recip); FGRunwayList::iterator it = std::find(r.begin(), r.end(), recip);
@ -278,33 +323,49 @@ FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
return r; return r;
} }
//------------------------------------------------------------------------------
unsigned int FGAirport::numTaxiways() const unsigned int FGAirport::numTaxiways() const
{ {
loadTaxiways(); loadTaxiways();
return mTaxiways.size(); return mTaxiways.size();
} }
//------------------------------------------------------------------------------
FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const
{ {
loadTaxiways(); loadTaxiways();
return loadById<FGTaxiway>(mTaxiways, aIndex);
assert(aIndex >= 0 && aIndex < mTaxiways.size());
return (FGTaxiway*) flightgear::NavDataCache::instance()->loadById(mTaxiways[aIndex]);
} }
//------------------------------------------------------------------------------
FGTaxiwayList FGAirport::getTaxiways() const
{
loadTaxiways();
return loadAllById<FGTaxiway>(mTaxiways);
}
//------------------------------------------------------------------------------
unsigned int FGAirport::numPavements() const unsigned int FGAirport::numPavements() const
{ {
loadTaxiways(); loadTaxiways();
return mPavements.size(); return mPavements.size();
} }
//------------------------------------------------------------------------------
FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
{ {
loadTaxiways(); loadTaxiways();
assert(aIndex >= 0 && aIndex < mPavements.size()); return loadById<FGPavement>(mPavements, aIndex);
return (FGPavement*) flightgear::NavDataCache::instance()->loadById(mPavements[aIndex]);
} }
//------------------------------------------------------------------------------
FGPavementList FGAirport::getPavements() const
{
loadTaxiways();
return loadAllById<FGPavement>(mPavements);
}
//------------------------------------------------------------------------------
FGRunway* FGAirport::getActiveRunwayForUsage() const FGRunway* FGAirport::getActiveRunwayForUsage() const
{ {
FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment"); FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
@ -383,7 +444,7 @@ char** FGAirport::searchNamesAndIdents(const std::string& aFilter)
} }
// find basic airport location info from airport database // find basic airport location info from airport database
const FGAirport *fgFindAirportID( const string& id) const FGAirport *fgFindAirportID( const std::string& id)
{ {
if ( id.empty() ) { if ( id.empty() ) {
return NULL; return NULL;
@ -482,7 +543,7 @@ void FGAirport::readThresholdData(SGPropertyNode* aRoot)
void FGAirport::processThreshold(SGPropertyNode* aThreshold) void FGAirport::processThreshold(SGPropertyNode* aThreshold)
{ {
// first, let's identify the current runway // first, let's identify the current runway
string rwyIdent(aThreshold->getStringValue("rwy")); std::string rwyIdent(aThreshold->getStringValue("rwy"));
NavDataCache* cache = NavDataCache::instance(); NavDataCache* cache = NavDataCache::instance();
PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent); PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent);
if (id == 0) { if (id == 0) {
@ -642,18 +703,21 @@ void FGAirport::addApproach(Approach* aApp)
mApproaches.push_back(aApp); mApproaches.push_back(aApp);
} }
//------------------------------------------------------------------------------
unsigned int FGAirport::numSIDs() const unsigned int FGAirport::numSIDs() const
{ {
loadProcedures(); loadProcedures();
return mSIDs.size(); return mSIDs.size();
} }
//------------------------------------------------------------------------------
flightgear::SID* FGAirport::getSIDByIndex(unsigned int aIndex) const flightgear::SID* FGAirport::getSIDByIndex(unsigned int aIndex) const
{ {
loadProcedures(); loadProcedures();
return mSIDs[aIndex]; return mSIDs[aIndex];
} }
//------------------------------------------------------------------------------
flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
{ {
loadProcedures(); loadProcedures();
@ -666,18 +730,28 @@ flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
return NULL; return NULL;
} }
//------------------------------------------------------------------------------
flightgear::SIDList FGAirport::getSIDs() const
{
loadProcedures();
return flightgear::SIDList(mSIDs.begin(), mSIDs.end());
}
//------------------------------------------------------------------------------
unsigned int FGAirport::numSTARs() const unsigned int FGAirport::numSTARs() const
{ {
loadProcedures(); loadProcedures();
return mSTARs.size(); return mSTARs.size();
} }
//------------------------------------------------------------------------------
STAR* FGAirport::getSTARByIndex(unsigned int aIndex) const STAR* FGAirport::getSTARByIndex(unsigned int aIndex) const
{ {
loadProcedures(); loadProcedures();
return mSTARs[aIndex]; return mSTARs[aIndex];
} }
//------------------------------------------------------------------------------
STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
{ {
loadProcedures(); loadProcedures();
@ -690,18 +764,27 @@ STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
return NULL; return NULL;
} }
//------------------------------------------------------------------------------
STARList FGAirport::getSTARs() const
{
loadProcedures();
return STARList(mSTARs.begin(), mSTARs.end());
}
unsigned int FGAirport::numApproaches() const unsigned int FGAirport::numApproaches() const
{ {
loadProcedures(); loadProcedures();
return mApproaches.size(); return mApproaches.size();
} }
//------------------------------------------------------------------------------
Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
{ {
loadProcedures(); loadProcedures();
return mApproaches[aIndex]; return mApproaches[aIndex];
} }
//------------------------------------------------------------------------------
Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
{ {
loadProcedures(); loadProcedures();
@ -714,6 +797,22 @@ Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
return NULL; return NULL;
} }
//------------------------------------------------------------------------------
ApproachList FGAirport::getApproaches(ProcedureType type) const
{
loadProcedures();
if( type == PROCEDURE_INVALID )
return ApproachList(mApproaches.begin(), mApproaches.end());
ApproachList ret;
for(size_t i = 0; i < mApproaches.size(); ++i)
{
if( mApproaches[i]->type() == type )
ret.push_back(mApproaches[i]);
}
return ret;
}
CommStationList CommStationList
FGAirport::commStations() const FGAirport::commStations() const
{ {
@ -742,7 +841,7 @@ FGAirport::commStationsOfType(FGPositioned::Type aTy) const
} }
// get airport elevation // get airport elevation
double fgGetAirportElev( const string& id ) double fgGetAirportElev( const std::string& id )
{ {
const FGAirport *a=fgFindAirportID( id); const FGAirport *a=fgFindAirportID( id);
if (a) { if (a) {
@ -754,7 +853,7 @@ double fgGetAirportElev( const string& id )
// get airport position // get airport position
SGGeod fgGetAirportPos( const string& id ) SGGeod fgGetAirportPos( const std::string& id )
{ {
const FGAirport *a = fgFindAirportID( id); const FGAirport *a = fgFindAirportID( id);

View file

@ -34,33 +34,10 @@
#include <map> #include <map>
#include <Navaids/positioned.hxx> #include <Navaids/positioned.hxx>
#include <Airports/runways.hxx> #include <Navaids/procedure.hxx>
// forward decls
class FGAirportDynamics;
class FGRunway;
class FGHelipad;
class FGTaxiway;
class FGPavement;
class SGPropertyNode;
class FGAirport;
namespace flightgear {
class SID;
class STAR;
class Approach;
class Waypt;
class CommStation;
typedef SGSharedPtr<Waypt> WayptRef;
typedef std::vector<WayptRef> WayptVec;
typedef std::vector<CommStation*> CommStationList;
typedef std::map<std::string, FGAirport*> AirportCache;
}
typedef std::vector<FGRunway*> FGRunwayList;
#include "airports_fwd.hxx"
#include "runways.hxx"
/*************************************************************************************** /***************************************************************************************
* *
@ -108,6 +85,8 @@ public:
unsigned int numHelipads() const; unsigned int numHelipads() const;
FGRunway* getRunwayByIndex(unsigned int aIndex) const; FGRunway* getRunwayByIndex(unsigned int aIndex) const;
FGHelipad* getHelipadByIndex(unsigned int aIndex) const; FGHelipad* getHelipadByIndex(unsigned int aIndex) const;
FGRunwayMap getRunwayMap() const;
FGHelipadMap getHelipadMap() const;
bool hasRunwayWithIdent(const std::string& aIdent) const; bool hasRunwayWithIdent(const std::string& aIdent) const;
bool hasHelipadWithIdent(const std::string& aIdent) const; bool hasHelipadWithIdent(const std::string& aIdent) const;
@ -145,9 +124,11 @@ public:
unsigned int numTaxiways() const; unsigned int numTaxiways() const;
FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const; FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
FGTaxiwayList getTaxiways() const;
unsigned int numPavements() const; unsigned int numPavements() const;
FGPavement* getPavementByIndex(unsigned int aIndex) const; FGPavement* getPavementByIndex(unsigned int aIndex) const;
FGPavementList getPavements() const;
class AirportFilter : public Filter class AirportFilter : public Filter
{ {
@ -203,14 +184,20 @@ public:
unsigned int numSIDs() const; unsigned int numSIDs() const;
flightgear::SID* getSIDByIndex(unsigned int aIndex) const; flightgear::SID* getSIDByIndex(unsigned int aIndex) const;
flightgear::SID* findSIDWithIdent(const std::string& aIdent) const; flightgear::SID* findSIDWithIdent(const std::string& aIdent) const;
flightgear::SIDList getSIDs() const;
unsigned int numSTARs() const; unsigned int numSTARs() const;
flightgear::STAR* getSTARByIndex(unsigned int aIndex) const; flightgear::STAR* getSTARByIndex(unsigned int aIndex) const;
flightgear::STAR* findSTARWithIdent(const std::string& aIdent) const; flightgear::STAR* findSTARWithIdent(const std::string& aIdent) const;
flightgear::STARList getSTARs() const;
unsigned int numApproaches() const; unsigned int numApproaches() const;
flightgear::Approach* getApproachByIndex(unsigned int aIndex) const; flightgear::Approach* getApproachByIndex(unsigned int aIndex) const;
flightgear::Approach* findApproachWithIdent(const std::string& aIdent) const; flightgear::Approach* findApproachWithIdent(const std::string& aIdent) const;
flightgear::ApproachList getApproaches
(
flightgear::ProcedureType type = flightgear::PROCEDURE_INVALID
) const;
/** /**
* Syntactic wrapper around FGPositioned::findClosest - find the closest * Syntactic wrapper around FGPositioned::findClosest - find the closest

View file

@ -0,0 +1,98 @@
/*
* airports_fwd.hxx
*
* Created on: 04.03.2013
* Author: tom
*/
#ifndef AIRPORTS_FWD_HXX_
#define AIRPORTS_FWD_HXX_
#include <simgear/structure/SGSharedPtr.hxx>
#include <list>
#include <map>
#include <vector>
#include <string>
// forward decls
class FGAirport;
class FGAirportDynamics;
class FGRunway;
class FGHelipad;
class FGTaxiway;
class FGPavement;
class FGNavRecord;
class Block;
class FGTaxiNode;
class FGParking;
class FGTaxiSegment;
class FGTaxiRoute;
class FGGroundNetwork;
class RunwayList;
class RunwayGroup;
class FGRunwayPreference;
class FGSidStar;
class SGPropertyNode;
namespace flightgear {
class SID;
class STAR;
class Approach;
class Waypt;
class CommStation;
typedef std::vector<flightgear::SID*> SIDList;
typedef std::vector<STAR*> STARList;
typedef std::vector<Approach*> ApproachList;
typedef SGSharedPtr<Waypt> WayptRef;
typedef std::vector<WayptRef> WayptVec;
typedef SGSharedPtr<CommStation> CommStationRef;
typedef std::vector<CommStation*> CommStationList;
typedef std::map<std::string, FGAirport*> AirportCache;
}
typedef std::vector<FGRunway*> FGRunwayList;
typedef std::map<std::string, FGRunway*> FGRunwayMap;
typedef std::map<std::string, FGHelipad*> FGHelipadMap;
typedef std::vector<FGTaxiway*> FGTaxiwayList;
typedef std::vector<FGPavement*> FGPavementList;
typedef std::vector<FGTaxiSegment*> FGTaxiSegmentVector;
typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
typedef SGSharedPtr<FGTaxiNode> FGTaxiNodeRef;
typedef std::vector<FGTaxiNodeRef> FGTaxiNodeVector;
typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
typedef std::map<int, FGTaxiNodeRef> IndexTaxiNodeMap;
typedef std::vector<Block> BlockList;
typedef BlockList::iterator BlockListIterator;
typedef std::vector<time_t> TimeVector;
typedef std::vector<time_t>::iterator TimeVectorIterator;
typedef std::vector<FGTaxiRoute> TaxiRouteVector;
typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
typedef std::vector<FGParking*> FGParkingVec;
typedef FGParkingVec::iterator FGParkingVecIterator;
typedef FGParkingVec::const_iterator FGParkingVecConstIterator;
typedef std::vector<RunwayList> RunwayListVec;
typedef std::vector<RunwayList>::iterator RunwayListVectorIterator;
typedef std::vector<RunwayList>::const_iterator RunwayListVecConstIterator;
typedef std::vector<RunwayGroup> PreferenceList;
typedef std::vector<RunwayGroup>::iterator PreferenceListIterator;
typedef std::vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
#endif /* AIRPORTS_FWD_HXX_ */

View file

@ -25,14 +25,11 @@
#include <set> #include <set>
#include <ATC/trafficcontrol.hxx> #include <ATC/trafficcontrol.hxx>
#include "airports_fwd.hxx"
#include "parking.hxx" #include "parking.hxx"
#include "groundnetwork.hxx" #include "groundnetwork.hxx"
#include "runwayprefs.hxx" #include "runwayprefs.hxx"
// forward decls
class FGAirport;
class FGEnvironment;
class ParkingAssignment class ParkingAssignment
{ {
public: public:
@ -125,7 +122,10 @@ public:
FGAirport* parent() const FGAirport* parent() const
{ return _ap; } { return _ap; }
void getActiveRunway(const string& trafficType, int action, string& runway, double heading); void getActiveRunway( const std::string& trafficType,
int action,
std::string& runway,
double heading );
/** /**
* retrieve an available parking by GateID, or -1 if no suitable * retrieve an available parking by GateID, or -1 if no suitable

View file

@ -41,8 +41,4 @@ public:
bool getIsOnRunway() const { return isOnRunway; }; bool getIsOnRunway() const { return isOnRunway; };
}; };
typedef SGSharedPtr<FGTaxiNode> FGTaxiNode_ptr;
typedef std::vector<FGTaxiNode_ptr> FGTaxiNodeVector;
typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
#endif #endif

View file

@ -394,7 +394,7 @@ public:
{} {}
double score; double score;
FGTaxiNode_ptr previousNode; FGTaxiNodeRef previousNode;
}; };
FGTaxiRoute FGGroundNetwork::findShortestRoute(PositionedID start, PositionedID end, FGTaxiRoute FGGroundNetwork::findShortestRoute(PositionedID start, PositionedID end,

View file

@ -27,26 +27,11 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <string> #include <string>
#include <vector>
#include <list>
#include <map>
#include "gnnode.hxx" #include "gnnode.hxx"
#include "parking.hxx" #include "parking.hxx"
#include <ATC/trafficcontrol.hxx> #include <ATC/trafficcontrol.hxx>
class Block;
class FGRunway;
class FGTaxiSegment; // forward reference
class FGAIFlightPlan; // forward reference
class FGAirport; // forward reference
typedef std::vector<FGTaxiSegment*> FGTaxiSegmentVector;
typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
typedef std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
class Block class Block
{ {
private: private:
@ -63,9 +48,6 @@ public:
bool operator< (const Block &other) const { return blocktime < other.blocktime; }; bool operator< (const Block &other) const { return blocktime < other.blocktime; };
}; };
typedef std::vector<Block> BlockList;
typedef BlockList::iterator BlockListIterator;
/*************************************************************************************** /***************************************************************************************
* class FGTaxiSegment * class FGTaxiSegment
**************************************************************************************/ **************************************************************************************/
@ -119,14 +101,6 @@ public:
}; };
}; };
typedef std::vector<int> intVec;
typedef std::vector<int>::iterator intVecIterator;
/*************************************************************************************** /***************************************************************************************
* class FGTaxiRoute * class FGTaxiRoute
**************************************************************************************/ **************************************************************************************/
@ -181,9 +155,6 @@ public:
}; };
}; };
typedef std::vector<FGTaxiRoute> TaxiRouteVector;
typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
/************************************************************************************** /**************************************************************************************
* class FGGroundNetWork * class FGGroundNetWork
*************************************************************************************/ *************************************************************************************/

View file

@ -33,7 +33,6 @@
#include <simgear/sg_inlines.h> #include <simgear/sg_inlines.h>
#include <string> #include <string>
#include <vector>
#include <memory> // for std::auto_ptr #include <memory> // for std::auto_ptr
#include "gnnode.hxx" #include "gnnode.hxx"
@ -79,8 +78,4 @@ public:
return radius < other.radius; }; return radius < other.radius; };
}; };
typedef std::vector<FGParking*> FGParkingVec;
typedef FGParkingVec::iterator FGParkingVecIterator;
typedef FGParkingVec::const_iterator FGParkingVecConstIterator;
#endif #endif

View file

@ -90,7 +90,7 @@ ScheduleTime & ScheduleTime::operator=(const ScheduleTime & other)
return *this; return *this;
} }
string ScheduleTime::getName(time_t dayStart) std::string ScheduleTime::getName(time_t dayStart)
{ {
if ((start.size() != end.size()) if ((start.size() != end.size())
|| (start.size() != scheduleNames.size())) { || (start.size() != scheduleNames.size())) {
@ -109,7 +109,7 @@ string ScheduleTime::getName(time_t dayStart)
//couldn't find one so return 0; //couldn't find one so return 0;
//cerr << "Returning 0 " << endl; //cerr << "Returning 0 " << endl;
} }
return string(""); return std::string("");
} }
/****************************************************************************** /******************************************************************************
@ -136,15 +136,15 @@ RunwayList & RunwayList::operator=(const RunwayList & other)
return *this; return *this;
} }
void RunwayList::set(const string & tp, const string & lst) void RunwayList::set(const std::string & tp, const std::string & lst)
{ {
//weekday = atoi(timeCopy.substr(0,1).c_str()); //weekday = atoi(timeCopy.substr(0,1).c_str());
// timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday; // timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
// timeCopy = timeCopy.substr(2,timeCopy.length()); // timeCopy = timeCopy.substr(2,timeCopy.length());
type = tp; type = tp;
string rwys = lst; std::string rwys = lst;
string rwy; std::string rwy;
while (rwys.find(",") != string::npos) { while (rwys.find(",") != std::string::npos) {
rwy = rwys.substr(0, rwys.find(",", 0)); rwy = rwys.substr(0, rwys.find(",", 0));
//cerr << "adding runway [" << rwy << "] to the list " << endl; //cerr << "adding runway [" << rwy << "] to the list " << endl;
preferredRunways.push_back(rwy); preferredRunways.push_back(rwy);
@ -206,7 +206,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
double hdgDiff; double hdgDiff;
double crossWind; double crossWind;
double tailWind; double tailWind;
string name; std::string name;
//stringVec names; //stringVec names;
int bestMatch = 0, bestChoice = 0; int bestMatch = 0, bestChoice = 0;
@ -229,7 +229,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
validSelection = true; validSelection = true;
for (int j = 0; j < activeRwys; j++) { for (int j = 0; j < activeRwys; j++) {
string ident(rwyList[j].getRwyList(i)); std::string ident(rwyList[j].getRwyList(i));
if (!airport->hasRunwayWithIdent(ident)) { if (!airport->hasRunwayWithIdent(ident)) {
SG_LOG(SG_GENERAL, SG_WARN, SG_LOG(SG_GENERAL, SG_WARN,
"no such runway:" << ident << " at " << "no such runway:" << ident << " at " <<
@ -290,9 +290,9 @@ void RunwayGroup::setActive(const FGAirport * airport,
choice[0] = 0; choice[0] = 0;
choice[1] = 0; choice[1] = 0;
for (int i = activeRwys - 1; i; i--) { for (int i = activeRwys - 1; i; i--) {
if (rwyList[i].getType() == string("landing")) if (rwyList[i].getType() == std::string("landing"))
choice[0] = i; choice[0] = i;
if (rwyList[i].getType() == string("takeoff")) if (rwyList[i].getType() == std::string("takeoff"))
choice[1] = i; choice[1] = i;
} }
//cerr << "Choosing " << choice[0] << " for landing and " << choice[1] << "for takeoff" << endl; //cerr << "Choosing " << choice[0] << " for landing and " << choice[1] << "for takeoff" << endl;
@ -327,7 +327,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
nrActive = 0; nrActive = 0;
} }
void RunwayGroup::getActive(int i, string & name, string & type) void RunwayGroup::getActive(int i, std::string & name, std::string & type)
{ {
if (i == -1) { if (i == -1) {
return; return;
@ -394,7 +394,7 @@ ScheduleTime *FGRunwayPreference::getSchedule(const char *trafficType)
return 0; return 0;
} }
RunwayGroup *FGRunwayPreference::getGroup(const string & groupName) RunwayGroup *FGRunwayPreference::getGroup(const std::string & groupName)
{ {
PreferenceListIterator i = preferences.begin(); PreferenceListIterator i = preferences.begin();
if (preferences.begin() == preferences.end()) if (preferences.begin() == preferences.end())
@ -407,7 +407,7 @@ RunwayGroup *FGRunwayPreference::getGroup(const string & groupName)
return 0; return 0;
} }
string FGRunwayPreference::getId() std::string FGRunwayPreference::getId()
{ {
return _ap->getId(); return _ap->getId();
}; };

View file

@ -24,23 +24,18 @@
#ifndef _RUNWAYPREFS_HXX_ #ifndef _RUNWAYPREFS_HXX_
#define _RUNWAYPREFS_HXX_ #define _RUNWAYPREFS_HXX_
#include <time.h> #include "airports_fwd.hxx"
#include <vector>
#include <string>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <time.h>
using std::vector; typedef std::vector<time_t> timeVec;
using std::string; typedef std::vector<time_t>::const_iterator timeVecConstIterator;
typedef vector<time_t> timeVec; typedef std::vector<std::string> stringVec;
typedef vector<time_t>::const_iterator timeVecConstIterator; typedef std::vector<std::string>::iterator stringVecIterator;
typedef std::vector<std::string>::const_iterator stringVecConstIterator;
typedef vector<string> stringVec;
typedef vector<string>::iterator stringVecIterator;
typedef vector<string>::const_iterator stringVecConstIterator;
class FGAirport;
/***************************************************************************/ /***************************************************************************/
class ScheduleTime { class ScheduleTime {
@ -54,12 +49,12 @@ public:
ScheduleTime() : tailWind(0), crssWind(0) {}; ScheduleTime() : tailWind(0), crssWind(0) {};
ScheduleTime(const ScheduleTime &other); ScheduleTime(const ScheduleTime &other);
ScheduleTime &operator= (const ScheduleTime &other); ScheduleTime &operator= (const ScheduleTime &other);
string getName(time_t dayStart); std::string getName(time_t dayStart);
void clear(); void clear();
void addStartTime(time_t time) { start.push_back(time); }; void addStartTime(time_t time) { start.push_back(time); };
void addEndTime (time_t time) { end. push_back(time); }; void addEndTime (time_t time) { end. push_back(time); };
void addScheduleName(const string& sched) { scheduleNames.push_back(sched); }; void addScheduleName(const std::string& sched) { scheduleNames.push_back(sched); };
void setTailWind(double wnd) { tailWind = wnd; }; void setTailWind(double wnd) { tailWind = wnd; };
void setCrossWind(double wnd) { tailWind = wnd; }; void setCrossWind(double wnd) { tailWind = wnd; };
@ -73,32 +68,27 @@ public:
class RunwayList class RunwayList
{ {
private: private:
string type; std::string type;
stringVec preferredRunways; stringVec preferredRunways;
public: public:
RunwayList() {}; RunwayList() {};
RunwayList(const RunwayList &other); RunwayList(const RunwayList &other);
RunwayList& operator= (const RunwayList &other); RunwayList& operator= (const RunwayList &other);
void set(const string&, const string&); void set(const std::string&, const std::string&);
void clear(); void clear();
string getType() { return type; }; std::string getType() { return type; };
stringVec *getRwyList() { return &preferredRunways; }; stringVec *getRwyList() { return &preferredRunways; };
string getRwyList(int j) { return preferredRunways[j]; }; std::string getRwyList(int j) { return preferredRunways[j]; };
}; };
typedef vector<RunwayList> RunwayListVec;
typedef vector<RunwayList>::iterator RunwayListVectorIterator;
typedef vector<RunwayList>::const_iterator RunwayListVecConstIterator;
/*****************************************************************************/ /*****************************************************************************/
class RunwayGroup class RunwayGroup
{ {
private: private:
string name; std::string name;
RunwayListVec rwyList; RunwayListVec rwyList;
int active; int active;
//stringVec runwayNames; //stringVec runwayNames;
@ -110,22 +100,18 @@ public:
RunwayGroup(const RunwayGroup &other); RunwayGroup(const RunwayGroup &other);
RunwayGroup &operator= (const RunwayGroup &other); RunwayGroup &operator= (const RunwayGroup &other);
void setName(const string& nm) { name = nm; }; void setName(const std::string& nm) { name = nm; };
void add(const RunwayList& list) { rwyList.push_back(list);}; void add(const RunwayList& list) { rwyList.push_back(list);};
void setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr); void setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr);
int getNrActiveRunways() { return nrActive;}; int getNrActiveRunways() { return nrActive;};
void getActive(int i, string& name, string& type); void getActive(int i, std::string& name, std::string& type);
string getName() { return name; }; std::string getName() { return name; };
void clear() { rwyList.clear(); }; void clear() { rwyList.clear(); };
//void add(string, string); //void add(string, string);
}; };
typedef vector<RunwayGroup> PreferenceList;
typedef vector<RunwayGroup>::iterator PreferenceListIterator;
typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
/******************************************************************************/ /******************************************************************************/
class FGRunwayPreference { class FGRunwayPreference {
@ -148,9 +134,9 @@ public:
FGRunwayPreference & operator= (const FGRunwayPreference &other); FGRunwayPreference & operator= (const FGRunwayPreference &other);
ScheduleTime *getSchedule(const char *trafficType); ScheduleTime *getSchedule(const char *trafficType);
RunwayGroup *getGroup(const string& groupName); RunwayGroup *getGroup(const std::string& groupName);
string getId(); std::string getId();
bool available() { return initialized; }; bool available() { return initialized; };
void setInitialized(bool state) { initialized = state; }; void setInitialized(bool state) { initialized = state; };

View file

@ -130,12 +130,12 @@ void FGRunway::setReciprocalRunway(PositionedID other)
FGAirport* FGRunway::airport() const FGAirport* FGRunway::airport() const
{ {
return (FGAirport*) flightgear::NavDataCache::instance()->loadById(_airport); return loadById<FGAirport>(_airport);
} }
FGRunway* FGRunway::reciprocalRunway() const FGRunway* FGRunway::reciprocalRunway() const
{ {
return (FGRunway*) flightgear::NavDataCache::instance()->loadById(_reciprocal); return loadById<FGRunway>(_reciprocal);
} }
FGNavRecord* FGRunway::ILS() const FGNavRecord* FGRunway::ILS() const
@ -144,7 +144,7 @@ FGNavRecord* FGRunway::ILS() const
return NULL; return NULL;
} }
return (FGNavRecord*) flightgear::NavDataCache::instance()->loadById(_ils); return loadById<FGNavRecord>(_ils);
} }
FGNavRecord* FGRunway::glideslope() const FGNavRecord* FGRunway::glideslope() const
@ -158,10 +158,10 @@ FGNavRecord* FGRunway::glideslope() const
return (FGNavRecord*) cache->loadById(gsId); return (FGNavRecord*) cache->loadById(gsId);
} }
std::vector<flightgear::SID*> FGRunway::getSIDs() const flightgear::SIDList FGRunway::getSIDs() const
{ {
FGAirport* apt = airport(); FGAirport* apt = airport();
std::vector<flightgear::SID*> result; flightgear::SIDList result;
for (unsigned int i=0; i<apt->numSIDs(); ++i) { for (unsigned int i=0; i<apt->numSIDs(); ++i) {
flightgear::SID* s = apt->getSIDByIndex(i); flightgear::SID* s = apt->getSIDByIndex(i);
if (s->isForRunway(this)) { if (s->isForRunway(this)) {
@ -172,10 +172,10 @@ std::vector<flightgear::SID*> FGRunway::getSIDs() const
return result; return result;
} }
std::vector<flightgear::STAR*> FGRunway::getSTARs() const flightgear::STARList FGRunway::getSTARs() const
{ {
FGAirport* apt = airport(); FGAirport* apt = airport();
std::vector<flightgear::STAR*> result; flightgear::STARList result;
for (unsigned int i=0; i<apt->numSTARs(); ++i) { for (unsigned int i=0; i<apt->numSTARs(); ++i) {
flightgear::STAR* s = apt->getSTARByIndex(i); flightgear::STAR* s = apt->getSTARByIndex(i);
if (s->isForRunway(this)) { if (s->isForRunway(this)) {
@ -186,13 +186,17 @@ std::vector<flightgear::STAR*> FGRunway::getSTARs() const
return result; return result;
} }
std::vector<flightgear::Approach*> FGRunway::getApproaches() const flightgear::ApproachList
FGRunway::getApproaches(flightgear::ProcedureType type) const
{ {
FGAirport* apt = airport(); FGAirport* apt = airport();
std::vector<flightgear::Approach*> result; flightgear::ApproachList result;
for (unsigned int i=0; i<apt->numApproaches(); ++i) { for (unsigned int i=0; i<apt->numApproaches(); ++i)
{
flightgear::Approach* s = apt->getApproachByIndex(i); flightgear::Approach* s = apt->getApproachByIndex(i);
if (s->runway() == this) { if( s->runway() == this
&& (type == flightgear::PROCEDURE_INVALID || type == s->type()) )
{
result.push_back(s); result.push_back(s);
} }
} // of approaches at the airport iteration } // of approaches at the airport iteration

View file

@ -26,18 +26,9 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <Airports/runwaybase.hxx> #include <Navaids/procedure.hxx>
#include "runwaybase.hxx"
// forward decls #include "airports_fwd.hxx"
class FGAirport;
class FGNavRecord;
class SGPropertyNode;
namespace flightgear {
class SID;
class STAR;
class Approach;
}
class FGRunway : public FGRunwayBase class FGRunway : public FGRunwayBase
{ {
@ -113,15 +104,18 @@ public:
/** /**
* Get SIDs (DPs) associated with this runway * Get SIDs (DPs) associated with this runway
*/ */
std::vector<flightgear::SID*> getSIDs() const; flightgear::SIDList getSIDs() const;
/** /**
* Get STARs associared with this runway * Get STARs associared with this runway
*/ */
std::vector<flightgear::STAR*> getSTARs() const; flightgear::STARList getSTARs() const;
std::vector<flightgear::Approach*> getApproaches() const; flightgear::ApproachList getApproaches
(
flightgear::ProcedureType type = flightgear::PROCEDURE_INVALID
) const;
}; };

View file

@ -28,11 +28,9 @@
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx> #include <simgear/props/props_io.hxx>
#include <AIModel/AIFlightPlan.hxx>
#include <Airports/airport.hxx> #include <Airports/airport.hxx>
#include "sidstar.hxx" #include "sidstar.hxx"
using std::cerr; using std::cerr;
@ -119,4 +117,4 @@ FGAIFlightPlan *FGSidStar::getBest(string activeRunway, double heading)
} else { } else {
return 0; return 0;
} }
} }

View file

@ -23,29 +23,13 @@
#ifndef _SIDSTAR_HXX_ #ifndef _SIDSTAR_HXX_
#define _SIDSTAR_HXX_ #define _SIDSTAR_HXX_
#include <string> #include "airports_fwd.hxx"
#include <map> #include <ATC/trafficcontrol.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/xml/easyxml.hxx> #include <simgear/xml/easyxml.hxx>
#include <ATC/trafficcontrol.hxx> class FGSidStar
#include <AIModel/AIFlightPlan.hxx>
#include "parking.hxx"
#include "groundnetwork.hxx"
#include "runwayprefs.hxx"
class FGAirport;
typedef std::vector<FGAIFlightPlan*> FlightPlanVec;
typedef std::vector<FGAIFlightPlan*>::iterator FlightPlanVecIterator;
typedef std::map < std::string, FlightPlanVec > FlightPlanVecMap;
class FGSidStar
{ {
private: private:
std::string id; std::string id;
@ -61,6 +45,4 @@ class FGSidStar
FGAIFlightPlan *getBest(std::string activeRunway, double heading); FGAIFlightPlan *getBest(std::string activeRunway, double heading);
}; };
#endif
#endif

View file

@ -16,9 +16,7 @@
#ifndef _XML_LOADER_HXX_ #ifndef _XML_LOADER_HXX_
#define _XML_LOADER_HXX_ #define _XML_LOADER_HXX_
class FGAirportDynamics; #include "airports_fwd.hxx"
class FGRunwayPreference;
class FGSidStar;
class XMLVisitor; // ffrom easyxml.hxx class XMLVisitor; // ffrom easyxml.hxx

View file

@ -326,6 +326,12 @@ void FGPositioned::modifyPosition(const SGGeod& newPos)
const_cast<SGVec3d&>(mCart) = SGVec3d::fromGeod(newPos); const_cast<SGVec3d&>(mCart) = SGVec3d::fromGeod(newPos);
} }
//------------------------------------------------------------------------------
FGPositioned* FGPositioned::loadByIdImpl(PositionedID id)
{
return flightgear::NavDataCache::instance()->loadById(id);
}
FGPositioned::TypeFilter::TypeFilter(Type aTy) : FGPositioned::TypeFilter::TypeFilter(Type aTy) :
mMinType(aTy), mMinType(aTy),
mMaxType(aTy) mMaxType(aTy)

View file

@ -21,6 +21,7 @@
#ifndef FG_POSITIONED_HXX #ifndef FG_POSITIONED_HXX
#define FG_POSITIONED_HXX #define FG_POSITIONED_HXX
#include <cassert>
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdint.h> #include <stdint.h>
@ -128,6 +129,9 @@ public:
double elevation() const double elevation() const
{ return mPosition.getElevationFt(); } { return mPosition.getElevationFt(); }
double elevationM() const
{ return mPosition.getElevationM(); }
/** /**
* Predicate class to support custom filtering of FGPositioned queries * Predicate class to support custom filtering of FGPositioned queries
* Default implementation of this passes any FGPositioned instance. * Default implementation of this passes any FGPositioned instance.
@ -243,7 +247,33 @@ protected:
FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos); FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos);
void modifyPosition(const SGGeod& newPos); void modifyPosition(const SGGeod& newPos);
static FGPositioned* loadByIdImpl(PositionedID id);
template<class T>
static T* loadById(PositionedID id)
{
return static_cast<T*>( loadByIdImpl(id) );
}
template<class T>
static T* loadById(const PositionedIDVec& id_vec, size_t index)
{
assert(index >= 0 && index < id_vec.size());
return loadById<T>(id_vec[index]);
}
template<class T>
static std::vector<T*> loadAllById(const PositionedIDVec& id_vec)
{
std::vector<T*> vec(id_vec.size());
for(size_t i = 0; i < id_vec.size(); ++i)
vec[i] = loadById<T>(id_vec[i]);
return vec;
}
const PositionedID mGuid; const PositionedID mGuid;
const SGGeod mPosition; const SGGeod mPosition;
const SGVec3d mCart; const SGVec3d mCart;

View file

@ -24,6 +24,7 @@
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <Airports/runways.hxx>
#include <Navaids/waypoint.hxx> #include <Navaids/waypoint.hxx>
using std::string; using std::string;

View file

@ -23,9 +23,8 @@
#include <set> #include <set>
#include <simgear/math/sg_types.hxx> // for string_list #include <simgear/math/sg_types.hxx> // for string_list
#include <Airports/airports_fwd.hxx>
#include <Navaids/route.hxx> #include <Navaids/route.hxx>
#include <Airports/runways.hxx>
typedef SGSharedPtr<FGRunway> FGRunwayRef; typedef SGSharedPtr<FGRunway> FGRunwayRef;

View file

@ -164,16 +164,16 @@ naRef f_groupGetElementById(sc::Group& group, const nasal::CallContext& ctx)
); );
} }
naRef f_eventGetTarget(naContext c, sc::Event& event) naRef to_nasal_helper(naContext c, const sc::ElementWeakPtr& el)
{ {
return NasalElement::create(c, event.getTarget().lock()); return NasalElement::create(c, el.lock());
} }
naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave) naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
{ {
NasalEvent::init("canvas.Event") NasalEvent::init("canvas.Event")
.member("type", &sc::Event::getTypeString) .member("type", &sc::Event::getTypeString)
.member("target", &f_eventGetTarget) .member("target", &sc::Event::getTarget)
.method("stopPropagation", &sc::Event::stopPropagation); .method("stopPropagation", &sc::Event::stopPropagation);
NasalMouseEvent::init("canvas.MouseEvent") NasalMouseEvent::init("canvas.MouseEvent")
.bases<NasalEvent>() .bases<NasalEvent>()

View file

@ -462,7 +462,7 @@ static const char* wayptGhostGetMember(naContext c, void* g, naRef field, naRef*
static RouteRestriction routeRestrictionFromString(const char* s) static RouteRestriction routeRestrictionFromString(const char* s)
{ {
string u(s); std::string u(s);
boost::to_lower(u); boost::to_lower(u);
if (u == "computed") return RESTRICT_COMPUTED; if (u == "computed") return RESTRICT_COMPUTED;
if (u == "at") return RESTRICT_AT; if (u == "at") return RESTRICT_AT;
@ -728,7 +728,7 @@ static const char* procedureGhostGetMember(naContext c, void* g, naRef field, na
ArrivalDeparture* ad = static_cast<ArrivalDeparture*>(proc); ArrivalDeparture* ad = static_cast<ArrivalDeparture*>(proc);
*out = naNewVector(c); *out = naNewVector(c);
BOOST_FOREACH(string id, ad->transitionIdents()) { BOOST_FOREACH(std::string id, ad->transitionIdents()) {
naVec_append(*out, stringToNasal(c, id)); naVec_append(*out, stringToNasal(c, id));
} }
} else { } else {
@ -1112,7 +1112,7 @@ static naRef f_findAirportsByICAO(naContext c, naRef me, int argc, naRef* args)
} }
int argOffset = 0; int argOffset = 0;
string prefix(naStr_data(args[argOffset++])); std::string prefix(naStr_data(args[argOffset++]));
AirportInfoFilter filter; // defaults to airports only AirportInfoFilter filter; // defaults to airports only
if (argOffset < argc) { if (argOffset < argc) {
filter.fromArg(args[argOffset++]); filter.fromArg(args[argOffset++]);
@ -1213,26 +1213,6 @@ static naRef f_airport_runwaysWithoutReciprocals(naContext c, naRef me, int argc
return runways; return runways;
} }
static naRef f_airport_taxiway(naContext c, naRef me, int argc, naRef* args)
{
FGAirport* apt = airportGhost(me);
if (!apt) {
naRuntimeError(c, "airport.taxiway called on non-airport object");
}
if ((argc < 1) || !naIsString(args[0])) {
naRuntimeError(c, "airport.taxiway expects a taxiway ident argument");
}
naRef taxiways = naNewVector(c);
for (unsigned int i = 0; i < apt->numTaxiways(); i++) {
naVec_append(taxiways, ghostForTaxiway(c, apt->getTaxiwayByIndex(i)));
}
return taxiways;
}
static naRef f_airport_sids(naContext c, naRef me, int argc, naRef* args) static naRef f_airport_sids(naContext c, naRef me, int argc, naRef* args)
{ {
FGAirport* apt = airportGhost(me); FGAirport* apt = airportGhost(me);
@ -1417,7 +1397,7 @@ static naRef f_airport_getSid(naContext c, naRef me, int argc, naRef* args)
naRuntimeError(c, "airport.getSid passed invalid argument"); naRuntimeError(c, "airport.getSid passed invalid argument");
} }
string ident = naStr_data(args[0]); std::string ident = naStr_data(args[0]);
return ghostForProcedure(c, apt->findSIDWithIdent(ident)); return ghostForProcedure(c, apt->findSIDWithIdent(ident));
} }
@ -1432,7 +1412,7 @@ static naRef f_airport_getStar(naContext c, naRef me, int argc, naRef* args)
naRuntimeError(c, "airport.getStar passed invalid argument"); naRuntimeError(c, "airport.getStar passed invalid argument");
} }
string ident = naStr_data(args[0]); std::string ident = naStr_data(args[0]);
return ghostForProcedure(c, apt->findSTARWithIdent(ident)); return ghostForProcedure(c, apt->findSTARWithIdent(ident));
} }
@ -1447,7 +1427,7 @@ static naRef f_airport_getApproach(naContext c, naRef me, int argc, naRef* args)
naRuntimeError(c, "airport.getIAP passed invalid argument"); naRuntimeError(c, "airport.getIAP passed invalid argument");
} }
string ident = naStr_data(args[0]); std::string ident = naStr_data(args[0]);
return ghostForProcedure(c, apt->findApproachWithIdent(ident)); return ghostForProcedure(c, apt->findApproachWithIdent(ident));
} }
@ -1621,7 +1601,7 @@ static naRef f_findNavaidsByIdent(naContext c, naRef me, int argc, naRef* args)
} }
FGPositioned::Type type = FGPositioned::INVALID; FGPositioned::Type type = FGPositioned::INVALID;
string ident = naStr_data(args[argOffset++]); std::string ident = naStr_data(args[argOffset++]);
if (argOffset < argc) { if (argOffset < argc) {
type = FGPositioned::typeFromName(naStr_data(args[argOffset])); type = FGPositioned::typeFromName(naStr_data(args[argOffset]));
} }
@ -1647,7 +1627,7 @@ static naRef f_findFixesByIdent(naContext c, naRef me, int argc, naRef* args)
naRuntimeError(c, "findFixesByIdent expectes ident string as arg %d", argOffset); naRuntimeError(c, "findFixesByIdent expectes ident string as arg %d", argOffset);
} }
string ident(naStr_data(args[argOffset])); std::string ident(naStr_data(args[argOffset]));
naRef r = naNewVector(c); naRef r = naNewVector(c);
FGPositioned::TypeFilter filter(FGPositioned::FIX); FGPositioned::TypeFilter filter(FGPositioned::FIX);
@ -1954,7 +1934,7 @@ static naRef f_createWP(naContext c, naRef me, int argc, naRef* args)
naRuntimeError(c, "createWP: no identifier supplied"); naRuntimeError(c, "createWP: no identifier supplied");
} }
string ident = naStr_data(args[argOffset++]); std::string ident = naStr_data(args[argOffset++]);
WayptRef wpt = new BasicWaypt(pos, ident, NULL); WayptRef wpt = new BasicWaypt(pos, ident, NULL);
// set waypt flags - approach, departure, pseudo, etc // set waypt flags - approach, departure, pseudo, etc
@ -2430,7 +2410,6 @@ naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave)
hashset(c, airportPrototype, "runway", naNewFunc(c, naNewCCode(c, f_airport_runway))); hashset(c, airportPrototype, "runway", naNewFunc(c, naNewCCode(c, f_airport_runway)));
hashset(c, airportPrototype, "runwaysWithoutReciprocals", naNewFunc(c, naNewCCode(c, f_airport_runwaysWithoutReciprocals))); hashset(c, airportPrototype, "runwaysWithoutReciprocals", naNewFunc(c, naNewCCode(c, f_airport_runwaysWithoutReciprocals)));
hashset(c, airportPrototype, "helipad", naNewFunc(c, naNewCCode(c, f_airport_runway))); hashset(c, airportPrototype, "helipad", naNewFunc(c, naNewCCode(c, f_airport_runway)));
hashset(c, airportPrototype, "taxiway", naNewFunc(c, naNewCCode(c, f_airport_taxiway)));
hashset(c, airportPrototype, "tower", naNewFunc(c, naNewCCode(c, f_airport_tower))); hashset(c, airportPrototype, "tower", naNewFunc(c, naNewCCode(c, f_airport_tower)));
hashset(c, airportPrototype, "comms", naNewFunc(c, naNewCCode(c, f_airport_comms))); hashset(c, airportPrototype, "comms", naNewFunc(c, naNewCCode(c, f_airport_comms)));
hashset(c, airportPrototype, "sids", naNewFunc(c, naNewCCode(c, f_airport_sids))); hashset(c, airportPrototype, "sids", naNewFunc(c, naNewCCode(c, f_airport_sids)));

View file

@ -140,8 +140,8 @@ class FGAISchedule
}; };
typedef vector<FGAISchedule*> ScheduleVector; typedef std::vector<FGAISchedule*> ScheduleVector;
typedef vector<FGAISchedule*>::iterator ScheduleVectorIterator; typedef std::vector<FGAISchedule*>::iterator ScheduleVectorIterator;
bool compareSchedules(FGAISchedule*a, FGAISchedule*b); bool compareSchedules(FGAISchedule*a, FGAISchedule*b);