Isis 3 Programmer Reference
BundleObservationVector.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "BundleObservationVector.h"
10 
11 #include <algorithm>
12 
13 #include <QDebug>
14 
15 #include "BundleObservation.h"
16 #include "IsisBundleObservation.h"
17 #include "Camera.h"
18 #include "CsmBundleObservation.h"
19 #include "IException.h"
20 
21 namespace Isis {
22 
27  }
28 
29 
42  }
43 
44 
51  clear();
52  }
53 
54 
65  if (&src != this) {
70  }
71  return *this;
72  }
73 
74 
99  QString observationNumber,
100  QString instrumentId,
101  BundleSettingsQsp bundleSettings) {
102 
103  BundleObservationQsp bundleObservation;
104  bool addToExisting = false;
105 
106  if (bundleSettings->solveObservationMode() &&
107  m_observationNumberToObservationMap.contains(observationNumber)) {
108  bundleObservation = m_observationNumberToObservationMap.value(observationNumber);
109 
110  addToExisting = true;
111  }
112 
113  if (addToExisting) {
114  // if we have already added a BundleObservation with this number, we have to add the new
115  // BundleImage to this observation
116  bundleObservation->append(bundleImage);
117 
118  bundleImage->setParentObservation(bundleObservation);
119 
120  // update observation number to observation ptr map
121  m_observationNumberToObservationMap.insertMulti(observationNumber, bundleObservation);
122 
123  // update image serial number to observation ptr map
124  m_imageSerialToObservationMap.insertMulti(bundleImage->serialNumber(), bundleObservation);
125  }
126  else {
127  // create new BundleObservation and append to this vector
128 
129  bool isIsisObservation = bundleImage->camera()->GetCameraType() != Camera::Csm;
130 
131  if (isIsisObservation) {
132  bundleObservation.reset(new IsisBundleObservation(bundleImage,
133  observationNumber,
134  instrumentId,
135  bundleSettings->bundleTargetBody()));
136  }
137  else {
138  bundleObservation.reset(new CsmBundleObservation(bundleImage,
139  observationNumber,
140  instrumentId,
141  bundleSettings->bundleTargetBody()));
142  }
143 
144  if (!bundleObservation) {
145  QString message = "Unable to allocate new BundleObservation ";
146  message += "for " + bundleImage->fileName();
147  throw IException(IException::Programmer, message, _FILEINFO_);
148  }
149 
150  // Find the bundle observation solve settings for this new observation
151  BundleObservationSolveSettings solveSettings;
152  // When there is only one bundle observation solve setting, use it for all observations
153  if ( bundleSettings->numberSolveSettings() == 1) {
154  solveSettings = bundleSettings->observationSolveSettings(0);
155  }
156  // Otherwise, we want to grab the bundle observation solve settings that is associated with
157  // the observation number for this new observation
158  else {
159  solveSettings = bundleSettings->observationSolveSettings(observationNumber);
160  }
161 
162  bundleObservation->setSolveSettings(solveSettings);
163 
164  bundleObservation->setIndex(size());
165 
166  bundleImage->setParentObservation(bundleObservation);
167 
168  append(bundleObservation);
169 
170  if (isIsisObservation) {
171  QSharedPointer<IsisBundleObservation> isisObs = qSharedPointerDynamicCast<IsisBundleObservation>(bundleObservation);
172  isisObs->initializeExteriorOrientation();
173  if (bundleSettings->solveTargetBody()) {
174  isisObs->initializeBodyRotation();
175  }
176  }
177 
178  // update observation number to observation ptr map
179  m_observationNumberToObservationMap.insertMulti(observationNumber, bundleObservation);
180 
181  // update image serial number to observation ptr map
182  m_imageSerialToObservationMap.insertMulti(bundleImage->serialNumber(), bundleObservation);
183 
184  // update instrument ID to observation ptr map
185  // separate held observations out into their own entry
186  if (bundleObservation->numberParameters() == 0) {
187  m_instIdToObservationMap.insertMulti("held", bundleObservation);
188  }
189  else {
190  m_instIdToObservationMap.insertMulti(instrumentId, bundleObservation);
191  }
192 
193  }
194  return bundleObservation;
195  }
196 
197 
205  int numParameters = 0;
206 
207  for (int i = 0; i < size(); i++) {
208  numParameters += at(i)->numberParameters();
209  }
210  return numParameters;
211  }
212 
213 
225  observationByCubeSerialNumber(QString cubeSerialNumber) {
226  BundleObservationQsp bundleObservation;
227 
228  if (m_imageSerialToObservationMap.contains(cubeSerialNumber))
229  bundleObservation = m_imageSerialToObservationMap.value(cubeSerialNumber);
230 
231  return bundleObservation;
232  }
233 
234 
239  return m_instIdToObservationMap.uniqueKeys();
240  }
241 
242 
247  observationsByInstId(QString instrumentId) const {
248  QList<BundleObservationQsp> list = m_instIdToObservationMap.values(instrumentId);
249  // multimap returns them in reverse order they were put in, so invert them to preserve order
250  std::reverse(std::begin(list), std::end(list));
251  return list;
252  }
253 }
Isis::BundleObservationVector::numberParameters
int numberParameters()
Returns the sum of the position parameters and pointing parameters for the contained BundleObservatio...
Definition: BundleObservationVector.cpp:204
Isis::BundleObservationVector::instrumentIds
QList< QString > instrumentIds() const
Get a list of all instrument IDs that there are observations for.
Definition: BundleObservationVector.cpp:238
QList< QString >
Isis::BundleObservationVector::m_imageSerialToObservationMap
QMap< QString, BundleObservationQsp > m_imageSerialToObservationMap
Map between image serial number and pointer to observation.
Definition: BundleObservationVector.h:79
Isis::BundleObservationVector::~BundleObservationVector
~BundleObservationVector()
Destructor.
Definition: BundleObservationVector.cpp:50
Isis::BundleObservationVector::addNew
BundleObservationQsp addNew(BundleImageQsp image, QString observationNumber, QString instrumentId, BundleSettingsQsp bundleSettings)
Adds a new BundleObservation to this vector or fetches an existing BundleObservation if this vector a...
Definition: BundleObservationVector.cpp:98
Isis::BundleObservationVector::operator=
BundleObservationVector & operator=(const BundleObservationVector &src)
Assignment operator.
Definition: BundleObservationVector.cpp:64
QSharedPointer
Definition: JigsawWorkOrder.h:28
Isis::CsmBundleObservation
Class for observations that use CSM camera models in bundle adjustment.
Definition: CsmBundleObservation.h:28
Isis::BundleObservationVector::observationsByInstId
QList< BundleObservationQsp > observationsByInstId(QString instrumentId) const
Get all of the observations with a specific instrument ID.
Definition: BundleObservationVector.cpp:247
Isis::BundleObservationVector::observationByCubeSerialNumber
BundleObservationQsp observationByCubeSerialNumber(QString cubeSerialNumber)
Accesses a BundleObservation associated with the passed serial number.
Definition: BundleObservationVector.cpp:225
Isis::BundleObservationVector::m_observationNumberToObservationMap
QMap< QString, BundleObservationQsp > m_observationNumberToObservationMap
Map between observation number and pointer to observation.
Definition: BundleObservationVector.h:77
Isis::BundleObservationVector::m_instIdToObservationMap
QMultiMap< QString, BundleObservationQsp > m_instIdToObservationMap
Map between instrument ID and pointer to observation.
Definition: BundleObservationVector.h:81
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Camera::Csm
@ Csm
Community Sensor Model Camera.
Definition: Camera.h:364
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::BundleObservationVector::BundleObservationVector
BundleObservationVector()
Constructs an empty BundleObservationVector.
Definition: BundleObservationVector.cpp:26
Isis::IsisBundleObservation
Class for observations that use ISIS camera models in bundle adjustment.
Definition: IsisBundleObservation.h:34
Isis::BundleObservationSolveSettings
This class is used to modify and manage solve settings for 1 to many BundleObservations.
Definition: BundleObservationSolveSettings.h:82
QVector
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:18
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::BundleObservationVector
This class is a container class for BundleObservations.
Definition: BundleObservationVector.h:55