mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T778, utility functions geo objects
This commit is contained in:
committed by
Mat Sutcliffe
parent
2ace391325
commit
3ff8694718
@@ -52,6 +52,15 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
CONTAINER IGeoObjectList<OBJ, CONTAINER>::findOutsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const
|
||||
{
|
||||
return this->container().findBy([&](const OBJ & geoObj)
|
||||
{
|
||||
return calculateGreatCircleDistance(geoObj, coordinate) > range;
|
||||
});
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
OBJ IGeoObjectList<OBJ, CONTAINER>::findFirstWithinRangeOrDefault(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
||||
{
|
||||
@@ -147,6 +156,16 @@ namespace BlackMisc
|
||||
return max;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
int IGeoObjectList<OBJ, CONTAINER>::removeInsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range)
|
||||
{
|
||||
const int size = this->container().size();
|
||||
const CONTAINER copy = this->container().findOutsideRange(coordinate, range);
|
||||
const int d = size - copy.size();
|
||||
if (d > 0) { *this = copy; }
|
||||
return d;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
int IGeoObjectList<OBJ, CONTAINER>::removeOutsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,11 @@ namespace BlackMisc
|
||||
//! \param range within range of other position
|
||||
CONTAINER findWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
//! Find 0..n objects outside range of given coordinate
|
||||
//! \param coordinate other position
|
||||
//! \param range outside range of other position
|
||||
CONTAINER findOutsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
//! Find first in range
|
||||
OBJ findFirstWithinRangeOrDefault(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
|
||||
|
||||
@@ -86,6 +91,9 @@ namespace BlackMisc
|
||||
//! Find min/max/average height
|
||||
Aviation::CAltitude findMaxHeight() const;
|
||||
|
||||
//! Remove inside range
|
||||
int removeInsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range);
|
||||
|
||||
//! Remove outside range
|
||||
int removeOutsideRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user