diff --git a/src/Airports/airport.cxx b/src/Airports/airport.cxx index 6d463fd54..42d76f5ba 100644 --- a/src/Airports/airport.cxx +++ b/src/Airports/airport.cxx @@ -889,6 +889,46 @@ FGAirport::commStationsOfType(FGPositioned::Type aTy) const return result; } +class AirportWithSize +{ +public: + AirportWithSize(FGPositionedRef pos) : + _pos(pos), + _sizeMetric(0) + { + assert(pos->type() == FGPositioned::AIRPORT); + FGAirport* apt = static_cast(pos.get()); + BOOST_FOREACH(FGRunway* rwy, apt->getRunwaysWithoutReciprocals()) { + _sizeMetric += static_cast(rwy->lengthFt()); + } + } + + bool operator<(const AirportWithSize& other) const + { + return _sizeMetric < other._sizeMetric; + } + + FGPositionedRef pos() const + { return _pos; } +private: + FGPositionedRef _pos; + unsigned int _sizeMetric; + +}; + +void FGAirport::sortBySize(FGPositionedList& airportList) +{ + std::vector annotated; + BOOST_FOREACH(FGPositionedRef p, airportList) { + annotated.push_back(AirportWithSize(p)); + } + std::sort(annotated.begin(), annotated.end()); + + for (unsigned int i=0; i