Ref T261, improved "finding" for elevation, "findFirst" for small radius

This commit is contained in:
Klaus Basan
2018-04-28 19:04:06 +02:00
committed by Roland Winklmeier
parent ae8d9abf0d
commit ad10470eb1
3 changed files with 18 additions and 2 deletions

View File

@@ -53,6 +53,15 @@ namespace BlackMisc
}); });
} }
template<class OBJ, class CONTAINER>
OBJ IGeoObjectList<OBJ, CONTAINER>::findFirstWithinRangeOrDefault(const ICoordinateGeodetic &coordinate, const CLength &range) const
{
return this->container().findFirstByOrDefault([&](const OBJ & geoObj)
{
return calculateGreatCircleDistance(geoObj, coordinate) <= range;
});
}
template<class OBJ, class CONTAINER> template<class OBJ, class CONTAINER>
CONTAINER IGeoObjectList<OBJ, CONTAINER>::findWithGeodeticMSLHeight() const CONTAINER IGeoObjectList<OBJ, CONTAINER>::findWithGeodeticMSLHeight() const
{ {

View File

@@ -63,6 +63,9 @@ namespace BlackMisc
//! \param range within range of other position //! \param range within range of other position
CONTAINER findWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const; CONTAINER findWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
//! Find first in range
OBJ findFirstWithinRangeOrDefault(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const;
//! Elements with geodetic height (only MSL) //! Elements with geodetic height (only MSL)
CONTAINER findWithGeodeticMSLHeight() const; CONTAINER findWithGeodeticMSLHeight() const;

View File

@@ -91,9 +91,13 @@ namespace BlackMisc
return delta; return delta;
} }
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const CLength &range) const
{ {
const CCoordinateGeodetic coordinate = this->getElevationCoordinates().findClosestWithinRange(reference, minRange(range)); // for single point we use a slightly optimized version
const bool singlePoint = (range <= CElevationPlane::singlePointRadius());
const CCoordinateGeodetic coordinate = singlePoint ?
this->getElevationCoordinates().findFirstWithinRangeOrDefault(reference, CElevationPlane::singlePointRadius()) :
this->getElevationCoordinates().findClosestWithinRange(reference, range);
const bool found = !coordinate.isNull(); const bool found = !coordinate.isNull();
{ {
QWriteLocker l{&m_lockElvCoordinates }; QWriteLocker l{&m_lockElvCoordinates };