_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
if (material) {
- const vector<string>& names = material->get_names();
+ const std::vector<std::string>& names = material->get_names();
_solid = material->get_solid();
int mRangeNM;
int mFreqKhz;
PositionedID mAirport;
-};
-
+};
+
} // of namespace flightgear
#endif // of FG_ATC_COMM_STATION_HXX
//class FGATCController;
-typedef vector<FGATCController*> AtcVec;
-typedef vector<FGATCController*>::iterator AtcVecIterator;
+typedef std::vector<FGATCController*> AtcVec;
+typedef std::vector<FGATCController*>::iterator AtcVecIterator;
class FGATCManager : public SGSubsystem
{
#ifndef _TRAFFIC_CONTROL_HXX_
#define _TRAFFIC_CONTROL_HXX_
-#include <string>
-#include <vector>
-#include <list>
+#include <Airports/airports_fwd.hxx>
#include <osg/Geode>
#include <osg/Geometry>
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
-typedef std::vector<int> intVec;
-typedef std::vector<int>::iterator intVecIterator;
+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 FGAIFlightPlan; // forward reference
-class FGGroundNetwork; // forward reference
-class FGAIAircraft; // forward reference
-class FGAirportDynamics;
+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>::iterator intVecIterator;
/**************************************************************************************
* class FGATCInstruction
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
* clearance for a given runway.
void printDepartureCue();
};
-typedef std::vector<ActiveRunway> ActiveRunwayVec;
-typedef std::vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
-
/**
* class FGATCController
* NOTE: this class serves as an abstraction layer for all sorts of ATC controllers.
// Note that at this point, multi-word facility names
// 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(" -"));
- for (vector<string>::const_iterator wordp = name_words.begin();
+ for( std::vector<string>::const_iterator wordp = name_words.begin();
wordp != name_words.end(); wordp++) {
string word(*wordp);
// Remap some abbreviations that occur in apt.dat, to
)
set(HEADERS
+ airports_fwd.hxx
apt_loader.hxx
dynamicloader.hxx
dynamics.hxx
using namespace flightgear;
-
/***************************************************************************
* FGAirport
***************************************************************************/
AirportCache FGAirport::airportCache;
-FGAirport::FGAirport(PositionedID aGuid, const string &id, const SGGeod& location,
- const string &name, bool has_metar, Type aType) :
+FGAirport::FGAirport( PositionedID aGuid,
+ const std::string &id,
+ const SGGeod& location,
+ const std::string &name,
+ bool has_metar,
+ Type aType ):
FGPositioned(aGuid, aType, id, location),
_name(name),
_has_metar(has_metar),
return _dynamics;
}
+//------------------------------------------------------------------------------
unsigned int FGAirport::numRunways() const
{
loadRunways();
return mRunways.size();
}
+//------------------------------------------------------------------------------
unsigned int FGAirport::numHelipads() const
{
loadHelipads();
return mHelipads.size();
}
+//------------------------------------------------------------------------------
FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const
{
loadRunways();
-
- assert(aIndex >= 0 && aIndex < mRunways.size());
- return (FGRunway*) flightgear::NavDataCache::instance()->loadById(mRunways[aIndex]);
+ return loadById<FGRunway>(mRunways, aIndex);
}
+//------------------------------------------------------------------------------
FGHelipad* FGAirport::getHelipadByIndex(unsigned int aIndex) const
{
loadHelipads();
+ return loadById<FGHelipad>(mHelipads, aIndex);
+}
+
+//------------------------------------------------------------------------------
+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;
- assert(aIndex >= 0 && aIndex < mHelipads.size());
- return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(mHelipads[aIndex]);
+ BOOST_FOREACH(PositionedID id, mHelipads)
+ {
+ FGHelipad* rwy = loadById<FGHelipad>(id);
+ map[ rwy->ident() ] = rwy;
+ }
+
+ return map;
}
-bool FGAirport::hasRunwayWithIdent(const string& aIdent) const
+//------------------------------------------------------------------------------
+bool FGAirport::hasRunwayWithIdent(const std::string& aIdent) const
{
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;
}
-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);
if (id == 0) {
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);
if (id == 0) {
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
{
loadRunways();
double deviationWeight = param->getDoubleValue("deviation-weight", 1);
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 dev = aHeading - rwy->headingDeg();
SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
return result;
}
+//------------------------------------------------------------------------------
FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
{
loadRunways();
double currentLowestDev = 180.0;
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 dev = inboundCourse - rwy->headingDeg();
}
+//------------------------------------------------------------------------------
bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
{
loadRunways();
BOOST_FOREACH(PositionedID id, mRunways) {
- FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+ FGRunway* rwy = loadById<FGRunway>(id);
if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) {
return true; // we're done!
}
return false;
}
+//------------------------------------------------------------------------------
FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
{
loadRunways();
FGRunwayList r;
BOOST_FOREACH(PositionedID id, mRunways) {
- FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+ FGRunway* rwy = loadById<FGRunway>(id);
FGRunway* recip = rwy->reciprocalRunway();
if (recip) {
FGRunwayList::iterator it = std::find(r.begin(), r.end(), recip);
return r;
}
+//------------------------------------------------------------------------------
unsigned int FGAirport::numTaxiways() const
{
loadTaxiways();
return mTaxiways.size();
}
+//------------------------------------------------------------------------------
FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const
{
loadTaxiways();
-
- assert(aIndex >= 0 && aIndex < mTaxiways.size());
- return (FGTaxiway*) flightgear::NavDataCache::instance()->loadById(mTaxiways[aIndex]);
+ return loadById<FGTaxiway>(mTaxiways, aIndex);
+}
+
+//------------------------------------------------------------------------------
+FGTaxiwayList FGAirport::getTaxiways() const
+{
+ loadTaxiways();
+ return loadAllById<FGTaxiway>(mTaxiways);
}
+//------------------------------------------------------------------------------
unsigned int FGAirport::numPavements() const
{
loadTaxiways();
return mPavements.size();
}
+//------------------------------------------------------------------------------
FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
{
loadTaxiways();
- assert(aIndex >= 0 && aIndex < mPavements.size());
- return (FGPavement*) flightgear::NavDataCache::instance()->loadById(mPavements[aIndex]);
+ return loadById<FGPavement>(mPavements, aIndex);
}
+//------------------------------------------------------------------------------
+FGPavementList FGAirport::getPavements() const
+{
+ loadTaxiways();
+ return loadAllById<FGPavement>(mPavements);
+}
+
+//------------------------------------------------------------------------------
FGRunway* FGAirport::getActiveRunwayForUsage() const
{
FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
}
// find basic airport location info from airport database
-const FGAirport *fgFindAirportID( const string& id)
+const FGAirport *fgFindAirportID( const std::string& id)
{
if ( id.empty() ) {
return NULL;
void FGAirport::processThreshold(SGPropertyNode* aThreshold)
{
// first, let's identify the current runway
- string rwyIdent(aThreshold->getStringValue("rwy"));
+ std::string rwyIdent(aThreshold->getStringValue("rwy"));
NavDataCache* cache = NavDataCache::instance();
PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent);
if (id == 0) {
mApproaches.push_back(aApp);
}
+//------------------------------------------------------------------------------
unsigned int FGAirport::numSIDs() const
{
loadProcedures();
return mSIDs.size();
}
+//------------------------------------------------------------------------------
flightgear::SID* FGAirport::getSIDByIndex(unsigned int aIndex) const
{
loadProcedures();
return mSIDs[aIndex];
}
+//------------------------------------------------------------------------------
flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
{
loadProcedures();
return NULL;
}
+//------------------------------------------------------------------------------
+flightgear::SIDList FGAirport::getSIDs() const
+{
+ loadProcedures();
+ return flightgear::SIDList(mSIDs.begin(), mSIDs.end());
+}
+
+//------------------------------------------------------------------------------
unsigned int FGAirport::numSTARs() const
{
loadProcedures();
return mSTARs.size();
}
+//------------------------------------------------------------------------------
STAR* FGAirport::getSTARByIndex(unsigned int aIndex) const
{
loadProcedures();
return mSTARs[aIndex];
}
+//------------------------------------------------------------------------------
STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
{
loadProcedures();
return NULL;
}
+//------------------------------------------------------------------------------
+STARList FGAirport::getSTARs() const
+{
+ loadProcedures();
+ return STARList(mSTARs.begin(), mSTARs.end());
+}
+
unsigned int FGAirport::numApproaches() const
{
loadProcedures();
return mApproaches.size();
}
+//------------------------------------------------------------------------------
Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
{
loadProcedures();
return mApproaches[aIndex];
}
+//------------------------------------------------------------------------------
Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
{
loadProcedures();
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
FGAirport::commStations() const
{
}
// get airport elevation
-double fgGetAirportElev( const string& id )
+double fgGetAirportElev( const std::string& id )
{
const FGAirport *a=fgFindAirportID( id);
if (a) {
// get airport position
-SGGeod fgGetAirportPos( const string& id )
+SGGeod fgGetAirportPos( const std::string& id )
{
const FGAirport *a = fgFindAirportID( id);
#include <map>
#include <Navaids/positioned.hxx>
-#include <Airports/runways.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 <Navaids/procedure.hxx>
+#include "airports_fwd.hxx"
+#include "runways.hxx"
/***************************************************************************************
*
unsigned int numHelipads() const;
FGRunway* getRunwayByIndex(unsigned int aIndex) const;
FGHelipad* getHelipadByIndex(unsigned int aIndex) const;
+ FGRunwayMap getRunwayMap() const;
+ FGHelipadMap getHelipadMap() const;
bool hasRunwayWithIdent(const std::string& aIdent) const;
bool hasHelipadWithIdent(const std::string& aIdent) const;
unsigned int numTaxiways() const;
FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
+ FGTaxiwayList getTaxiways() const;
unsigned int numPavements() const;
FGPavement* getPavementByIndex(unsigned int aIndex) const;
+ FGPavementList getPavements() const;
class AirportFilter : public Filter
{
unsigned int numSIDs() const;
flightgear::SID* getSIDByIndex(unsigned int aIndex) const;
flightgear::SID* findSIDWithIdent(const std::string& aIdent) const;
+ flightgear::SIDList getSIDs() const;
unsigned int numSTARs() const;
flightgear::STAR* getSTARByIndex(unsigned int aIndex) const;
flightgear::STAR* findSTARWithIdent(const std::string& aIdent) const;
+ flightgear::STARList getSTARs() const;
unsigned int numApproaches() const;
flightgear::Approach* getApproachByIndex(unsigned int aIndex) 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
--- /dev/null
+/*
+ * 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_ */
#include <set>
#include <ATC/trafficcontrol.hxx>
+#include "airports_fwd.hxx"
#include "parking.hxx"
#include "groundnetwork.hxx"
#include "runwayprefs.hxx"
-// forward decls
-class FGAirport;
-class FGEnvironment;
-
class ParkingAssignment
{
public:
FGAirport* parent() const
{ 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
bool getIsOnRunway() const { return isOnRunway; };
};
-typedef SGSharedPtr<FGTaxiNode> FGTaxiNode_ptr;
-typedef std::vector<FGTaxiNode_ptr> FGTaxiNodeVector;
-typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
-
#endif
{}
double score;
- FGTaxiNode_ptr previousNode;
+ FGTaxiNodeRef previousNode;
};
FGTaxiRoute FGGroundNetwork::findShortestRoute(PositionedID start, PositionedID end,
#include <simgear/compiler.h>
#include <string>
-#include <vector>
-#include <list>
-#include <map>
#include "gnnode.hxx"
#include "parking.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
{
private:
bool operator< (const Block &other) const { return blocktime < other.blocktime; };
};
-typedef std::vector<Block> BlockList;
-typedef BlockList::iterator BlockListIterator;
-
/***************************************************************************************
* class FGTaxiSegment
**************************************************************************************/
};
};
-
-
-
-typedef std::vector<int> intVec;
-typedef std::vector<int>::iterator intVecIterator;
-
-
-
/***************************************************************************************
* class FGTaxiRoute
**************************************************************************************/
};
};
-typedef std::vector<FGTaxiRoute> TaxiRouteVector;
-typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
-
/**************************************************************************************
* class FGGroundNetWork
*************************************************************************************/
#include <simgear/sg_inlines.h>
#include <string>
-#include <vector>
#include <memory> // for std::auto_ptr
#include "gnnode.hxx"
return radius < other.radius; };
};
-typedef std::vector<FGParking*> FGParkingVec;
-typedef FGParkingVec::iterator FGParkingVecIterator;
-typedef FGParkingVec::const_iterator FGParkingVecConstIterator;
-
#endif
return *this;
}
-string ScheduleTime::getName(time_t dayStart)
+std::string ScheduleTime::getName(time_t dayStart)
{
if ((start.size() != end.size())
|| (start.size() != scheduleNames.size())) {
//couldn't find one so return 0;
//cerr << "Returning 0 " << endl;
}
- return string("");
+ return std::string("");
}
/******************************************************************************
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());
// timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
// timeCopy = timeCopy.substr(2,timeCopy.length());
type = tp;
- string rwys = lst;
- string rwy;
- while (rwys.find(",") != string::npos) {
+ std::string rwys = lst;
+ std::string rwy;
+ while (rwys.find(",") != std::string::npos) {
rwy = rwys.substr(0, rwys.find(",", 0));
//cerr << "adding runway [" << rwy << "] to the list " << endl;
preferredRunways.push_back(rwy);
double hdgDiff;
double crossWind;
double tailWind;
- string name;
+ std::string name;
//stringVec names;
int bestMatch = 0, bestChoice = 0;
validSelection = true;
for (int j = 0; j < activeRwys; j++) {
- string ident(rwyList[j].getRwyList(i));
+ std::string ident(rwyList[j].getRwyList(i));
if (!airport->hasRunwayWithIdent(ident)) {
SG_LOG(SG_GENERAL, SG_WARN,
"no such runway:" << ident << " at " <<
choice[0] = 0;
choice[1] = 0;
for (int i = activeRwys - 1; i; i--) {
- if (rwyList[i].getType() == string("landing"))
+ if (rwyList[i].getType() == std::string("landing"))
choice[0] = i;
- if (rwyList[i].getType() == string("takeoff"))
+ if (rwyList[i].getType() == std::string("takeoff"))
choice[1] = i;
}
//cerr << "Choosing " << choice[0] << " for landing and " << choice[1] << "for takeoff" << endl;
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) {
return;
return 0;
}
-RunwayGroup *FGRunwayPreference::getGroup(const string & groupName)
+RunwayGroup *FGRunwayPreference::getGroup(const std::string & groupName)
{
PreferenceListIterator i = preferences.begin();
if (preferences.begin() == preferences.end())
return 0;
}
-string FGRunwayPreference::getId()
+std::string FGRunwayPreference::getId()
{
return _ap->getId();
};
#ifndef _RUNWAYPREFS_HXX_
#define _RUNWAYPREFS_HXX_
-#include <time.h>
-#include <vector>
-#include <string>
+#include "airports_fwd.hxx"
#include <simgear/compiler.h>
+#include <time.h>
-using std::vector;
-using std::string;
-
-typedef vector<time_t> timeVec;
-typedef vector<time_t>::const_iterator timeVecConstIterator;
+typedef std::vector<time_t> timeVec;
+typedef std::vector<time_t>::const_iterator timeVecConstIterator;
-typedef vector<string> stringVec;
-typedef vector<string>::iterator stringVecIterator;
-typedef vector<string>::const_iterator stringVecConstIterator;
+typedef std::vector<std::string> stringVec;
+typedef std::vector<std::string>::iterator stringVecIterator;
+typedef std::vector<std::string>::const_iterator stringVecConstIterator;
-class FGAirport;
/***************************************************************************/
class ScheduleTime {
ScheduleTime() : tailWind(0), crssWind(0) {};
ScheduleTime(const ScheduleTime &other);
ScheduleTime &operator= (const ScheduleTime &other);
- string getName(time_t dayStart);
+ std::string getName(time_t dayStart);
void clear();
void addStartTime(time_t time) { start.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 setCrossWind(double wnd) { tailWind = wnd; };
class RunwayList
{
private:
- string type;
+ std::string type;
stringVec preferredRunways;
public:
RunwayList() {};
RunwayList(const RunwayList &other);
RunwayList& operator= (const RunwayList &other);
- void set(const string&, const string&);
+ void set(const std::string&, const std::string&);
void clear();
- string getType() { return type; };
+ std::string getType() { return type; };
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
{
private:
- string name;
+ std::string name;
RunwayListVec rwyList;
int active;
//stringVec runwayNames;
RunwayGroup(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 setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr);
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 add(string, string);
};
-typedef vector<RunwayGroup> PreferenceList;
-typedef vector<RunwayGroup>::iterator PreferenceListIterator;
-typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
-
/******************************************************************************/
class FGRunwayPreference {
FGRunwayPreference & operator= (const FGRunwayPreference &other);
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; };
void setInitialized(bool state) { initialized = state; };
FGAirport* FGRunway::airport() const
{
- return (FGAirport*) flightgear::NavDataCache::instance()->loadById(_airport);
+ return loadById<FGAirport>(_airport);
}
FGRunway* FGRunway::reciprocalRunway() const
{
- return (FGRunway*) flightgear::NavDataCache::instance()->loadById(_reciprocal);
+ return loadById<FGRunway>(_reciprocal);
}
FGNavRecord* FGRunway::ILS() const
return NULL;
}
- return (FGNavRecord*) flightgear::NavDataCache::instance()->loadById(_ils);
+ return loadById<FGNavRecord>(_ils);
}
FGNavRecord* FGRunway::glideslope() const
return (FGNavRecord*) cache->loadById(gsId);
}
-std::vector<flightgear::SID*> FGRunway::getSIDs() const
+flightgear::SIDList FGRunway::getSIDs() const
{
FGAirport* apt = airport();
- std::vector<flightgear::SID*> result;
+ flightgear::SIDList result;
for (unsigned int i=0; i<apt->numSIDs(); ++i) {
flightgear::SID* s = apt->getSIDByIndex(i);
if (s->isForRunway(this)) {
return result;
}
-std::vector<flightgear::STAR*> FGRunway::getSTARs() const
+flightgear::STARList FGRunway::getSTARs() const
{
FGAirport* apt = airport();
- std::vector<flightgear::STAR*> result;
+ flightgear::STARList result;
for (unsigned int i=0; i<apt->numSTARs(); ++i) {
flightgear::STAR* s = apt->getSTARByIndex(i);
if (s->isForRunway(this)) {
return result;
}
-std::vector<flightgear::Approach*> FGRunway::getApproaches() const
+flightgear::ApproachList
+FGRunway::getApproaches(flightgear::ProcedureType type) const
{
FGAirport* apt = airport();
- std::vector<flightgear::Approach*> result;
- for (unsigned int i=0; i<apt->numApproaches(); ++i) {
+ flightgear::ApproachList result;
+ for (unsigned int i=0; i<apt->numApproaches(); ++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);
}
} // of approaches at the airport iteration
#include <simgear/compiler.h>
-#include <Airports/runwaybase.hxx>
-
-// forward decls
-class FGAirport;
-class FGNavRecord;
-class SGPropertyNode;
-
-namespace flightgear {
- class SID;
- class STAR;
- class Approach;
-}
+#include <Navaids/procedure.hxx>
+#include "runwaybase.hxx"
+#include "airports_fwd.hxx"
class FGRunway : public FGRunwayBase
{
/**
* Get SIDs (DPs) associated with this runway
*/
- std::vector<flightgear::SID*> getSIDs() const;
+ flightgear::SIDList getSIDs() const;
/**
* 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;
};
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
-
-
+#include <AIModel/AIFlightPlan.hxx>
#include <Airports/airport.hxx>
-
#include "sidstar.hxx"
using std::cerr;
} else {
return 0;
}
-}
\ No newline at end of file
+}
#ifndef _SIDSTAR_HXX_
#define _SIDSTAR_HXX_
-#include <string>
-#include <map>
+#include "airports_fwd.hxx"
+#include <ATC/trafficcontrol.hxx>
#include <simgear/misc/sg_path.hxx>
-
#include <simgear/xml/easyxml.hxx>
-#include <ATC/trafficcontrol.hxx>
-#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
+class FGSidStar
{
private:
std::string id;
FGAIFlightPlan *getBest(std::string activeRunway, double heading);
};
-
-
-#endif
\ No newline at end of file
+#endif
#ifndef _XML_LOADER_HXX_
#define _XML_LOADER_HXX_
-class FGAirportDynamics;
-class FGRunwayPreference;
-class FGSidStar;
+#include "airports_fwd.hxx"
class XMLVisitor; // ffrom easyxml.hxx
const_cast<SGVec3d&>(mCart) = SGVec3d::fromGeod(newPos);
}
+//------------------------------------------------------------------------------
+FGPositioned* FGPositioned::loadByIdImpl(PositionedID id)
+{
+ return flightgear::NavDataCache::instance()->loadById(id);
+}
+
FGPositioned::TypeFilter::TypeFilter(Type aTy) :
mMinType(aTy),
mMaxType(aTy)
#ifndef FG_POSITIONED_HXX
#define FG_POSITIONED_HXX
+#include <cassert>
#include <string>
#include <vector>
#include <stdint.h>
double elevation() const
{ return mPosition.getElevationFt(); }
+ double elevationM() const
+ { return mPosition.getElevationM(); }
+
/**
* Predicate class to support custom filtering of FGPositioned queries
* Default implementation of this passes any FGPositioned instance.
FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos);
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 SGGeod mPosition;
const SGVec3d mCart;
#include <simgear/structure/exception.hxx>
+#include <Airports/runways.hxx>
#include <Navaids/waypoint.hxx>
using std::string;
#include <set>
#include <simgear/math/sg_types.hxx> // for string_list
-
+#include <Airports/airports_fwd.hxx>
#include <Navaids/route.hxx>
-#include <Airports/runways.hxx>
typedef SGSharedPtr<FGRunway> FGRunwayRef;
);
}
-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)
{
NasalEvent::init("canvas.Event")
.member("type", &sc::Event::getTypeString)
- .member("target", &f_eventGetTarget)
+ .member("target", &sc::Event::getTarget)
.method("stopPropagation", &sc::Event::stopPropagation);
NasalMouseEvent::init("canvas.MouseEvent")
.bases<NasalEvent>()
static RouteRestriction routeRestrictionFromString(const char* s)
{
- string u(s);
+ std::string u(s);
boost::to_lower(u);
if (u == "computed") return RESTRICT_COMPUTED;
if (u == "at") return RESTRICT_AT;
ArrivalDeparture* ad = static_cast<ArrivalDeparture*>(proc);
*out = naNewVector(c);
- BOOST_FOREACH(string id, ad->transitionIdents()) {
+ BOOST_FOREACH(std::string id, ad->transitionIdents()) {
naVec_append(*out, stringToNasal(c, id));
}
} else {
}
int argOffset = 0;
- string prefix(naStr_data(args[argOffset++]));
+ std::string prefix(naStr_data(args[argOffset++]));
AirportInfoFilter filter; // defaults to airports only
if (argOffset < argc) {
filter.fromArg(args[argOffset++]);
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)
{
FGAirport* apt = airportGhost(me);
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));
}
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));
}
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));
}
}
FGPositioned::Type type = FGPositioned::INVALID;
- string ident = naStr_data(args[argOffset++]);
+ std::string ident = naStr_data(args[argOffset++]);
if (argOffset < argc) {
type = FGPositioned::typeFromName(naStr_data(args[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);
FGPositioned::TypeFilter filter(FGPositioned::FIX);
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);
// set waypt flags - approach, departure, pseudo, etc
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, "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, "comms", naNewFunc(c, naNewCCode(c, f_airport_comms)));
hashset(c, airportPrototype, "sids", naNewFunc(c, naNewCCode(c, f_airport_sids)));
};
-typedef vector<FGAISchedule*> ScheduleVector;
-typedef vector<FGAISchedule*>::iterator ScheduleVectorIterator;
+typedef std::vector<FGAISchedule*> ScheduleVector;
+typedef std::vector<FGAISchedule*>::iterator ScheduleVectorIterator;
bool compareSchedules(FGAISchedule*a, FGAISchedule*b);