From e7f2d639c176e33f56530dbd2419a0c51401c045 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 26 Jan 2018 22:23:00 +0100 Subject: [PATCH] Ref T231, arbitrary radius for elevation plane --- src/blackmisc/geo/elevationplane.cpp | 12 +++++++++++- src/blackmisc/geo/elevationplane.h | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/blackmisc/geo/elevationplane.cpp b/src/blackmisc/geo/elevationplane.cpp index a2e438906..8ece8c3ca 100644 --- a/src/blackmisc/geo/elevationplane.cpp +++ b/src/blackmisc/geo/elevationplane.cpp @@ -34,7 +34,7 @@ namespace BlackMisc bool CElevationPlane::isNull() const { - return m_radius.isNull(); + return m_radius.isNull() || CCoordinateGeodetic::isNull(); } bool CElevationPlane::isWithinRange(const ICoordinateGeodetic &coordinate) const @@ -46,6 +46,16 @@ namespace BlackMisc return inRange; } + bool CElevationPlane::isWithinRange(const ICoordinateGeodetic &coordinate, const CLength &radius) const + { + if (coordinate.isNull()) { return false; } + if (radius.isNull()) { return false; } + if (isNull()) { return false; } + const CLength d = this->calculateGreatCircleDistance(coordinate); + const bool inRange = (radius >= d); + return inRange; + } + void CElevationPlane::setSinglePointRadius() { m_radius = singlePointRadius(); diff --git a/src/blackmisc/geo/elevationplane.h b/src/blackmisc/geo/elevationplane.h index ab164e933..2b6a95f33 100644 --- a/src/blackmisc/geo/elevationplane.h +++ b/src/blackmisc/geo/elevationplane.h @@ -48,12 +48,16 @@ namespace BlackMisc //! Altitude (synonym for geodetic height) const Aviation::CAltitude &getAltitude() const { return this->geodeticHeight(); } - //! Existing value - bool isNull() const; + //! Existing value? + virtual bool isNull() const override; //! Check if elevation is within radius and can be used + //! \remark checks against the set radius bool isWithinRange(const ICoordinateGeodetic &coordinate) const; + //! Check if elevation is within radius and can be used + bool isWithinRange(const ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &radius) const; + //! Treat as single point as obtained from simulator void setSinglePointRadius();