return result;
}
+bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
+{
+ unsigned int numRunways(mRunways.size());
+ for (unsigned int r=0; r<numRunways; ++r) {
+ FGRunway* rwy = mRunways[r];
+ if (rwy->isReciprocal()) {
+ continue; // we only care about lengths, so don't do work twice
+ }
+
+ int surface = rwy->surface();
+ if ((surface != 1) && (surface != 2)) {
+ continue; // no hard surface
+ }
+
+ if (rwy->lengthFt() >= aLengthFt) {
+ return true; // we're done!
+ }
+ } // of runways iteration
+
+ return false;
+}
+
unsigned int FGAirport::numTaxiways() const
{
return mTaxiways.size();
return findBestRunwayForHeading(hdg);
}
+FGAirport* FGAirport::findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter)
+{
+ AirportFilter aptFilter;
+ if (filter == NULL) {
+ filter = &aptFilter;
+ }
+
+ FGPositionedRef r = FGPositioned::findClosest(aPos, aCuttofNm, filter);
+ if (!r) {
+ return NULL;
+ }
+
+ return static_cast<FGAirport*>(r.ptr());
+}
+
+FGAirport::HardSurfaceFilter::HardSurfaceFilter(double minLengthFt) :
+ mMinLengthFt(minLengthFt)
+{
+}
+
+bool FGAirport::HardSurfaceFilter::pass(FGPositioned* aPos) const
+{
+ if (aPos->type() != AIRPORT) {
+ return false; // exclude seaports and heliports as well, we need a runways
+ }
+
+ return static_cast<FGAirport*>(aPos)->hasHardRunwayOfLengthFt(mMinLengthFt);
+}
+
/******************************************************************************
* FGAirportList
*****************************************************************************/
FGRunway* getRunwayByIdent(const std::string& aIdent) const;
FGRunway* findBestRunwayForHeading(double aHeading) const;
+ /**
+ * Useful predicate for FMS/GPS/NAV displays and similar - check if this
+ * aiport has a hard-surfaced runway of at least the specified length.
+ * For the moment, hard means asphalt or concrete, not gravel or a
+ * lake bed.
+ */
+ bool hasHardRunwayOfLengthFt(double aLengthFt) const;
+
unsigned int numTaxiways() const;
FGRunway* getTaxiwayByIndex(unsigned int aIndex) const;
void addRunway(FGRunway* aRunway);
+
+ class AirportFilter : public Filter
+ {
+ public:
+ virtual bool pass(FGPositioned* aPos) const {
+ Type ty(aPos->type());
+ return (ty >= AIRPORT) && (ty <= SEAPORT);
+ }
+ };
+
+ class HardSurfaceFilter : public Filter
+ {
+ public:
+ HardSurfaceFilter(double minLengthFt);
+
+ virtual bool pass(FGPositioned* aPos) const;
+ private:
+ double mMinLengthFt;
+ };
+
+ /**
+ * Syntactic wrapper around FGPositioned::findClosest - find the closest
+ * match for filter, and return it cast to FGAirport. The default filter
+ * passes all airports, including seaports and heliports.
+ */
+ static FGAirport* findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter = NULL);
private:
typedef std::vector<FGRunwayPtr>::const_iterator Runway_iterator;
/**