CWeatherGrid utility classes

Renamed Cavok to ClearWeather since CAVOK does not mean no clouds.
Find methods.

refs #612
This commit is contained in:
Roland Winklmeier
2016-03-26 21:24:49 +01:00
parent 5d93144c3c
commit a2de3a16e4
2 changed files with 30 additions and 3 deletions

View File

@@ -8,9 +8,11 @@
*/
#include "weathergrid.h"
#include "blackmisc/geo/coordinategeodetic.h"
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
namespace BlackMisc
{
@@ -20,7 +22,25 @@ namespace BlackMisc
CSequence<CGridPoint>(other)
{ }
const CWeatherGrid &CWeatherGrid::getCavokGrid()
CWeatherGrid CWeatherGrid::findWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const
{
return findBy([&](const CGridPoint & gridPoint)
{
return calculateGreatCircleDistance(gridPoint.getPosition(), coordinate) <= range;
});
}
CWeatherGrid CWeatherGrid::findClosest(int number, const ICoordinateGeodetic &coordinate) const
{
CWeatherGrid closest = partiallySorted(number, [ & ](const CGridPoint & a, const CGridPoint & b)
{
return calculateEuclideanDistanceSquared(a.getPosition(), coordinate) < calculateEuclideanDistanceSquared(b.getPosition(), coordinate);
});
closest.truncate(number);
return closest;
}
const CWeatherGrid &CWeatherGrid::getClearWeatherGrid()
{
static const CVisibilityLayer visibilityLayer(
CAltitude(0, CAltitude::MeanSeaLevel, CLengthUnit::m()),

View File

@@ -15,6 +15,7 @@
#include "gridpoint.h"
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/sequence.h"
#include "blackmisc/geo/geoobjectlist.h"
namespace BlackMisc
{
@@ -39,8 +40,14 @@ namespace BlackMisc
//! Construct from a base class object.
CWeatherGrid(const CSequence<CGridPoint> &other);
//! CAVOK grid
static const BlackMisc::Weather::CWeatherGrid &getCavokGrid();
//! \copydoc Geo::IGeoObjectList::findWithinRange
CWeatherGrid findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const BlackMisc::PhysicalQuantities::CLength &range) const;
//! \copydoc Geo::IGeoObjectList::findClosest
CWeatherGrid findClosest(int number, const BlackMisc::Geo::ICoordinateGeodetic &coordinate) const;
//! Clear weather grid
static const BlackMisc::Weather::CWeatherGrid &getClearWeatherGrid();
//! Thunderstorm grid
static const BlackMisc::Weather::CWeatherGrid &getThunderStormGrid();