From 92d4294972f4f134167126dcfd4fbc155df47c99 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 25 Jan 2018 05:23:34 +0100 Subject: [PATCH] Ref T236, isNull default implementation of ICoordinateGeodetic Also interface can be checked agains null --- src/blackmisc/geo/coordinategeodetic.h | 6 +++++- src/blackmisc/geo/elevationplane.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/blackmisc/geo/coordinategeodetic.h b/src/blackmisc/geo/coordinategeodetic.h index e73e17215..4ad562946 100644 --- a/src/blackmisc/geo/coordinategeodetic.h +++ b/src/blackmisc/geo/coordinategeodetic.h @@ -95,6 +95,10 @@ namespace BlackMisc //! Geodetic height null? bool isGeodeticHeightNull() const { return this->geodeticHeight().isNull(); } + //! Is null, means vector x, y, z == 0 + //! \remark this is a default implementation, concrete implementations of ICoordinateGeodetic might override it + virtual bool isNull() const { return this->normalVector().isNull(); } + //! Great circle distance PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const; @@ -256,7 +260,7 @@ namespace BlackMisc void setNull() { this->setNormalVector(0, 0, 0); } //! Is null? - bool isNull() const { return m_x == 0 && m_y == 0 && m_z == 0; } + virtual bool isNull() const override { return m_x == 0 && m_y == 0 && m_z == 0; } //! Coordinate by WGS84 position data static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const Aviation::CAltitude &geodeticHeight = {}); diff --git a/src/blackmisc/geo/elevationplane.cpp b/src/blackmisc/geo/elevationplane.cpp index 8903a58ab..a2e438906 100644 --- a/src/blackmisc/geo/elevationplane.cpp +++ b/src/blackmisc/geo/elevationplane.cpp @@ -24,8 +24,7 @@ namespace BlackMisc return s.arg(this->latitude().valueRoundedWithUnit(6, i18n), this->longitude().valueRoundedWithUnit(6, i18n), this->geodeticHeight().valueRoundedWithUnit(6, i18n), - m_radius.valueRoundedWithUnit(2, i18n) - ); + m_radius.valueRoundedWithUnit(2, i18n)); } const CAltitude &CElevationPlane::getAltitudeIfWithinRadius(const ICoordinateGeodetic &coordinate) const @@ -40,6 +39,7 @@ namespace BlackMisc bool CElevationPlane::isWithinRange(const ICoordinateGeodetic &coordinate) const { + if (coordinate.isNull()) { return false; } if (isNull()) { return false; } const CLength d = this->calculateGreatCircleDistance(coordinate); const bool inRange = (m_radius >= d);