diff --git a/isis/src/control/objs/BundleAdjust/BundleAdjust.cpp b/isis/src/control/objs/BundleAdjust/BundleAdjust.cpp index 38e907e417..ec98a4df63 100644 --- a/isis/src/control/objs/BundleAdjust/BundleAdjust.cpp +++ b/isis/src/control/objs/BundleAdjust/BundleAdjust.cpp @@ -436,16 +436,6 @@ namespace Isis { } } - // initialize exterior orientation (spice) for all BundleImages in all BundleObservations - // - // TODO!!! - should these initializations just be done when we add the new observation above? - m_bundleObservations.initializeExteriorOrientation(); - - // TODO - if (m_bundleSettings->solveTargetBody()) { - m_bundleObservations.initializeBodyRotation(); - } - // set up vector of BundleControlPoints int numControlPoints = m_controlNet->GetNumPoints(); for (int i = 0; i < numControlPoints; i++) { diff --git a/isis/src/control/objs/BundleUtilities/AbstractBundleObservation.h b/isis/src/control/objs/BundleUtilities/AbstractBundleObservation.h index a07839c0e5..00d1832673 100644 --- a/isis/src/control/objs/BundleUtilities/AbstractBundleObservation.h +++ b/isis/src/control/objs/BundleUtilities/AbstractBundleObservation.h @@ -45,8 +45,10 @@ namespace Isis { virtual AbstractBundleObservation &operator=(const AbstractBundleObservation &src); // copy method - // not implementedn in BundleObservation either??? -// virtual void copy(const AbstractBundleObservation &src); + + void copy(const AbstractBundleObservation &src); + + virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings) = 0; virtual void append(const BundleImageQsp &value); @@ -93,7 +95,7 @@ namespace Isis { QMap m_cubeSerialNumberToBundleImageMap; QStringList m_serialNumbers; //!< List of all cube serial numbers in observation. QStringList m_imageNames; //!< List of all cube names. - QString m_instrumentId; //!< Spacecraft instrument id. + QString m_instrumentId; //!< Spacecraft instrument id. // TODO??? change these to LinearAlgebra vectors... LinearAlgebra::Vector m_weights; //!< Parameter weights. diff --git a/isis/src/control/objs/BundleUtilities/BundleObservation.h b/isis/src/control/objs/BundleUtilities/BundleObservation.h index 162a216179..0982d6a2cf 100644 --- a/isis/src/control/objs/BundleUtilities/BundleObservation.h +++ b/isis/src/control/objs/BundleUtilities/BundleObservation.h @@ -107,7 +107,7 @@ namespace Isis { // copy method void copy(const BundleObservation &src); - bool setSolveSettings(BundleObservationSolveSettings solveSettings); + virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings); int numberPositionParameters(); int numberPointingParameters(); diff --git a/isis/src/control/objs/BundleUtilities/BundleObservationVector.cpp b/isis/src/control/objs/BundleUtilities/BundleObservationVector.cpp index 7e3762d241..64616a207e 100644 --- a/isis/src/control/objs/BundleUtilities/BundleObservationVector.cpp +++ b/isis/src/control/objs/BundleUtilities/BundleObservationVector.cpp @@ -14,6 +14,8 @@ find files of those names at the top level of this repository. **/ #include "AbstractBundleObservation.h" #include "BundleObservation.h" +#include "Camera.h" +#include "CsmBundleObservation.h" #include "IException.h" namespace Isis { @@ -101,7 +103,6 @@ namespace Isis { AbstractBundleObservationQsp bundleObservation; bool addToExisting = false; - // TODO it looks like this can just become 1 if statement if (bundleSettings->solveObservationMode() && m_observationNumberToObservationMap.contains(observationNumber)) { bundleObservation = m_observationNumberToObservationMap.value(observationNumber); @@ -117,20 +118,37 @@ namespace Isis { bundleImage->setParentObservation(bundleObservation); // updateo observation number to observation ptr map - m_observationNumberToObservationMap.insertMulti(observationNumber,bundleObservation); + m_observationNumberToObservationMap.insertMulti(observationNumber, bundleObservation); // update image serial number to observation ptr map m_imageSerialToObservationMap.insertMulti(bundleImage->serialNumber(), bundleObservation); } else { // create new BundleObservation and append to this vector - BundleObservation *isisObservation = new BundleObservation(bundleImage, - observationNumber, - instrumentId, - bundleSettings->bundleTargetBody()); + bool isIsisObservation = true; + + // This NULL check is needed solely for the unit test + if (bundleImage->camera() != NULL) { + isIsisObservation = bundleImage->camera()->GetCameraType() != Camera::Csm; + } + + AbstractBundleObservation *observation = NULL; + + if (isIsisObservation) { + observation = new BundleObservation(bundleImage, + observationNumber, + instrumentId, + bundleSettings->bundleTargetBody()); + } + else { + observation = new CsmBundleObservation(bundleImage, + observationNumber, + instrumentId, + bundleSettings->bundleTargetBody()); + } - if (!isisObservation) { + if (!observation) { QString message = "Unable to allocate new BundleObservation "; message += "for " + bundleImage->fileName(); throw IException(IException::Programmer, message, _FILEINFO_); @@ -148,9 +166,8 @@ namespace Isis { solveSettings = bundleSettings->observationSolveSettings(observationNumber); } - isisObservation->setSolveSettings(solveSettings); - - bundleObservation.reset(isisObservation); + observation->setSolveSettings(solveSettings); + bundleObservation.reset(observation); bundleObservation->setIndex(size()); @@ -158,6 +175,17 @@ namespace Isis { append(bundleObservation); + if (isIsisObservation) { + QSharedPointer isisObs = qSharedPointerDynamicCast(bundleObservation); + // This check is needed for the current unit test + if (bundleImage->camera() != NULL) { + isisObs->initializeExteriorOrientation(); + if (bundleSettings->solveTargetBody()) { + isisObs->initializeBodyRotation(); + } + } + } + // update observation number to observation ptr map m_observationNumberToObservationMap.insertMulti(observationNumber, bundleObservation); @@ -233,41 +261,4 @@ namespace Isis { std::reverse(std::begin(list), std::end(list)); return list; } - - - /** - * Initializes the exterior orientations for the contained ISIS - * BundleObservations. - * - * @return @b bool Returns true upon successful initialization - */ - bool BundleObservationVector::initializeExteriorOrientation() { - // get isis observations - // get csm observations - int nObservations = size(); - // just do it for ISIS observations - for (int i = 0; i < nObservations; i++) { - // TODO: how to only do this if ISIS observations - QSharedPointer observation = qSharedPointerDynamicCast( at(i) ); - observation->initializeExteriorOrientation(); - } - return true; - } - - - /** - * Initializes the body rotations for the contained BundleObservations. - * - * @return @b bool Returns true upon successful initialization - */ - bool BundleObservationVector::initializeBodyRotation() { - int nObservations = size(); - //TODO: just do it for ISIS observations - for (int i = 0; i < nObservations; i++) { - QSharedPointer observation = qSharedPointerDynamicCast( at(i) ); - observation->initializeBodyRotation(); - } - - return true; - } } diff --git a/isis/src/control/objs/BundleUtilities/BundleObservationVector.h b/isis/src/control/objs/BundleUtilities/BundleObservationVector.h index 3f05fabfa4..17ccd2aa38 100644 --- a/isis/src/control/objs/BundleUtilities/BundleObservationVector.h +++ b/isis/src/control/objs/BundleUtilities/BundleObservationVector.h @@ -19,6 +19,7 @@ find files of those names at the top level of this repository. **/ #include "BundleImage.h" #include "AbstractBundleObservation.h" #include "BundleObservation.h" +#include "CsmBundleObservation.h" #include "BundleSettings.h" namespace Isis { @@ -71,14 +72,6 @@ namespace Isis { QList instrumentIds() const; QList observationsByInstId(QString instrumentId) const; - bool initializeExteriorOrientation(); - bool initializeBodyRotation(); - - // To add: - // getCsmObservations() - // getIsisObservations() - // addNewIsis()? - private: //! Map between observation number and pointer to observation. QMap m_observationNumberToObservationMap; diff --git a/isis/src/control/objs/BundleUtilities/BundleUtilities.truth b/isis/src/control/objs/BundleUtilities/BundleUtilities.truth index c3a3f516af..9b209b74ac 100644 --- a/isis/src/control/objs/BundleUtilities/BundleUtilities.truth +++ b/isis/src/control/objs/BundleUtilities/BundleUtilities.truth @@ -538,7 +538,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Testing BundleObservationVector... number of parameters: "0" -init exterior orientiation successful? "Yes" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/isis/src/control/objs/BundleUtilities/unitTest.cpp b/isis/src/control/objs/BundleUtilities/unitTest.cpp index 8827c269c1..e750be21b6 100755 --- a/isis/src/control/objs/BundleUtilities/unitTest.cpp +++ b/isis/src/control/objs/BundleUtilities/unitTest.cpp @@ -626,7 +626,7 @@ int main(int argc, char *argv[]) { qDebug() << obs1b.formatBundleOutputString(true); #endif // Following segfaults (see #4157) - qDebug() << "init exterior orientiation successful? " << toString(bov.initializeExteriorOrientation()); +// qDebug() << "init exterior orientiation successful? " << toString(bov.initializeExteriorOrientation()); qDebug() << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; qDebug() << ""; qDebug() << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; diff --git a/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.cpp b/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.cpp index 6d184be1bb..42df7931c5 100644 --- a/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.cpp +++ b/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.cpp @@ -97,8 +97,9 @@ namespace Isis { * * @return @b bool Returns true if settings were successfully set */ - bool CsmBundleObservation::setSolveSettings(BundleObservationSolveSettingsQsp solveSettings) { - m_solveSettings = solveSettings; + bool CsmBundleObservation::setSolveSettings(BundleObservationSolveSettings solveSettings) { + m_solveSettings = BundleObservationSolveSettingsQsp( + new BundleObservationSolveSettings(solveSettings)); CSMCamera *csmCamera = dynamic_cast(front()->camera()); @@ -107,14 +108,14 @@ namespace Isis { m_corrections.clear(); m_adjustedSigmas.clear(); - if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::Set) { - m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterSet()); + if (m_solveSettings->csmSolveOption() == BundleObservationSolveSettings::Set) { + m_paramIndices = csmCamera->getParameterIndices(m_solveSettings->csmParameterSet()); } - else if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::Type) { - m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterType()); + else if (m_solveSettings->csmSolveOption() == BundleObservationSolveSettings::Type) { + m_paramIndices = csmCamera->getParameterIndices(m_solveSettings->csmParameterType()); } - else if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::List) { - m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterList()); + else if (m_solveSettings->csmSolveOption() == BundleObservationSolveSettings::List) { + m_paramIndices = csmCamera->getParameterIndices(m_solveSettings->csmParameterList()); } else { return false; @@ -696,19 +697,19 @@ QString CsmBundleObservation::formatBundleOutputString(bool errorPropagation, bo /** - * Calculates the sensor partials with respect to the solve - * parameters and populates the coeffImage matrix. - * - * @param coeffImage A matrix that will be populated with the + * Calculates the sensor partials with respect to the solve + * parameters and populates the coeffImage matrix. + * + * @param coeffImage A matrix that will be populated with the * sensor partials with respect to the solve * parameters. - * @param measure The measure that the partials are being + * @param measure The measure that the partials are being * computed for. - * - * @return bool + * + * @return bool */ bool CsmBundleObservation::computeImagePartials(LinearAlgebra::Matrix &coeffImage, BundleMeasure &measure) { - coeffImage.clear(); + coeffImage.clear(); CSMCamera *csmCamera = dynamic_cast(measure.camera()); SurfacePoint groundPoint = measure.parentControlPoint()->adjustedSurfacePoint(); @@ -743,8 +744,8 @@ QString CsmBundleObservation::formatBundleOutputString(bool errorPropagation, bo CSMCamera *measureCamera = dynamic_cast(measure.camera()); - // do ground partials - vector groundPartials = measureCamera->GroundPartials(); + // do ground partials + vector groundPartials = measureCamera->GroundPartials(); // groundPartials is: // line WRT x @@ -805,15 +806,15 @@ QString CsmBundleObservation::formatBundleOutputString(bool errorPropagation, bo /** - * Returns the observed value in (sample, line) coordinates. - * This requires no modification for Csm. - * - * @param measure measure The measure that the partials are + * Returns the observed value in (sample, line) coordinates. + * This requires no modification for Csm. + * + * @param measure measure The measure that the partials are * being computed for. - * @param deltaVal The difference between the measured and + * @param deltaVal The difference between the measured and * calculate sample, line coordinates - * - * @return double The The difference between the measured and + * + * @return double The The difference between the measured and * calculated (line, sample) coordinate */ double CsmBundleObservation::computeObservationValue(BundleMeasure &measure, double deltaVal) { diff --git a/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.h b/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.h index 4167f9aefb..ababb553e8 100644 --- a/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.h +++ b/isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.h @@ -53,7 +53,7 @@ namespace Isis { // copy method void copy(const CsmBundleObservation &src); - bool setSolveSettings(BundleObservationSolveSettingsQsp solveSettings); + virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings); int numberParameters(); diff --git a/isis/tests/CsmBundleObservationTests.cpp b/isis/tests/CsmBundleObservationTests.cpp index f85451ad87..0561eef0fb 100644 --- a/isis/tests/CsmBundleObservationTests.cpp +++ b/isis/tests/CsmBundleObservationTests.cpp @@ -57,9 +57,9 @@ TEST_F(CSMCameraFixture, CsmBundleOutputString) { QString sn = SerialNumber::Compose(*testCube); BundleImageQsp bi = BundleImageQsp(new BundleImage(testCam, sn, testCube->fileName())); - BundleObservationSolveSettingsQsp bundleSolSetting(new BundleObservationSolveSettings()); + BundleObservationSolveSettings bundleSolSetting; - bundleSolSetting->setCSMSolveSet(csm::param::ADJUSTABLE); + bundleSolSetting.setCSMSolveSet(csm::param::ADJUSTABLE); CsmBundleObservation observation(bi, "ObservationNumber", @@ -116,9 +116,9 @@ TEST_F(CSMCameraFixture, CsmBundleOutputCSVString) { QString sn = SerialNumber::Compose(*testCube); BundleImageQsp bi = BundleImageQsp(new BundleImage(testCam, sn, testCube->fileName())); - BundleObservationSolveSettingsQsp bundleSolSetting(new BundleObservationSolveSettings()); + BundleObservationSolveSettings bundleSolSetting; - bundleSolSetting->setCSMSolveSet(csm::param::ADJUSTABLE); + bundleSolSetting.setCSMSolveSet(csm::param::ADJUSTABLE); CsmBundleObservation observation(bi, "ObservationNumber", @@ -163,7 +163,7 @@ TEST_F(CSMCameraFixture, CsmBundleSetSolveSettings) { QString sn = SerialNumber::Compose(*testCube); BundleImageQsp bi = BundleImageQsp(new BundleImage(testCam, sn, testCube->fileName())); - BundleObservationSolveSettingsQsp bundleSolSetting(new BundleObservationSolveSettings()); + BundleObservationSolveSettings bundleSolSetting; CsmBundleObservation observation(bi, "ObservationNumber", @@ -172,7 +172,7 @@ TEST_F(CSMCameraFixture, CsmBundleSetSolveSettings) { QStringList paramList; - bundleSolSetting->setCSMSolveSet(csm::param::ADJUSTABLE); + bundleSolSetting.setCSMSolveSet(csm::param::ADJUSTABLE); ASSERT_TRUE(observation.setSolveSettings(bundleSolSetting)); ASSERT_EQ(observation.numberParameters(), 2); @@ -181,7 +181,7 @@ TEST_F(CSMCameraFixture, CsmBundleSetSolveSettings) { EXPECT_EQ(paramList[0].toStdString(), "Parameter 1"); EXPECT_EQ(paramList[1].toStdString(), "Parameter 3"); - bundleSolSetting->setCSMSolveType(csm::param::FIXED); + bundleSolSetting.setCSMSolveType(csm::param::FIXED); ASSERT_TRUE(observation.setSolveSettings(bundleSolSetting)); ASSERT_EQ(observation.numberParameters(), 1); @@ -192,7 +192,7 @@ TEST_F(CSMCameraFixture, CsmBundleSetSolveSettings) { paramList.clear(); paramList.push_back("Parameter 2"); paramList.push_back("Parameter 3"); - bundleSolSetting->setCSMSolveParameterList(paramList); + bundleSolSetting.setCSMSolveParameterList(paramList); ASSERT_TRUE(observation.setSolveSettings(bundleSolSetting)); ASSERT_EQ(observation.numberParameters(), 2); @@ -239,7 +239,7 @@ TEST_F(CSMCameraFixture, CsmBundleApplyParameterCorrections) { QString sn = SerialNumber::Compose(*testCube); BundleImageQsp bi = BundleImageQsp(new BundleImage(testCam, sn, testCube->fileName())); - BundleObservationSolveSettingsQsp bundleSolSetting(new BundleObservationSolveSettings()); + BundleObservationSolveSettings bundleSolSetting; CsmBundleObservation observation(bi, "ObservationNumber", @@ -248,7 +248,7 @@ TEST_F(CSMCameraFixture, CsmBundleApplyParameterCorrections) { QStringList paramList; - bundleSolSetting->setCSMSolveSet(csm::param::ADJUSTABLE); + bundleSolSetting.setCSMSolveSet(csm::param::ADJUSTABLE); ASSERT_TRUE(observation.setSolveSettings(bundleSolSetting));