mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
committed by
Mathew Sutcliffe
parent
fe1a570c39
commit
4747b3b484
59
src/blackmisc/avaircraftlist.cpp
Normal file
59
src/blackmisc/avaircraftlist.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "avaircraftlist.h"
|
||||
#include "predicates.h"
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
/*
|
||||
* Empty constructor
|
||||
*/
|
||||
CAircraftList::CAircraftList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CAircraftList::CAircraftList(const CSequence<CAircraft> &other) :
|
||||
CSequence<CAircraft>(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CAircraftList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CAircraft>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CSequence<CAircraft>>();
|
||||
qRegisterMetaType<BlackMisc::CCollection<CAircraft>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CCollection<CAircraft>>();
|
||||
qRegisterMetaType<CAircraftList>();
|
||||
qDBusRegisterMetaType<CAircraftList>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsign
|
||||
*/
|
||||
CAircraftList CAircraftList::findByCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return this->findBy(&CAircraft::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Aircrafts within range
|
||||
*/
|
||||
CAircraftList CAircraftList::findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const
|
||||
{
|
||||
return this->findBy([&](const CAircraft & aircraft)
|
||||
{
|
||||
return BlackMisc::Geo::greatCircleDistance(aircraft, coordinate) <= range;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user