Isis 3 Programmer Reference
ControlPointV0003.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "ControlPointV0003.h"
10
11#include <QString>
12
13#include "ControlMeasureLogData.h"
14#include "ControlPointFileEntryV0002.pb.h"
15#include "ControlPointV0002.h"
16#include "IException.h"
17#include "PvlObject.h"
18#include "PvlContainer.h"
19
20using namespace std;
21
22namespace Isis {
23
29 ControlPointV0003::ControlPointV0003(QSharedPointer<ControlPointFileEntryV0002> pointData)
30 : m_pointData(pointData) {
31
32 }
33
34
41 : m_pointData(new ControlPointFileEntryV0002) {
42
43 // Copy over strings, doubles, and bools
44 copy(pointObject, "PointId",
45 m_pointData, &ControlPointFileEntryV0002::set_id);
46 copy(pointObject, "ChooserName",
47 m_pointData, &ControlPointFileEntryV0002::set_choosername);
48 copy(pointObject, "DateTime",
49 m_pointData, &ControlPointFileEntryV0002::set_datetime);
50 copy(pointObject, "AprioriXYZSourceFile",
51 m_pointData, &ControlPointFileEntryV0002::set_apriorisurfpointsourcefile);
52 copy(pointObject, "AprioriRadiusSourceFile",
53 m_pointData, &ControlPointFileEntryV0002::set_aprioriradiussourcefile);
54 copy(pointObject, "JigsawRejected",
55 m_pointData, &ControlPointFileEntryV0002::set_jigsawrejected);
56 copy(pointObject, "EditLock",
57 m_pointData, &ControlPointFileEntryV0002::set_editlock);
58 copy(pointObject, "Ignore",
59 m_pointData, &ControlPointFileEntryV0002::set_ignore);
60 copy(pointObject, "AprioriX",
61 m_pointData, &ControlPointFileEntryV0002::set_apriorix);
62 copy(pointObject, "AprioriY",
63 m_pointData, &ControlPointFileEntryV0002::set_aprioriy);
64 copy(pointObject, "AprioriZ",
65 m_pointData, &ControlPointFileEntryV0002::set_aprioriz);
66 copy(pointObject, "AdjustedX",
67 m_pointData, &ControlPointFileEntryV0002::set_adjustedx);
68 copy(pointObject, "AdjustedY",
69 m_pointData, &ControlPointFileEntryV0002::set_adjustedy);
70 copy(pointObject, "AdjustedZ",
71 m_pointData, &ControlPointFileEntryV0002::set_adjustedz);
72 copy(pointObject, "LatitudeConstrained",
73 m_pointData, &ControlPointFileEntryV0002::set_latitudeconstrained);
74 copy(pointObject, "LongitudeConstrained",
75 m_pointData, &ControlPointFileEntryV0002::set_longitudeconstrained);
76 copy(pointObject, "RadiusConstrained",
77 m_pointData, &ControlPointFileEntryV0002::set_radiusconstrained);
78
79 // Copy enumerated values
80
81 // The control point type names were changed between version 3 and version 4.
82 // In version 3, the types are ground, tie, and constrained
83 // In version 4, these were changed to fixed, free, and constrained respectively.
84 // The protobuf file version was not changed, fixed and free were simply added to the
85 // enumeration and the old names were flagged as obsolete.
86 if (pointObject["PointType"][0] == "Fixed"
87 || pointObject["PointType"][0] == "Ground") {
88 m_pointData->set_type(ControlPointFileEntryV0002::Fixed);
89 }
90 else if (pointObject["PointType"][0] == "Constrained") {
91 m_pointData->set_type(ControlPointFileEntryV0002::Constrained);
92 }
93 else if (pointObject["PointType"][0] == "Free"
94 || pointObject["PointType"][0] == "Tie") {
95 m_pointData->set_type(ControlPointFileEntryV0002::Free);
96 }
97 else {
98 QString msg = "Invalid ControlPoint type [" + pointObject["PointType"][0] + "].";
99 throw IException(IException::User, msg, _FILEINFO_);
100 }
101
102 if (pointObject.hasKeyword("AprioriXYZSource")) {
103 QString source = pointObject["AprioriXYZSource"][0];
104
105 if (source == "None") {
106 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::None);
107 }
108 else if (source == "User") {
109 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::User);
110 }
111 else if (source == "AverageOfMeasures") {
112 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::AverageOfMeasures);
113 }
114 else if (source == "Reference") {
115 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Reference);
116 }
117 else if (source == "Basemap") {
118 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Basemap);
119 }
120 else if (source == "BundleSolution") {
121 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::BundleSolution);
122 }
123 else {
124 QString msg = "Invalid AprioriXYZSource [" + source + "]";
125 throw IException(IException::User, msg, _FILEINFO_);
126 }
127 }
128
129 if (pointObject.hasKeyword("AprioriRadiusSource")) {
130 QString source = pointObject["AprioriRadiusSource"][0];
131
132 if (source == "None") {
133 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::None);
134 }
135 else if (source == "User") {
136 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::User);
137 }
138 else if (source == "AverageOfMeasures") {
139 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::AverageOfMeasures);
140 }
141 else if (source == "Ellipsoid") {
142 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::Ellipsoid);
143 }
144 else if (source == "DEM") {
145 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::DEM);
146 }
147 else if (source == "BundleSolution") {
148 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::BundleSolution);
149 }
150 else {
151 QString msg = "Invalid AprioriRadiusSource, [" + source + "]";
152 throw IException(IException::User, msg, _FILEINFO_);
153 }
154 }
155
156 // Copy array values
157 if (pointObject.hasKeyword("AprioriCovarianceMatrix")) {
158 PvlKeyword &matrix = pointObject["AprioriCovarianceMatrix"];
159
160 m_pointData->add_aprioricovar(toDouble(matrix[0]));
161 m_pointData->add_aprioricovar(toDouble(matrix[1]));
162 m_pointData->add_aprioricovar(toDouble(matrix[2]));
163 m_pointData->add_aprioricovar(toDouble(matrix[3]));
164 m_pointData->add_aprioricovar(toDouble(matrix[4]));
165 m_pointData->add_aprioricovar(toDouble(matrix[5]));
166 }
167
168 if (pointObject.hasKeyword("AdjustedCovarianceMatrix")) {
169 PvlKeyword &matrix = pointObject["AdjustedCovarianceMatrix"];
170
171 m_pointData->add_adjustedcovar(toDouble(matrix[0]));
172 m_pointData->add_adjustedcovar(toDouble(matrix[1]));
173 m_pointData->add_adjustedcovar(toDouble(matrix[2]));
174 m_pointData->add_adjustedcovar(toDouble(matrix[3]));
175 m_pointData->add_adjustedcovar(toDouble(matrix[4]));
176 m_pointData->add_adjustedcovar(toDouble(matrix[5]));
177 }
178
179 // Process Measures
180 for (int groupIndex = 0; groupIndex < pointObject.groups(); groupIndex ++) {
181 PvlGroup &group = pointObject.group(groupIndex);
182 ControlPointFileEntryV0002_Measure measure;
183
184 // Copy strings, booleans, and doubles
185 copy(group, "SerialNumber",
186 measure, &ControlPointFileEntryV0002_Measure::set_serialnumber);
187 copy(group, "ChooserName",
188 measure, &ControlPointFileEntryV0002_Measure::set_choosername);
189 copy(group, "Sample",
190 measure, &ControlPointFileEntryV0002_Measure::set_sample);
191 copy(group, "Line",
192 measure, &ControlPointFileEntryV0002_Measure::set_line);
193 copy(group, "SampleResidual",
194 measure, &ControlPointFileEntryV0002_Measure::set_sampleresidual);
195 copy(group, "LineResidual",
196 measure, &ControlPointFileEntryV0002_Measure::set_lineresidual);
197 copy(group, "DateTime",
198 measure, &ControlPointFileEntryV0002_Measure::set_datetime);
199 copy(group, "Diameter",
200 measure, &ControlPointFileEntryV0002_Measure::set_diameter);
201 copy(group, "EditLock",
202 measure, &ControlPointFileEntryV0002_Measure::set_editlock);
203 copy(group, "Ignore",
204 measure, &ControlPointFileEntryV0002_Measure::set_ignore);
205 copy(group, "JigsawRejected",
206 measure, &ControlPointFileEntryV0002_Measure::set_jigsawrejected);
207 copy(group, "AprioriSample",
208 measure, &ControlPointFileEntryV0002_Measure::set_apriorisample);
209 copy(group, "AprioriLine",
210 measure, &ControlPointFileEntryV0002_Measure::set_aprioriline);
211 copy(group, "SampleSigma",
212 measure, &ControlPointFileEntryV0002_Measure::set_samplesigma);
213 copy(group, "LineSigma",
214 measure, &ControlPointFileEntryV0002_Measure::set_linesigma);
215
216 if (group.hasKeyword("Reference")) {
217 if (group["Reference"][0].toLower() == "true") {
218 m_pointData->set_referenceindex(groupIndex);
219 }
220 group.deleteKeyword("Reference");
221 }
222
223 QString type = group["MeasureType"][0].toLower();
224 if (type == "candidate") {
225 measure.set_type(ControlPointFileEntryV0002_Measure::Candidate);
226 }
227 else if (type == "manual") {
228 measure.set_type(ControlPointFileEntryV0002_Measure::Manual);
229 }
230 else if (type == "registeredpixel") {
231 measure.set_type(ControlPointFileEntryV0002_Measure::RegisteredPixel);
232 }
233 else if (type == "registeredsubpixel") {
234 measure.set_type(ControlPointFileEntryV0002_Measure::RegisteredSubPixel);
235 }
236 else {
238 "Unknown measure type [" + type + "]",
239 _FILEINFO_);
240 }
241 group.deleteKeyword("MeasureType");
242
243 for (int key = 0; key < group.keywords(); key++) {
244 ControlMeasureLogData interpreter(group[key]);
245 if (!interpreter.IsValid()) {
246 QString msg = "Unhandled or duplicate keywords in control measure ["
247 + group[key].name() + "]";
248 throw IException(IException::Programmer, msg, _FILEINFO_);
249 }
250 else {
251 ControlPointFileEntryV0002_Measure_MeasureLogData protoBufDataEntry;
252
253 protoBufDataEntry.set_doubledatatype(interpreter.GetDataType());
254 protoBufDataEntry.set_doubledatavalue(interpreter.GetNumericalValue());
255
256 *measure.add_log() = protoBufDataEntry;
257 }
258 }
259
260 *m_pointData->add_measures() = measure;
261 }
262
263 if (!m_pointData->IsInitialized()) {
264 QString msg = "There is missing required information in the control "
265 "points or measures";
266 throw IException(IException::Io, msg, _FILEINFO_);
267 }
268 }
269
270
277 : m_pointData(new ControlPointFileEntryV0002) {
278 QSharedPointer<ControlNetFileProtoV0001_PBControlPoint> oldPointData = oldPoint.pointData();
279 if (!oldPointData) {
280 QString msg = "Version 2 control point is missing point data.";
281 throw IException(IException::User, msg, _FILEINFO_);
282 }
283 QSharedPointer<ControlNetLogDataProtoV0001_Point> oldLogData = oldPoint.logData();
284 if (!oldLogData) {
285 QString msg = "Version 2 control point is missing measure log data.";
286 throw IException(IException::User, msg, _FILEINFO_);
287 }
288
289 // Copy over POD values
290 if ( oldPointData->has_id() ) {
291 m_pointData->set_id( oldPointData->id() );
292 }
293 if ( oldPointData->has_choosername() ) {
294 m_pointData->set_choosername( oldPointData->choosername() );
295 }
296 if ( oldPointData->has_datetime() ) {
297 m_pointData->set_datetime( oldPointData->datetime() );
298 }
299 if ( oldPointData->has_apriorisurfpointsourcefile() ) {
300 m_pointData->set_apriorisurfpointsourcefile( oldPointData->apriorisurfpointsourcefile() );
301 }
302 if ( oldPointData->has_aprioriradiussourcefile() ) {
303 m_pointData->set_aprioriradiussourcefile( oldPointData->aprioriradiussourcefile() );
304 }
305 if ( oldPointData->has_jigsawrejected() ) {
306 m_pointData->set_jigsawrejected( oldPointData->jigsawrejected() );
307 }
308 if ( oldPointData->has_editlock() ) {
309 m_pointData->set_editlock( oldPointData->editlock() );
310 }
311 if ( oldPointData->has_ignore() ) {
312 m_pointData->set_ignore( oldPointData->ignore() );
313 }
314 if ( oldPointData->has_apriorix() ) {
315 m_pointData->set_apriorix( oldPointData->apriorix() );
316 }
317 if ( oldPointData->has_aprioriy() ) {
318 m_pointData->set_aprioriy( oldPointData->aprioriy() );
319 }
320 if ( oldPointData->has_aprioriz() ) {
321 m_pointData->set_aprioriz( oldPointData->aprioriz() );
322 }
323 if ( oldPointData->has_adjustedx() ) {
324 m_pointData->set_adjustedx( oldPointData->adjustedx() );
325 }
326 if ( oldPointData->has_adjustedy() ) {
327 m_pointData->set_adjustedy( oldPointData->adjustedy() );
328 }
329 if ( oldPointData->has_adjustedz() ) {
330 m_pointData->set_adjustedz( oldPointData->adjustedz() );
331 }
332 if ( oldPointData->has_latitudeconstrained() ) {
333 m_pointData->set_latitudeconstrained( oldPointData->latitudeconstrained() );
334 }
335 if ( oldPointData->has_longitudeconstrained() ) {
336 m_pointData->set_longitudeconstrained( oldPointData->longitudeconstrained() );
337 }
338 if ( oldPointData->has_radiusconstrained() ) {
339 m_pointData->set_radiusconstrained( oldPointData->radiusconstrained() );
340 }
341 if ( oldPointData->has_referenceindex() ) {
342 m_pointData->set_referenceindex( oldPointData->referenceindex() );
343 }
344
345 // Copy over enumerated values
346
347 // The only point types in V0002 are ground and tie.
348 // So, convert ground and tie to their V0003 values, fixed and free respectively.
349 // Later check if the point is constrained.
350 if ( oldPointData->has_type() ) {
351 ControlNetFileProtoV0001_PBControlPoint_PointType pointType = oldPointData->type();
352 if (pointType == ControlNetFileProtoV0001_PBControlPoint::Ground) {
353 m_pointData->set_type(ControlPointFileEntryV0002::Fixed);
354 }
355 else if (pointType == ControlNetFileProtoV0001_PBControlPoint::Tie) {
356 m_pointData->set_type(ControlPointFileEntryV0002::Free);
357 }
358 else {
359 QString msg = "Invalid ControlPoint type.";
360 throw IException(IException::User, msg, _FILEINFO_);
361 }
362 }
363
364 if ( oldPointData->has_apriorisurfpointsource() ) {
365 ControlNetFileProtoV0001_PBControlPoint_AprioriSource surfacePointSource;
366 surfacePointSource = oldPointData->apriorisurfpointsource();
367 if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::None) {
368 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::None);
369 }
370 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::User) {
371 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::User);
372 }
373 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures) {
374 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::AverageOfMeasures);
375 }
376 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::Reference) {
377 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Reference);
378 }
379 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::Basemap) {
380 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Basemap);
381 }
382 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::BundleSolution) {
383 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::BundleSolution);
384 }
385 else {
386 QString msg = "Invalid ControlPoint apriori surface point source.";
387 throw IException(IException::User, msg, _FILEINFO_);
388 }
389 }
390
391 if ( oldPointData->has_aprioriradiussource() ) {
392 ControlNetFileProtoV0001_PBControlPoint_AprioriSource radiusSource;
393 radiusSource = oldPointData->aprioriradiussource();
394 if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::None) {
395 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::None);
396 }
397 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::User) {
398 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::User);
399 }
400 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures) {
401 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::AverageOfMeasures);
402 }
403 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::Ellipsoid) {
404 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::Ellipsoid);
405 }
406 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::DEM) {
407 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::DEM);
408 }
409 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::BundleSolution) {
410 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::BundleSolution);
411 }
412 else {
413 QString msg = "Invalid AprioriRadiusSource.";
414 throw IException(IException::User, msg, _FILEINFO_);
415 }
416 }
417
418 // Copy the array values
419
420 // If there is a covariance matrix, then the point is constrained
421 if (oldPointData->aprioricovar_size() > 0) {
422 m_pointData->set_type(ControlPointFileEntryV0002::Constrained);
423 m_pointData->add_aprioricovar( oldPointData->aprioricovar(0) );
424 m_pointData->add_aprioricovar( oldPointData->aprioricovar(1) );
425 m_pointData->add_aprioricovar( oldPointData->aprioricovar(2) );
426 m_pointData->add_aprioricovar( oldPointData->aprioricovar(3) );
427 m_pointData->add_aprioricovar( oldPointData->aprioricovar(4) );
428 m_pointData->add_aprioricovar( oldPointData->aprioricovar(5) );
429 }
430
431 if (oldPointData->adjustedcovar_size() > 0) {
432 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(0) );
433 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(1) );
434 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(2) );
435 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(3) );
436 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(4) );
437 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(5) );
438 }
439
440 // Copy the measures
441 for (int i = 0; i < oldPointData->measures_size(); i++) {
442 ControlPointFileEntryV0002_Measure *newMeasure = m_pointData->add_measures();
443 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure oldMeasure;
444 oldMeasure = oldPointData->measures(i);
445
446 // Copy over POD values
447 if ( oldMeasure.has_serialnumber() ) {
448 newMeasure->set_serialnumber( oldMeasure.serialnumber() );
449 }
450 if ( oldMeasure.has_choosername() ) {
451 newMeasure->set_choosername( oldMeasure.choosername() );
452 }
453 if ( oldMeasure.has_datetime() ) {
454 newMeasure->set_datetime( oldMeasure.datetime() );
455 }
456 if ( oldMeasure.has_diameter() ) {
457 newMeasure->set_diameter( oldMeasure.diameter() );
458 }
459 if ( oldMeasure.has_editlock() ) {
460 newMeasure->set_editlock( oldMeasure.editlock() );
461 }
462 if ( oldMeasure.has_ignore() ) {
463 newMeasure->set_ignore( oldMeasure.ignore() );
464 }
465 if ( oldMeasure.has_jigsawrejected() ) {
466 newMeasure->set_jigsawrejected( oldMeasure.jigsawrejected() );
467 }
468 if ( oldMeasure.has_apriorisample() ) {
469 newMeasure->set_apriorisample( oldMeasure.apriorisample() );
470 }
471 if ( oldMeasure.has_aprioriline() ) {
472 newMeasure->set_aprioriline( oldMeasure.aprioriline() );
473 }
474 if ( oldMeasure.has_samplesigma() ) {
475 newMeasure->set_samplesigma( oldMeasure.samplesigma() );
476 }
477 if ( oldMeasure.has_linesigma() ) {
478 newMeasure->set_linesigma( oldMeasure.linesigma() );
479 }
480 // In the version 1 protobuf format, the sample, line, sample residual, and line residual
481 // values are stored in a nested message so we have to copy them differently.
482 if ( oldMeasure.has_measurement() ) {
483 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_PBMeasure oldMeasurement;
484 oldMeasurement = oldMeasure.measurement();
485 if ( oldMeasurement.has_sample() ) {
486 newMeasure->set_sample( oldMeasurement.sample() );
487 }
488 if ( oldMeasurement.has_line() ) {
489 newMeasure->set_line( oldMeasurement.line() );
490 }
491 if ( oldMeasurement.has_sampleresidual() ) {
492 newMeasure->set_sampleresidual( oldMeasurement.sampleresidual() );
493 }
494 if ( oldMeasurement.has_lineresidual() ) {
495 newMeasure->set_lineresidual( oldMeasurement.lineresidual() );
496 }
497 }
498
499 // Copy over the enumerated values
500 if ( oldMeasure.has_type() ) {
501 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType oldType;
502 oldType = oldMeasure.type();
503 if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_Candidate) {
504 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_Candidate);
505 }
506 else if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_Manual) {
507 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_Manual);
508 }
509 else if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_RegisteredPixel) {
510 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_RegisteredPixel);
511 }
512 else if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_RegisteredSubPixel) {
513 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_RegisteredSubPixel);
514 }
515 else {
516 QString msg = "Invalid measure type";
517 throw IException(IException::User, msg, _FILEINFO_);
518 }
519
520 // Copy over any log data
521 ControlNetLogDataProtoV0001_Point_Measure measureLogData = oldLogData->measures(i);
522 for (int j = 0; j < measureLogData.loggedmeasuredata_size(); j++) {
523
524 ControlNetLogDataProtoV0001_Point_Measure_DataEntry oldData =
525 measureLogData.loggedmeasuredata(j);
526
527 ControlPointFileEntryV0002_Measure_MeasureLogData newData;
528
529 newData.set_doubledatatype( oldData.datatype() );
530 newData.set_doubledatavalue( oldData.datavalue() );
531
532 *newMeasure->add_log() = newData;
533 }
534
535 // Check that all the required fields in the measure are filled
536 if ( !newMeasure->IsInitialized() ) {
537 QString msg = "Measure file entry at index [" + toString(i)
538 + "] is missing required fields.";
539 throw IException(IException::User, msg, _FILEINFO_);
540 }
541 }
542 }
543
544 // Check that all of the required fields in the point are filled
545 if ( !m_pointData->IsInitialized() ) {
546 QString msg = "Control point file entry is missing required fields.";
547 throw IException(IException::User, msg, _FILEINFO_);
548 }
549 }
550
551
561 const ControlPointFileEntryV0002 &ControlPointV0003::pointData() {
562 if (!m_pointData) {
563 m_pointData.reset(new ControlPointFileEntryV0002);
564 }
565
566 return *m_pointData;
567 }
568
569
585 QString keyName,
586 QSharedPointer<ControlPointFileEntryV0002> point,
587 void (ControlPointFileEntryV0002::*setter)(bool)) {
588
589 if (!container.hasKeyword(keyName)) {
590 return;
591 }
592
593 QString value = container[keyName][0];
594 container.deleteKeyword(keyName);
595 value = value.toLower();
596
597 if (value == "true" || value == "yes") {
598 (point.data()->*setter)(true);
599 }
600 }
601
602
618 QString keyName,
619 QSharedPointer<ControlPointFileEntryV0002> point,
620 void (ControlPointFileEntryV0002::*setter)(double)) {
621
622 if (!container.hasKeyword(keyName)) {
623 return;
624 }
625
626 double value = toDouble(container[keyName][0]);
627 container.deleteKeyword(keyName);
628 (point.data()->*setter)(value);
629 }
630
631
647 QString keyName,
648 QSharedPointer<ControlPointFileEntryV0002> point,
649 void (ControlPointFileEntryV0002::*setter)(const std::string&)) {
650
651 if (!container.hasKeyword(keyName)) {
652 return;
653 }
654
655 QString value = container[keyName][0];
656 container.deleteKeyword(keyName);
657 (point.data()->*setter)(value.toLatin1().data());
658 }
659
660
676 QString keyName,
677 ControlPointFileEntryV0002_Measure &measure,
678 void (ControlPointFileEntryV0002_Measure::*setter)(bool)) {
679
680 if (!container.hasKeyword(keyName)) {
681 return;
682 }
683
684 QString value = container[keyName][0];
685 container.deleteKeyword(keyName);
686 value = value.toLower();
687
688 if (value == "true" || value == "yes") {
689 (measure.*setter)(true);
690 }
691 }
692
693
709 QString keyName,
710 ControlPointFileEntryV0002_Measure &measure,
711 void (ControlPointFileEntryV0002_Measure::*setter)(double)) {
712
713 if (!container.hasKeyword(keyName)) {
714 return;
715 }
716
717 double value = toDouble(container[keyName][0]);
718 container.deleteKeyword(keyName);
719 (measure.*setter)(value);
720 }
721
722
738 QString keyName,
739 ControlPointFileEntryV0002_Measure &measure,
740 void (ControlPointFileEntryV0002_Measure::*setter)
741 (const std::string &)) {
742
743 if (!container.hasKeyword(keyName)) {
744 return;
745 }
746
747 QString value = container[keyName][0];
748 container.deleteKeyword(keyName);
749 (measure.*setter)(value.toLatin1().data());
750 }
751}
Statistical and similar ControlMeasure associated information.
A container for the information stored in a version 2 ControlPoint.
void copy(PvlContainer &container, QString keyName, QSharedPointer< ControlPointFileEntryV0002 > point, void(ControlPointFileEntryV0002::*setter)(bool))
This convenience method takes a boolean value from a PvlKeyword and copies it into a version 2 protob...
const ControlPointFileEntryV0002 & pointData()
Access the protobuf control point data.
QSharedPointer< ControlPointFileEntryV0002 > m_pointData
protobuf container that holds information used to create a control point.
ControlPointV0003()
Default constructor.
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
Contains more than one keyword-value pair.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
QString name() const
Returns the container name.
void deleteKeyword(const QString &name)
Remove a specified keyword.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
A single keyword-value pair.
Definition PvlKeyword.h:87
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
Namespace for the standard library.