Add FGPositioned static methods: isAirportType(), isRunwayType(), isNavaidType()
For consistency, define these three static methods in FGPositioned. FGPositioned::isAirportType() is the same as FGAirport::isAirportType() (piece of code moved from airport.cxx to positioned.cxx, and FGAirport::isAirportType() now calls FGPositioned::isAirportType()). - FGPositioned::isAirportType() returns true for AIRPORT, HELIPORT, SEAPORT; - FGPositioned::isRunwayType() returns true for RUNWAY; - FGPositioned::isNavaidType() returns true for NDB, VOR, ILS, LOC, GS, DME, TACAN.
This commit is contained in:
parent
9d4cbb005f
commit
91470cbc54
4 changed files with 53 additions and 6 deletions
|
@ -51,6 +51,7 @@
|
|||
#include <ATC/CommStation.hxx>
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
#include <Navaids/navrecord.hxx>
|
||||
#include <Navaids/positioned.hxx>
|
||||
#include <Airports/groundnetwork.hxx>
|
||||
#include <Airports/xmlloader.hxx>
|
||||
|
||||
|
@ -106,13 +107,10 @@ bool FGAirport::isHeliport() const
|
|||
return type() == HELIPORT;
|
||||
}
|
||||
|
||||
// Static method
|
||||
bool FGAirport::isAirportType(FGPositioned* pos)
|
||||
{
|
||||
if (!pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (pos->type() >= AIRPORT) && (pos->type() <= SEAPORT);
|
||||
return FGPositioned::isAirportType(pos);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -74,8 +74,10 @@ class FGAirport : public FGPositioned
|
|||
return mIsClosed;
|
||||
}
|
||||
|
||||
// True for the following types: AIRPORT, HELIPORT, SEAPORT.
|
||||
// False for other types, as well as if pos == nullptr.
|
||||
static bool isAirportType(FGPositioned* pos);
|
||||
|
||||
|
||||
virtual const std::string& name() const
|
||||
{ return _name; }
|
||||
|
||||
|
|
|
@ -85,6 +85,43 @@ FGPositioned::~FGPositioned()
|
|||
{
|
||||
}
|
||||
|
||||
// Static method
|
||||
bool FGPositioned::isAirportType(FGPositioned* pos)
|
||||
{
|
||||
if (!pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (pos->type() >= AIRPORT) && (pos->type() <= SEAPORT);
|
||||
}
|
||||
|
||||
// Static method
|
||||
bool FGPositioned::isRunwayType(FGPositioned* pos)
|
||||
{
|
||||
return (pos && pos->type() == RUNWAY);
|
||||
}
|
||||
|
||||
// Static method
|
||||
bool FGPositioned::isNavaidType(FGPositioned* pos)
|
||||
{
|
||||
if (!pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (pos->type()) {
|
||||
case NDB:
|
||||
case VOR:
|
||||
case ILS:
|
||||
case LOC:
|
||||
case GS:
|
||||
case DME:
|
||||
case TACAN:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FGPositionedRef
|
||||
FGPositioned::createUserWaypoint(const std::string& aIdent, const SGGeod& aPos)
|
||||
{
|
||||
|
|
|
@ -98,6 +98,16 @@ public:
|
|||
Type type() const
|
||||
{ return mType; }
|
||||
|
||||
// True for the following types: AIRPORT, HELIPORT, SEAPORT.
|
||||
// False for other types, as well as if pos == nullptr.
|
||||
static bool isAirportType(FGPositioned* pos);
|
||||
// True for the following type: RUNWAY.
|
||||
// False for other types, as well as if pos == nullptr.
|
||||
static bool isRunwayType(FGPositioned* pos);
|
||||
// True for the following types: NDB, VOR, ILS, LOC, GS, DME, TACAN.
|
||||
// False for other types, as well as if pos == nullptr.
|
||||
static bool isNavaidType(FGPositioned* pos);
|
||||
|
||||
const char* typeString() const
|
||||
{ return nameForType(mType); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue