Isis 3 Programmer Reference
BundleObservationVector.cpp
1
6
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
21namespace Isis {
22
28
29
43
44
53
54
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 bool isIsisObservation = bundleImage->camera()->GetCameraType() != Camera::Csm;
114
115 if (addToExisting) {
116 // if we have already added a BundleObservation with this number, we have to add the new
117 // BundleImage to this observation
118 bundleObservation->append(bundleImage);
119
120 bundleImage->setParentObservation(bundleObservation);
121
122 // update observation number to observation ptr map
123 m_observationNumberToObservationMap.insert(observationNumber, bundleObservation);
124
125 // update image serial number to observation ptr map
126 m_imageSerialToObservationMap.insert(bundleImage->serialNumber(), bundleObservation);
127 }
128 else {
129 // create new BundleObservation and append to this vector
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 bundleImage->setParentObservation(bundleObservation);
151
152 // Find the bundle observation solve settings for this new observation
153 BundleObservationSolveSettings solveSettings;
154 // When there is only one bundle observation solve setting, use it for all observations
155 if ( bundleSettings->numberSolveSettings() == 1) {
156 solveSettings = bundleSettings->observationSolveSettings(0);
157 }
158 // Otherwise, we want to grab the bundle observation solve settings that is associated with
159 // the observation number for this new observation
160 else {
161 solveSettings = bundleSettings->observationSolveSettings(observationNumber);
162 }
163
164 bundleObservation->setSolveSettings(solveSettings);
165
166 bundleObservation->setIndex(size());
167
168 bundleImage->setParentObservation(bundleObservation);
169
170 append(bundleObservation);
171
172 // update observation number to observation ptr map
173 m_observationNumberToObservationMap.insert(observationNumber, bundleObservation);
174
175 // update image serial number to observation ptr map
176 m_imageSerialToObservationMap.insert(bundleImage->serialNumber(), bundleObservation);
177
178 // update instrument ID to observation ptr map
179 // separate held observations out into their own entry
180 if (bundleObservation->numberParameters() == 0) {
181 m_instIdToObservationMap.insert("held", bundleObservation);
182 }
183 else {
184 m_instIdToObservationMap.insert(instrumentId, bundleObservation);
185 }
186
187 }
188
189 // If it's an ISIS observation, setup the camera based on the solve settings
190 if (isIsisObservation) {
191 QSharedPointer<IsisBundleObservation> isisObs = qSharedPointerDynamicCast<IsisBundleObservation>(bundleObservation);
192 isisObs->initializeExteriorOrientation();
193 if (bundleSettings->solveTargetBody()) {
194 isisObs->initializeBodyRotation();
195 }
196 }
197 return bundleObservation;
198 }
199
200
208 int numParameters = 0;
209
210 for (int i = 0; i < size(); i++) {
211 numParameters += at(i)->numberParameters();
212 }
213 return numParameters;
214 }
215
216
228 observationByCubeSerialNumber(QString cubeSerialNumber) {
229 BundleObservationQsp bundleObservation;
230
231 if (m_imageSerialToObservationMap.contains(cubeSerialNumber))
232 bundleObservation = m_imageSerialToObservationMap.value(cubeSerialNumber);
233
234 return bundleObservation;
235 }
236
237
244
245
250 observationsByInstId(QString instrumentId) const {
251 QList<BundleObservationQsp> list = m_instIdToObservationMap.values(instrumentId);
252 // multimap returns them in reverse order they were put in, so invert them to preserve order
253 std::reverse(std::begin(list), std::end(list));
254 return list;
255 }
256
257
264 double vtpvImage = 0;
265
266 for (int i = 0; i < size(); i++) {
267 BundleObservationQsp bundleObservation = at(i);
268 vtpvImage += bundleObservation->vtpv();
269 }
270
271 return vtpvImage;
272 }
273}
This class is used to modify and manage solve settings for 1 to many BundleObservations.
double vtpvContribution()
Compute vtpv, the weighted sum of squares of constrained image parameter residuals.
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...
QMultiMap< QString, BundleObservationQsp > m_instIdToObservationMap
Map between instrument ID and pointer to observation.
QMultiMap< QString, BundleObservationQsp > m_imageSerialToObservationMap
Map between image serial number and pointer to observation.
QList< QString > instrumentIds() const
Get a list of all instrument IDs that there are observations for.
BundleObservationVector & operator=(const BundleObservationVector &src)
Assignment operator.
int numberParameters()
Returns the sum of the position parameters and pointing parameters for the contained BundleObservatio...
BundleObservationQsp observationByCubeSerialNumber(QString cubeSerialNumber)
Accesses a BundleObservation associated with the passed serial number.
QMultiMap< QString, BundleObservationQsp > m_observationNumberToObservationMap
Map between observation number and pointer to observation.
BundleObservationVector()
Constructs an empty BundleObservationVector.
QList< BundleObservationQsp > observationsByInstId(QString instrumentId) const
Get all of the observations with a specific instrument ID.
@ Csm
Community Sensor Model Camera.
Definition Camera.h:365
Class for observations that use CSM camera models in bundle adjustment.
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
Class for observations that use ISIS camera models in bundle adjustment.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Calculator.h:18
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QSharedPointer< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.
QSharedPointer< BundleObservation > BundleObservationQsp
Typdef for BundleObservation QSharedPointer.