9 #include "ControlPointV0001.h"
13 #include "ControlMeasureLogData.h"
15 #include "IException.h"
17 #include "Longitude.h"
18 #include "NaifStatus.h"
20 #include "PvlContainer.h"
21 #include "SpecialPixel.h"
22 #include "SurfacePoint.h"
35 ControlPointV0001::ControlPointV0001(
38 : m_pointData(pointData), m_logData(logData) {
50 : m_pointData(new ControlNetFileProtoV0001_PBControlPoint),
51 m_logData(new ControlNetLogDataProtoV0001_Point) {
54 for (
int cpKeyIndex = 0; cpKeyIndex < pointObject.
keywords(); cpKeyIndex ++) {
55 if (pointObject[cpKeyIndex][0] ==
"") {
61 copy(pointObject,
"PointId",
62 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_id);
63 copy(pointObject,
"ChooserName",
64 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_choosername);
65 copy(pointObject,
"DateTime",
66 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_datetime);
67 copy(pointObject,
"AprioriXYZSourceFile",
68 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorisurfpointsourcefile);
69 copy(pointObject,
"AprioriLatLonSourceFile",
70 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorisurfpointsourcefile);
71 copy(pointObject,
"AprioriRadiusSourceFile",
72 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriradiussourcefile);
73 copy(pointObject,
"JigsawRejected",
74 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_jigsawrejected);
75 copy(pointObject,
"EditLock",
76 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_editlock);
77 copy(pointObject,
"Ignore",
78 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_ignore);
79 copy(pointObject,
"LatitudeConstrained",
80 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_latitudeconstrained);
81 copy(pointObject,
"LongitudeConstrained",
82 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_longitudeconstrained);
83 copy(pointObject,
"RadiusConstrained",
84 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_radiusconstrained);
107 if ( pointObject.
hasKeyword(
"AprioriLatitude")
109 && pointObject.
hasKeyword(
"AprioriRadius") ) {
136 if ( (pointObject.
hasKeyword(
"Held") && pointObject[
"Held"][0] ==
"True")
137 || (pointObject[
"PointType"][0] ==
"Ground") ) {
138 m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Ground);
140 else if (pointObject[
"PointType"][0] ==
"Tie") {
141 m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Tie);
144 QString msg =
"Invalid ControlPoint type [" + pointObject[
"PointType"][0] +
"].";
148 if (pointObject.
hasKeyword(
"AprioriXYZSource")) {
149 QString source = pointObject[
"AprioriXYZSource"][0];
151 if (source ==
"None") {
152 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::None);
154 else if (source ==
"User") {
155 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::User);
157 else if (source ==
"AverageOfMeasures") {
159 ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures);
161 else if (source ==
"Reference") {
163 ControlNetFileProtoV0001_PBControlPoint::Reference);
165 else if (source ==
"Basemap") {
166 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Basemap);
168 else if (source ==
"BundleSolution") {
170 ControlNetFileProtoV0001_PBControlPoint::BundleSolution);
173 QString msg =
"Invalid AprioriXYZSource [" + source +
"]";
178 if (pointObject.
hasKeyword(
"AprioriLatLonSource")) {
179 QString source = pointObject[
"AprioriLatLonSource"][0];
181 if (source ==
"None") {
182 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::None);
184 else if (source ==
"User") {
185 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::User);
187 else if (source ==
"AverageOfMeasures") {
189 ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures);
191 else if (source ==
"Reference") {
193 ControlNetFileProtoV0001_PBControlPoint::Reference);
195 else if (source ==
"Basemap") {
196 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Basemap);
198 else if (source ==
"BundleSolution") {
200 ControlNetFileProtoV0001_PBControlPoint::BundleSolution);
203 QString msg =
"Invalid AprioriLatLonSource [" + source +
"]";
208 if (pointObject.
hasKeyword(
"AprioriRadiusSource")) {
209 QString source = pointObject[
"AprioriRadiusSource"][0];
211 if (source ==
"None") {
212 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::None);
214 else if (source ==
"User") {
215 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::User);
217 else if (source ==
"AverageOfMeasures") {
219 ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures);
221 else if (source ==
"Ellipsoid") {
222 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::Ellipsoid);
224 else if (source ==
"DEM") {
225 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::DEM);
227 else if (source ==
"BundleSolution") {
229 ControlNetFileProtoV0001_PBControlPoint::BundleSolution);
232 QString msg =
"Invalid AprioriRadiusSource, [" + source +
"]";
242 if ( pointObject.
hasKeyword(
"AprioriCovarianceMatrix") ) {
243 PvlKeyword &matrix = pointObject[
"AprioriCovarianceMatrix"];
256 else if ( pointObject.
hasKeyword(
"AprioriSigmaLatitude")
257 || pointObject.
hasKeyword(
"AprioriSigmaLongitude")
258 || pointObject.
hasKeyword(
"AprioriSigmaRadius") ) {
260 double sigmaLat = 10000.0;
261 double sigmaLon = 10000.0;
262 double sigmaRad = 10000.0;
264 if ( pointObject.
hasKeyword(
"AprioriSigmaLatitude") ) {
265 if (
toDouble(pointObject[
"AprioriSigmaLatitude"][0]) > 0
266 &&
toDouble(pointObject[
"AprioriSigmaLatitude"][0]) < sigmaLat) {
267 sigmaLat =
toDouble(pointObject[
"AprioriSigmaLatitude"][0]);
272 if ( pointObject.
hasKeyword(
"AprioriSigmaLongitude") ) {
273 if (
toDouble(pointObject[
"AprioriSigmaLongitude"][0]) > 0
274 &&
toDouble(pointObject[
"AprioriSigmaLongitude"][0]) < sigmaLon) {
275 sigmaLon =
toDouble(pointObject[
"AprioriSigmaLongitude"][0]);
280 if ( pointObject.
hasKeyword(
"AprioriSigmaRadius") ) {
281 if (
toDouble(pointObject[
"AprioriSigmaRadius"][0]) > 0
282 &&
toDouble(pointObject[
"AprioriSigmaRadius"][0]) < sigmaRad) {
283 sigmaRad =
toDouble(pointObject[
"AprioriSigmaRadius"][0]);
295 m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 0) );
296 m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 1) );
297 m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 2) );
298 m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(1, 1) );
299 m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(1, 2) );
300 m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(2, 2) );
304 if ( pointObject.
hasKeyword(
"ApostCovarianceMatrix") ) {
305 PvlKeyword &matrix = pointObject[
"ApostCovarianceMatrix"];
318 else if ( pointObject.
hasKeyword(
"AdjustedSigmaLatitude")
319 || pointObject.
hasKeyword(
"AdjustedSigmaLongitude")
320 || pointObject.
hasKeyword(
"AdjustedSigmaRadius") ) {
322 double sigmaLat = 10000.0;
323 double sigmaLon = 10000.0;
324 double sigmaRad = 10000.0;
326 if ( pointObject.
hasKeyword(
"AdjustedSigmaLatitude") ) {
327 if (
toDouble(pointObject[
"AdjustedSigmaLatitude"][0]) > 0
328 &&
toDouble(pointObject[
"AdjustedSigmaLatitude"][0]) < sigmaLat) {
329 sigmaLat =
toDouble(pointObject[
"AdjustedSigmaLatitude"][0]);
333 if ( pointObject.
hasKeyword(
"AdjustedSigmaLongitude") ) {
334 if (
toDouble(pointObject[
"AdjustedSigmaLongitude"][0]) > 0
335 &&
toDouble(pointObject[
"AdjustedSigmaLongitude"][0]) < sigmaLon) {
336 sigmaLon =
toDouble(pointObject[
"AdjustedSigmaLongitude"][0]);
340 if ( pointObject.
hasKeyword(
"AdjustedSigmaRadius") ) {
341 if (
toDouble(pointObject[
"AdjustedSigmaRadius"][0]) > 0
342 &&
toDouble(pointObject[
"AdjustedSigmaRadius"][0]) < sigmaRad) {
343 sigmaRad =
toDouble(pointObject[
"AdjustedSigmaRadius"][0]);
354 m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 0) );
355 m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 1) );
356 m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 2) );
357 m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(1, 1) );
358 m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(1, 2) );
359 m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(2, 2) );
363 for (
int groupIndex = 0; groupIndex < pointObject.
groups(); groupIndex ++) {
365 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure measure;
368 copy(group,
"SerialNumber",
369 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_serialnumber);
370 copy(group,
"ChooserName",
371 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_choosername);
372 copy(group,
"DateTime",
373 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_datetime);
374 copy(group,
"Diameter",
375 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_diameter);
376 copy(group,
"EditLock",
377 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_editlock);
378 copy(group,
"Ignore",
379 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_ignore);
380 copy(group,
"JigsawRejected",
381 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_jigsawrejected);
382 copy(group,
"AprioriSample",
383 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_apriorisample);
384 copy(group,
"AprioriLine",
385 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_aprioriline);
386 copy(group,
"SampleSigma",
387 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_samplesigma);
388 copy(group,
"LineSigma",
389 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_linesigma);
398 value =
toDouble(group[
"Sample"][0]);
402 measure.set_ignore(
true);
404 measure.mutable_measurement()->set_sample(value);
416 measure.set_ignore(
true);
418 measure.mutable_measurement()->set_line(value);
425 double value =
toDouble(group[
"ErrorSample"][0]);
426 measure.mutable_measurement()->set_sampleresidual(value);
430 double value =
toDouble(group[
"ErrorLine"][0]);
431 measure.mutable_measurement()->set_lineresidual(value);
436 double value =
toDouble(group[
"SampleResidual"][0]);
437 measure.mutable_measurement()->set_sampleresidual(value);
442 double value =
toDouble(group[
"LineResidual"][0]);
443 measure.mutable_measurement()->set_lineresidual(value);
448 if (group[
"Reference"][0].toLower() ==
"true") {
456 QString type = group[
"MeasureType"][0].toLower();
457 if (type ==
"estimated"
458 || type ==
"unmeasured"
459 || type ==
"candidate") {
460 measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::Candidate);
462 else if (type ==
"manual") {
463 measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::Manual);
465 else if (type ==
"automatic"
466 || type ==
"validatedmanual"
467 || type ==
"automaticpixel") {
468 measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredPixel);
470 else if (type ==
"validatedautomatic"
471 || type ==
"automaticsubpixel") {
472 measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredSubPixel);
476 "Unknown measure type [" + type +
"]",
483 for (
int cmKeyIndex = 0; cmKeyIndex < group.
keywords(); cmKeyIndex++) {
484 if (group[cmKeyIndex][0] ==
""
485 || group[cmKeyIndex].name() ==
"ZScore"
486 || group[cmKeyIndex].name() ==
"ErrorMagnitude") {
493 ControlNetLogDataProtoV0001_Point_Measure measureLogData;
495 for (
int keyIndex = 0; keyIndex < group.
keywords(); keyIndex++) {
497 QString name = dataKeyword.
name();
501 if (name ==
"Obsolete_Eccentricity") {
504 else if (name ==
"GoodnessOfFit") {
507 else if (name ==
"MinimumPixelZScore") {
510 else if (name ==
"MaximumPixelZScore") {
513 else if (name ==
"PixelShift") {
516 else if (name ==
"WholePixelCorrelation") {
519 else if (name ==
"SubPixelCorrelation") {
522 else if (name ==
"Obsolete_AverageResidual") {
526 QString msg =
"Invalid control measure log data name [" + name +
"]";
534 QString msg =
"Invalid control measure log data value [" + dataKeyword[0] +
"]";
538 ControlNetLogDataProtoV0001_Point_Measure_DataEntry logEntry;
539 logEntry.set_datatype(dataType);
540 logEntry.set_datavalue(value);
541 *measureLogData.add_loggedmeasuredata() = logEntry;
546 *
m_logData->add_measures() = measureLogData;
550 QString msg =
"There is missing required information in the control "
551 "points or measures";
597 void (ControlNetFileProtoV0001_PBControlPoint::*setter)(
bool)) {
603 QString value = container[keyName][0];
605 value = value.toLower();
607 if (value ==
"true" || value ==
"yes") {
608 (point.data()->*setter)(
true);
630 void (ControlNetFileProtoV0001_PBControlPoint::*setter)(
double)) {
636 double value =
toDouble(container[keyName][0]);
638 (point.data()->*setter)(value);
659 void (ControlNetFileProtoV0001_PBControlPoint::*setter)(
const std::string&)) {
665 QString value = container[keyName][0];
667 (point.data()->*setter)(value.toLatin1().data());
687 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure,
688 void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(
bool)) {
694 QString value = container[keyName][0];
696 value = value.toLower();
698 if (value ==
"true" || value ==
"yes") {
699 (measure.*setter)(
true);
720 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure,
721 void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(
double)) {
729 value =
toDouble(container[keyName][0]);
734 (measure.*setter)(value);
754 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure,
755 void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)
756 (
const std::string &)) {
763 QString value = container[keyName][0];
765 (measure.*setter)(value.toLatin1().data());