6 #include "ControlPointFileEntryV0002.pb.h" 22 : m_pointData(pointData) {
33 : m_pointData(new ControlPointFileEntryV0002) {
36 copy(pointObject,
"PointId",
38 copy(pointObject,
"ChooserName",
39 m_pointData, &ControlPointFileEntryV0002::set_choosername);
40 copy(pointObject,
"DateTime",
41 m_pointData, &ControlPointFileEntryV0002::set_datetime);
42 copy(pointObject,
"AprioriXYZSourceFile",
43 m_pointData, &ControlPointFileEntryV0002::set_apriorisurfpointsourcefile);
44 copy(pointObject,
"AprioriRadiusSourceFile",
45 m_pointData, &ControlPointFileEntryV0002::set_aprioriradiussourcefile);
46 copy(pointObject,
"JigsawRejected",
47 m_pointData, &ControlPointFileEntryV0002::set_jigsawrejected);
48 copy(pointObject,
"EditLock",
49 m_pointData, &ControlPointFileEntryV0002::set_editlock);
50 copy(pointObject,
"Ignore",
51 m_pointData, &ControlPointFileEntryV0002::set_ignore);
52 copy(pointObject,
"AprioriX",
53 m_pointData, &ControlPointFileEntryV0002::set_apriorix);
54 copy(pointObject,
"AprioriY",
55 m_pointData, &ControlPointFileEntryV0002::set_aprioriy);
56 copy(pointObject,
"AprioriZ",
57 m_pointData, &ControlPointFileEntryV0002::set_aprioriz);
58 copy(pointObject,
"AdjustedX",
59 m_pointData, &ControlPointFileEntryV0002::set_adjustedx);
60 copy(pointObject,
"AdjustedY",
61 m_pointData, &ControlPointFileEntryV0002::set_adjustedy);
62 copy(pointObject,
"AdjustedZ",
63 m_pointData, &ControlPointFileEntryV0002::set_adjustedz);
64 copy(pointObject,
"LatitudeConstrained",
65 m_pointData, &ControlPointFileEntryV0002::set_latitudeconstrained);
66 copy(pointObject,
"LongitudeConstrained",
67 m_pointData, &ControlPointFileEntryV0002::set_longitudeconstrained);
68 copy(pointObject,
"RadiusConstrained",
69 m_pointData, &ControlPointFileEntryV0002::set_radiusconstrained);
78 if (pointObject[
"PointType"][0] ==
"Fixed" 79 || pointObject[
"PointType"][0] ==
"Ground") {
80 m_pointData->set_type(ControlPointFileEntryV0002::Fixed);
82 else if (pointObject[
"PointType"][0] ==
"Constrained") {
83 m_pointData->set_type(ControlPointFileEntryV0002::Constrained);
85 else if (pointObject[
"PointType"][0] ==
"Free" 86 || pointObject[
"PointType"][0] ==
"Tie") {
87 m_pointData->set_type(ControlPointFileEntryV0002::Free);
90 QString msg =
"Invalid ControlPoint type [" + pointObject[
"PointType"][0] +
"].";
94 if (pointObject.
hasKeyword(
"AprioriXYZSource")) {
95 QString source = pointObject[
"AprioriXYZSource"][0];
97 if (source ==
"None") {
98 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::None);
100 else if (source ==
"User") {
101 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::User);
103 else if (source ==
"AverageOfMeasures") {
104 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::AverageOfMeasures);
106 else if (source ==
"Reference") {
107 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Reference);
109 else if (source ==
"Basemap") {
110 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Basemap);
112 else if (source ==
"BundleSolution") {
113 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::BundleSolution);
116 QString msg =
"Invalid AprioriXYZSource [" + source +
"]";
121 if (pointObject.
hasKeyword(
"AprioriRadiusSource")) {
122 QString source = pointObject[
"AprioriRadiusSource"][0];
124 if (source ==
"None") {
125 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::None);
127 else if (source ==
"User") {
128 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::User);
130 else if (source ==
"AverageOfMeasures") {
131 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::AverageOfMeasures);
133 else if (source ==
"Ellipsoid") {
134 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::Ellipsoid);
136 else if (source ==
"DEM") {
137 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::DEM);
139 else if (source ==
"BundleSolution") {
140 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::BundleSolution);
143 QString msg =
"Invalid AprioriRadiusSource, [" + source +
"]";
149 if (pointObject.
hasKeyword(
"AprioriCovarianceMatrix")) {
150 PvlKeyword &matrix = pointObject[
"AprioriCovarianceMatrix"];
160 if (pointObject.
hasKeyword(
"AdjustedCovarianceMatrix")) {
161 PvlKeyword &matrix = pointObject[
"AdjustedCovarianceMatrix"];
172 for (
int groupIndex = 0; groupIndex < pointObject.
groups(); groupIndex ++) {
174 ControlPointFileEntryV0002_Measure measure;
177 copy(group,
"SerialNumber",
178 measure, &ControlPointFileEntryV0002_Measure::set_serialnumber);
179 copy(group,
"ChooserName",
180 measure, &ControlPointFileEntryV0002_Measure::set_choosername);
181 copy(group,
"Sample",
182 measure, &ControlPointFileEntryV0002_Measure::set_sample);
184 measure, &ControlPointFileEntryV0002_Measure::set_line);
185 copy(group,
"SampleResidual",
186 measure, &ControlPointFileEntryV0002_Measure::set_sampleresidual);
187 copy(group,
"LineResidual",
188 measure, &ControlPointFileEntryV0002_Measure::set_lineresidual);
189 copy(group,
"DateTime",
190 measure, &ControlPointFileEntryV0002_Measure::set_datetime);
191 copy(group,
"Diameter",
192 measure, &ControlPointFileEntryV0002_Measure::set_diameter);
193 copy(group,
"EditLock",
194 measure, &ControlPointFileEntryV0002_Measure::set_editlock);
195 copy(group,
"Ignore",
196 measure, &ControlPointFileEntryV0002_Measure::set_ignore);
197 copy(group,
"JigsawRejected",
198 measure, &ControlPointFileEntryV0002_Measure::set_jigsawrejected);
199 copy(group,
"AprioriSample",
200 measure, &ControlPointFileEntryV0002_Measure::set_apriorisample);
201 copy(group,
"AprioriLine",
202 measure, &ControlPointFileEntryV0002_Measure::set_aprioriline);
203 copy(group,
"SampleSigma",
204 measure, &ControlPointFileEntryV0002_Measure::set_samplesigma);
205 copy(group,
"LineSigma",
206 measure, &ControlPointFileEntryV0002_Measure::set_linesigma);
209 if (group[
"Reference"][0].toLower() ==
"true") {
215 QString type = group[
"MeasureType"][0].toLower();
216 if (type ==
"candidate") {
217 measure.set_type(ControlPointFileEntryV0002_Measure::Candidate);
219 else if (type ==
"manual") {
220 measure.set_type(ControlPointFileEntryV0002_Measure::Manual);
222 else if (type ==
"registeredpixel") {
223 measure.set_type(ControlPointFileEntryV0002_Measure::RegisteredPixel);
225 else if (type ==
"registeredsubpixel") {
226 measure.set_type(ControlPointFileEntryV0002_Measure::RegisteredSubPixel);
230 "Unknown measure type [" + type +
"]",
235 for (
int key = 0; key < group.
keywords(); key++) {
238 QString msg =
"Unhandled or duplicate keywords in control measure [" 239 + group[key].
name() +
"]";
243 ControlPointFileEntryV0002_Measure_MeasureLogData protoBufDataEntry;
245 protoBufDataEntry.set_doubledatatype(interpreter.
GetDataType());
248 *measure.add_log() = protoBufDataEntry;
256 QString msg =
"There is missing required information in the control " 257 "points or measures";
269 : m_pointData(new ControlPointFileEntryV0002) {
272 QString msg =
"Version 2 control point is missing point data.";
277 QString msg =
"Version 2 control point is missing measure log data.";
282 if ( oldPointData->has_id() ) {
285 if ( oldPointData->has_choosername() ) {
286 m_pointData->set_choosername( oldPointData->choosername() );
288 if ( oldPointData->has_datetime() ) {
289 m_pointData->set_datetime( oldPointData->datetime() );
291 if ( oldPointData->has_apriorisurfpointsourcefile() ) {
292 m_pointData->set_apriorisurfpointsourcefile( oldPointData->apriorisurfpointsourcefile() );
294 if ( oldPointData->has_aprioriradiussourcefile() ) {
295 m_pointData->set_aprioriradiussourcefile( oldPointData->aprioriradiussourcefile() );
297 if ( oldPointData->has_jigsawrejected() ) {
298 m_pointData->set_jigsawrejected( oldPointData->jigsawrejected() );
300 if ( oldPointData->has_editlock() ) {
301 m_pointData->set_editlock( oldPointData->editlock() );
303 if ( oldPointData->has_ignore() ) {
306 if ( oldPointData->has_apriorix() ) {
307 m_pointData->set_apriorix( oldPointData->apriorix() );
309 if ( oldPointData->has_aprioriy() ) {
310 m_pointData->set_aprioriy( oldPointData->aprioriy() );
312 if ( oldPointData->has_aprioriz() ) {
313 m_pointData->set_aprioriz( oldPointData->aprioriz() );
315 if ( oldPointData->has_adjustedx() ) {
316 m_pointData->set_adjustedx( oldPointData->adjustedx() );
318 if ( oldPointData->has_adjustedy() ) {
319 m_pointData->set_adjustedy( oldPointData->adjustedy() );
321 if ( oldPointData->has_adjustedz() ) {
322 m_pointData->set_adjustedz( oldPointData->adjustedz() );
324 if ( oldPointData->has_latitudeconstrained() ) {
325 m_pointData->set_latitudeconstrained( oldPointData->latitudeconstrained() );
327 if ( oldPointData->has_longitudeconstrained() ) {
328 m_pointData->set_longitudeconstrained( oldPointData->longitudeconstrained() );
330 if ( oldPointData->has_radiusconstrained() ) {
331 m_pointData->set_radiusconstrained( oldPointData->radiusconstrained() );
333 if ( oldPointData->has_referenceindex() ) {
334 m_pointData->set_referenceindex( oldPointData->referenceindex() );
342 if ( oldPointData->has_type() ) {
343 ControlNetFileProtoV0001_PBControlPoint_PointType pointType = oldPointData->type();
344 if (pointType == ControlNetFileProtoV0001_PBControlPoint::Ground) {
345 m_pointData->set_type(ControlPointFileEntryV0002::Fixed);
347 else if (pointType == ControlNetFileProtoV0001_PBControlPoint::Tie) {
348 m_pointData->set_type(ControlPointFileEntryV0002::Free);
351 QString msg =
"Invalid ControlPoint type.";
356 if ( oldPointData->has_apriorisurfpointsource() ) {
357 ControlNetFileProtoV0001_PBControlPoint_AprioriSource surfacePointSource;
358 surfacePointSource = oldPointData->apriorisurfpointsource();
359 if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::None) {
360 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::None);
362 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::User) {
363 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::User);
365 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures) {
366 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::AverageOfMeasures);
368 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::Reference) {
369 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Reference);
371 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::Basemap) {
372 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::Basemap);
374 else if (surfacePointSource == ControlNetFileProtoV0001_PBControlPoint::BundleSolution) {
375 m_pointData->set_apriorisurfpointsource(ControlPointFileEntryV0002::BundleSolution);
378 QString msg =
"Invalid ControlPoint apriori surface point source.";
383 if ( oldPointData->has_aprioriradiussource() ) {
384 ControlNetFileProtoV0001_PBControlPoint_AprioriSource radiusSource;
385 radiusSource = oldPointData->aprioriradiussource();
386 if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::None) {
387 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::None);
389 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::User) {
390 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::User);
392 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures) {
393 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::AverageOfMeasures);
395 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::Ellipsoid) {
396 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::Ellipsoid);
398 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::DEM) {
399 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::DEM);
401 else if (radiusSource == ControlNetFileProtoV0001_PBControlPoint::BundleSolution) {
402 m_pointData->set_aprioriradiussource(ControlPointFileEntryV0002::BundleSolution);
405 QString msg =
"Invalid AprioriRadiusSource.";
413 if (oldPointData->aprioricovar_size() > 0) {
414 m_pointData->set_type(ControlPointFileEntryV0002::Constrained);
415 m_pointData->add_aprioricovar( oldPointData->aprioricovar(0) );
416 m_pointData->add_aprioricovar( oldPointData->aprioricovar(1) );
417 m_pointData->add_aprioricovar( oldPointData->aprioricovar(2) );
418 m_pointData->add_aprioricovar( oldPointData->aprioricovar(3) );
419 m_pointData->add_aprioricovar( oldPointData->aprioricovar(4) );
420 m_pointData->add_aprioricovar( oldPointData->aprioricovar(5) );
423 if (oldPointData->adjustedcovar_size() > 0) {
424 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(0) );
425 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(1) );
426 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(2) );
427 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(3) );
428 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(4) );
429 m_pointData->add_adjustedcovar( oldPointData->adjustedcovar(5) );
433 for (
int i = 0; i < oldPointData->measures_size(); i++) {
434 ControlPointFileEntryV0002_Measure *newMeasure =
m_pointData->add_measures();
435 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure oldMeasure;
436 oldMeasure = oldPointData->measures(i);
439 if ( oldMeasure.has_serialnumber() ) {
440 newMeasure->set_serialnumber( oldMeasure.serialnumber() );
442 if ( oldMeasure.has_choosername() ) {
443 newMeasure->set_choosername( oldMeasure.choosername() );
445 if ( oldMeasure.has_datetime() ) {
446 newMeasure->set_datetime( oldMeasure.datetime() );
448 if ( oldMeasure.has_diameter() ) {
449 newMeasure->set_diameter( oldMeasure.diameter() );
451 if ( oldMeasure.has_editlock() ) {
452 newMeasure->set_editlock( oldMeasure.editlock() );
454 if ( oldMeasure.has_ignore() ) {
455 newMeasure->set_ignore( oldMeasure.ignore() );
457 if ( oldMeasure.has_jigsawrejected() ) {
458 newMeasure->set_jigsawrejected( oldMeasure.jigsawrejected() );
460 if ( oldMeasure.has_apriorisample() ) {
461 newMeasure->set_apriorisample( oldMeasure.apriorisample() );
463 if ( oldMeasure.has_aprioriline() ) {
464 newMeasure->set_aprioriline( oldMeasure.aprioriline() );
466 if ( oldMeasure.has_samplesigma() ) {
467 newMeasure->set_samplesigma( oldMeasure.samplesigma() );
469 if ( oldMeasure.has_linesigma() ) {
470 newMeasure->set_linesigma( oldMeasure.linesigma() );
474 if ( oldMeasure.has_measurement() ) {
475 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_PBMeasure oldMeasurement;
476 oldMeasurement = oldMeasure.measurement();
477 if ( oldMeasurement.has_sample() ) {
478 newMeasure->set_sample( oldMeasurement.sample() );
480 if ( oldMeasurement.has_line() ) {
481 newMeasure->set_line( oldMeasurement.line() );
483 if ( oldMeasurement.has_sampleresidual() ) {
484 newMeasure->set_sampleresidual( oldMeasurement.sampleresidual() );
486 if ( oldMeasurement.has_lineresidual() ) {
487 newMeasure->set_lineresidual( oldMeasurement.lineresidual() );
492 if ( oldMeasure.has_type() ) {
493 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType oldType;
494 oldType = oldMeasure.type();
495 if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_Candidate) {
496 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_Candidate);
498 else if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_Manual) {
499 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_Manual);
501 else if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_RegisteredPixel) {
502 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_RegisteredPixel);
504 else if (oldType == ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure_MeasureType_RegisteredSubPixel) {
505 newMeasure->set_type(ControlPointFileEntryV0002_Measure_MeasureType_RegisteredSubPixel);
508 QString msg =
"Invalid measure type";
513 ControlNetLogDataProtoV0001_Point_Measure measureLogData = oldLogData->measures(i);
514 for (
int j = 0; j < measureLogData.loggedmeasuredata_size(); j++) {
516 ControlNetLogDataProtoV0001_Point_Measure_DataEntry oldData =
517 measureLogData.loggedmeasuredata(j);
519 ControlPointFileEntryV0002_Measure_MeasureLogData newData;
521 newData.set_doubledatatype( oldData.datatype() );
522 newData.set_doubledatavalue( oldData.datavalue() );
524 *newMeasure->add_log() = newData;
528 if ( !newMeasure->IsInitialized() ) {
529 QString msg =
"Measure file entry at index [" +
toString(i)
530 +
"] is missing required fields.";
538 QString msg =
"Control point file entry is missing required fields.";
579 void (ControlPointFileEntryV0002::*setter)(
bool)) {
585 QString value = container[keyName][0];
587 value = value.toLower();
589 if (value ==
"true" || value ==
"yes") {
590 (point.data()->*setter)(
true);
612 void (ControlPointFileEntryV0002::*setter)(
double)) {
618 double value =
toDouble(container[keyName][0]);
620 (point.data()->*setter)(value);
641 void (ControlPointFileEntryV0002::*setter)(
const std::string&)) {
647 QString value = container[keyName][0];
649 (point.data()->*setter)(value.toLatin1().data());
669 ControlPointFileEntryV0002_Measure &measure,
670 void (ControlPointFileEntryV0002_Measure::*setter)(
bool)) {
676 QString value = container[keyName][0];
678 value = value.toLower();
680 if (value ==
"true" || value ==
"yes") {
681 (measure.*setter)(
true);
702 ControlPointFileEntryV0002_Measure &measure,
703 void (ControlPointFileEntryV0002_Measure::*setter)(
double)) {
709 double value =
toDouble(container[keyName][0]);
711 (measure.*setter)(value);
731 ControlPointFileEntryV0002_Measure &measure,
732 void (ControlPointFileEntryV0002_Measure::*setter)
733 (
const std::string &)) {
739 QString value = container[keyName][0];
741 (measure.*setter)(value.toLatin1().data());
int keywords() const
Returns the number of keywords contained in the PvlContainer.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
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...
NumericLogDataType GetDataType() const
Get the data type associated with this log data.
Contains more than one keyword-value pair.
Statistical and similar ControlMeasure associated information.
Namespace for the standard library.
QSharedPointer< ControlPointFileEntryV0002 > m_pointData
protobuf container that holds information used to create a control point.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
double toDouble(const QString &string)
Global function to convert from a string to a double.
This error is for when a programmer made an API call that was illegal.
A type of error that occurred when performing an actual I/O operation.
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
QString name() const
Returns the container name.
bool IsValid() const
This tests if the log data is complete and valid.
QSharedPointer< ControlNetFileProtoV0001_PBControlPoint > pointData()
Access the protobuf control point data.
QSharedPointer< ControlNetLogDataProtoV0001_Point > logData()
Access the protobuf log data for the control measures in the point.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
ControlPointV0003()
Default constructor.
A type of error that could only have occurred due to a mistake on the user's part (e...
A single keyword-value pair.
PvlGroup & group(const int index)
Return the group at the specified index.
Namespace for ISIS/Bullet specific routines.
int groups() const
Returns the number of groups contained.
double GetNumericalValue() const
Get the value associated with this log data.
Contains Pvl Groups and Pvl Objects.
A container for the information stored in a version 2 ControlPoint.
const ControlPointFileEntryV0002 & pointData()
Access the protobuf control point data.
void deleteKeyword(const QString &name)
Remove a specified keyword.