NavData API additions
This commit is contained in:
parent
71a1348037
commit
552df27341
9 changed files with 61 additions and 3 deletions
|
@ -52,6 +52,9 @@ class FGAirport : public FGPositioned
|
|||
const std::string& name, bool has_metar, Type aType);
|
||||
~FGAirport();
|
||||
|
||||
static bool isType(FGPositioned::Type ty)
|
||||
{ return (ty >= FGPositioned::AIRPORT) && (ty <= FGPositioned::SEAPORT); }
|
||||
|
||||
const std::string& getId() const { return ident(); }
|
||||
const std::string& getName() const { return _name; }
|
||||
std::string toString() const { return "an airport " + ident(); }
|
||||
|
|
|
@ -451,6 +451,18 @@ FGParkingRef FGGroundNetwork::getParkingByIndex(unsigned int index) const
|
|||
return FGParkingRef(static_cast<FGParking*>(tn.ptr()));
|
||||
}
|
||||
|
||||
FGParkingRef FGGroundNetwork::findParkingByName(const string &name) const
|
||||
{
|
||||
auto it = std::find_if(m_parkings.begin(), m_parkings.end(), [name](const FGParkingRef& p) {
|
||||
return p->ident() == name;
|
||||
});
|
||||
|
||||
if (it == m_parkings.end())
|
||||
return nullptr;
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
void FGGroundNetwork::addSegment(const FGTaxiNodeRef &from, const FGTaxiNodeRef &to)
|
||||
{
|
||||
FGTaxiSegment* seg = new FGTaxiSegment(from, to);
|
||||
|
|
|
@ -259,6 +259,8 @@ public:
|
|||
|
||||
FGParkingRef getParkingByIndex(unsigned int index) const;
|
||||
|
||||
FGParkingRef findParkingByName(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Find the taxiway segment joining two (ground-net) nodes. Returns
|
||||
* NULL if no such segment exists.
|
||||
|
|
|
@ -49,6 +49,9 @@ private:
|
|||
|
||||
SG_DISABLE_COPY(FGParking);
|
||||
public:
|
||||
static bool isType(FGPositioned::Type ty)
|
||||
{ return (ty == FGPositioned::PARKING); }
|
||||
|
||||
FGParking(int index,
|
||||
const SGGeod& pos,
|
||||
double heading, double radius,
|
||||
|
|
|
@ -38,7 +38,9 @@ class FGRunway : public FGRunwayBase
|
|||
double _stopway;
|
||||
PositionedID _ils;
|
||||
public:
|
||||
|
||||
static bool isType(FGPositioned::Type ty)
|
||||
{ return (ty == FGPositioned::RUNWAY); }
|
||||
|
||||
FGRunway(PositionedID aGuid,
|
||||
PositionedID aAirport, const std::string& rwy_no,
|
||||
const SGGeod& aGeod,
|
||||
|
@ -126,6 +128,9 @@ public:
|
|||
class FGHelipad : public FGRunwayBase
|
||||
{
|
||||
public:
|
||||
static bool isType(FGPositioned::Type ty)
|
||||
{ return (ty == FGPositioned::HELIPAD); }
|
||||
|
||||
FGHelipad(PositionedID aGuid,
|
||||
PositionedID aAirport, const std::string& rwy_no,
|
||||
const SGGeod& aGeod,
|
||||
|
|
|
@ -1713,7 +1713,7 @@ void NavDataCache::abortTransaction()
|
|||
|
||||
FGPositionedRef NavDataCache::loadById(PositionedID rowid)
|
||||
{
|
||||
if (rowid == 0) {
|
||||
if (rowid < 1) {
|
||||
return NULL;
|
||||
}
|
||||
if (!d) return NULL;
|
||||
|
|
|
@ -110,7 +110,12 @@ bool FGNavRecord::isVORTAC() const
|
|||
|
||||
void FGNavRecord::setColocatedDME(PositionedID other)
|
||||
{
|
||||
mColocated = other;
|
||||
mColocated = other;
|
||||
}
|
||||
|
||||
PositionedID FGNavRecord::colocatedDME() const
|
||||
{
|
||||
return mColocated;
|
||||
}
|
||||
|
||||
void FGNavRecord::updateFromXML(const SGGeod& geod, double heading)
|
||||
|
|
|
@ -56,6 +56,9 @@ class FGNavRecord : public FGPositioned
|
|||
mutable bool serviceable; // for failure modeling
|
||||
|
||||
public:
|
||||
static bool isType(FGPositioned::Type ty)
|
||||
{ return (ty >= FGPositioned::NDB) && (ty <= FGPositioned::DME); }
|
||||
|
||||
FGNavRecord( PositionedID aGuid,
|
||||
Type type,
|
||||
const std::string& ident,
|
||||
|
@ -98,8 +101,11 @@ class FGNavRecord : public FGPositioned
|
|||
void unbindFromNode(SGPropertyNode* nd) const;
|
||||
|
||||
void setColocatedDME(PositionedID other);
|
||||
|
||||
bool hasDME() const;
|
||||
|
||||
PositionedID colocatedDME() const;
|
||||
|
||||
bool isVORTAC() const;
|
||||
|
||||
void updateFromXML(const SGGeod& geod, double heading);
|
||||
|
|
|
@ -302,4 +302,26 @@ private:
|
|||
const SGVec3d mCart;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
T* fgpositioned_cast(FGPositioned* p)
|
||||
{
|
||||
if (T::isType(p->type())) {
|
||||
return static_cast<T*>(p);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* fgpositioned_cast(FGPositionedRef p)
|
||||
{
|
||||
if (!p) return nullptr;
|
||||
|
||||
if (T::isType(p->type())) {
|
||||
return static_cast<T*>(p.ptr());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // of FG_POSITIONED_HXX
|
||||
|
|
Loading…
Reference in a new issue