From a4dcd310eb3d1a898f14c9b27001c4864134a949 Mon Sep 17 00:00:00 2001 From: jlaura <jlaura@usgs.gov> Date: Mon, 22 Apr 2019 12:57:32 -0700 Subject: [PATCH] Adds settable ellipsoid to wrapper sort of (#18) * Adds settable ellipsoid to wrapper sort of * Removes failing test that should be failing --- csmapi.i | 1 + fixture/model.cpp | 11 ++++++++++- fixture/model.h | 15 ++++++++++----- python/tests/test_model.py | 5 ++++- settableellipsoid.i | 6 ++++++ 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 settableellipsoid.i diff --git a/csmapi.i b/csmapi.i index 40812d3..7795a03 100644 --- a/csmapi.i +++ b/csmapi.i @@ -8,3 +8,4 @@ %include "geometricmodel.i" %include "rastergm.i" %include "plugin.i" +%include "settableellipsoid.i" diff --git a/fixture/model.cpp b/fixture/model.cpp index 15bc633..5de15b9 100644 --- a/fixture/model.cpp +++ b/fixture/model.cpp @@ -482,4 +482,13 @@ std::vector<double> FixtureSensorModel::getCrossCovarianceMatrix( throw csm::Error(csm::Error::UNSUPPORTED_FUNCTION, "Unsupported function", "FixtureSensorModel::getCrossCovarianceMatrix"); -} \ No newline at end of file +} + +csm::Ellipsoid FixtureSensorModel::getEllipsoid() const { + return csm::Ellipsoid(m_majorAxis, m_minorAxis); +} + +void FixtureSensorModel::setEllipsoid(const csm::Ellipsoid &ellipsoid) { + m_majorAxis = ellipsoid.getSemiMajorRadius(); + m_minorAxis = ellipsoid.getSemiMinorRadius(); +} diff --git a/fixture/model.h b/fixture/model.h index 094fe73..9c73345 100644 --- a/fixture/model.h +++ b/fixture/model.h @@ -188,16 +188,21 @@ public: virtual std::string getModelState() const; virtual void replaceModelState(const std::string& argState); + + virtual csm::Ellipsoid getEllipsoid() const; + virtual void setEllipsoid(const csm:: Ellipsoid &ellipsoid); private: // This private form of the g2i method is used to ensure thread safety. virtual csm::ImageCoord groundToImage( - const csm::EcefCoord& groundPt, - const std::vector<double> &adjustments, - double desiredPrecision = 0.001, - double* achievedPrecision = NULL, - csm::WarningList* warnings = NULL) const; + const csm::EcefCoord& groundPt, + const std::vector<double> &adjustments, + double desiredPrecision = 0.001, + double* achievedPrecision = NULL, + csm::WarningList* warnings = NULL) const; + double m_minorAxis; + double m_majorAxis; }; #endif diff --git a/python/tests/test_model.py b/python/tests/test_model.py index 6522700..2493fdb 100644 --- a/python/tests/test_model.py +++ b/python/tests/test_model.py @@ -57,4 +57,7 @@ def test_bad_ground_to_image(model): gnd_coord = csmapi.EcefCoord(-1, -1, 0) with pytest.warns(Warning) as w: img = model.groundToImage(gnd_coord, 0) - assert len(w) == 1 \ No newline at end of file + assert len(w) == 1 + +def test_ellipsoid_is_settable(model): + assert isinstance(csmapi.SettableEllipsoid.getEllipsoid(model), csmapi.Ellipsoid) diff --git a/settableellipsoid.i b/settableellipsoid.i new file mode 100644 index 0000000..6714c47 --- /dev/null +++ b/settableellipsoid.i @@ -0,0 +1,6 @@ +%module(package="csmapi") settableellipsoid +%{ + #include "SettableEllipsoid.h" +%} + +%include "SettableEllipsoid.h" -- GitLab