diff --git a/src/blackmisc/geo/coordinategeodetic.cpp b/src/blackmisc/geo/coordinategeodetic.cpp index b7389b62e..aa39009b1 100644 --- a/src/blackmisc/geo/coordinategeodetic.cpp +++ b/src/blackmisc/geo/coordinategeodetic.cpp @@ -180,6 +180,11 @@ namespace BlackMisc } } + CCoordinateGeodetic::CCoordinateGeodetic(const std::array &normalVector) + { + this->setNormalVector(normalVector); + } + CCoordinateGeodetic::CCoordinateGeodetic(const CLatitude &latitude, const CLongitude &longitude, const CAltitude &geodeticHeight) : m_x(latitude.cos() * longitude.cos()), m_y(latitude.cos() * longitude.sin()), @@ -194,11 +199,10 @@ namespace BlackMisc CCoordinateGeodetic({ latitudeDegrees, PhysicalQuantities::CAngleUnit::deg() }, { longitudeDegrees, PhysicalQuantities::CAngleUnit::deg() }, { heightFeet, PhysicalQuantities::CLengthUnit::ft() }) {} CCoordinateGeodetic::CCoordinateGeodetic(const ICoordinateGeodetic &coordinate) : - m_x(coordinate.normalVectorDouble()[0]), - m_y(coordinate.normalVectorDouble()[1]), - m_z(coordinate.normalVectorDouble()[2]), m_geodeticHeight(coordinate.geodeticHeight()) - { } + { + this->setNormalVector(coordinate.normalVectorDouble()); + } CLatitude CCoordinateGeodetic::latitude() const { @@ -248,6 +252,14 @@ namespace BlackMisc this->setGeodeticHeight(CAltitude::null()); } + void CCoordinateGeodetic::setNormalVector(const std::array &normalVector) + { + Q_ASSERT_X(normalVector.size() == 3, Q_FUNC_INFO, "Wrong vector size"); + m_x = normalVector[0]; + m_y = normalVector[1]; + m_z = normalVector[2]; + } + CCoordinateGeodetic &CCoordinateGeodetic::switchUnit(const CLengthUnit &unit) { m_geodeticHeight.switchUnit(unit); diff --git a/src/blackmisc/geo/coordinategeodetic.h b/src/blackmisc/geo/coordinategeodetic.h index 11a097ae2..0cf09fd99 100644 --- a/src/blackmisc/geo/coordinategeodetic.h +++ b/src/blackmisc/geo/coordinategeodetic.h @@ -205,6 +205,9 @@ namespace BlackMisc //! Constructor by normal vector CCoordinateGeodetic(const QVector3D &normal) : m_x(normal.x()), m_y(normal.y()), m_z(normal.z()) {} + //! Constructor by normal vector + CCoordinateGeodetic(const std::array &normalVector); + //! Constructor by values CCoordinateGeodetic(const CLatitude &latitude, const CLongitude &longitude, const Aviation::CAltitude &geodeticHeight); @@ -262,6 +265,9 @@ namespace BlackMisc //! Set normal vector void setNormalVector(double x, double y, double z) { m_x = x; m_y = y; m_z = z; } + //! Set normal vector + void setNormalVector(const std::array &normalVector); + //! Set to null void setNull() {