Experimental sorter for airports.
Sort by size (cumulative runway length).
This commit is contained in:
parent
ef1ec369db
commit
c72ac27098
2 changed files with 48 additions and 1 deletions
|
@ -889,6 +889,46 @@ FGAirport::commStationsOfType(FGPositioned::Type aTy) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AirportWithSize
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AirportWithSize(FGPositionedRef pos) :
|
||||||
|
_pos(pos),
|
||||||
|
_sizeMetric(0)
|
||||||
|
{
|
||||||
|
assert(pos->type() == FGPositioned::AIRPORT);
|
||||||
|
FGAirport* apt = static_cast<FGAirport*>(pos.get());
|
||||||
|
BOOST_FOREACH(FGRunway* rwy, apt->getRunwaysWithoutReciprocals()) {
|
||||||
|
_sizeMetric += static_cast<int>(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<AirportWithSize> annotated;
|
||||||
|
BOOST_FOREACH(FGPositionedRef p, airportList) {
|
||||||
|
annotated.push_back(AirportWithSize(p));
|
||||||
|
}
|
||||||
|
std::sort(annotated.begin(), annotated.end());
|
||||||
|
|
||||||
|
for (unsigned int i=0; i<annotated.size(); ++i) {
|
||||||
|
airportList[i] = annotated[i].pos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get airport elevation
|
// get airport elevation
|
||||||
double fgGetAirportElev( const std::string& id )
|
double fgGetAirportElev( const std::string& id )
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,7 +251,14 @@ class FGAirport : public FGPositioned
|
||||||
* matches in a format suitable for use by a puaList.
|
* matches in a format suitable for use by a puaList.
|
||||||
*/
|
*/
|
||||||
static char** searchNamesAndIdents(const std::string& aFilter);
|
static char** searchNamesAndIdents(const std::string& aFilter);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort an FGPositionedList of airports by size (number of runways + length)
|
||||||
|
* this is meant to prioritise more important airports.
|
||||||
|
*/
|
||||||
|
static void sortBySize(FGPositionedList&);
|
||||||
|
|
||||||
flightgear::CommStationList commStationsOfType(FGPositioned::Type aTy) const;
|
flightgear::CommStationList commStationsOfType(FGPositioned::Type aTy) const;
|
||||||
|
|
||||||
flightgear::CommStationList commStations() const;
|
flightgear::CommStationList commStations() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue