9 #include "ControlPointV0002.h"
13 #include "ControlPointV0001.h"
14 #include "IException.h"
16 #include "PvlContainer.h"
28 ControlPointV0002::ControlPointV0002(
31 : m_pointData(pointData), m_logData(logData) {
42 : m_pointData(new ControlNetFileProtoV0001_PBControlPoint),
43 m_logData(new ControlNetLogDataProtoV0001_Point) {
46 copy(pointObject,
"PointId",
47 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_id);
48 copy(pointObject,
"ChooserName",
49 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_choosername);
50 copy(pointObject,
"DateTime",
51 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_datetime);
52 copy(pointObject,
"AprioriXYZSourceFile",
53 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorisurfpointsourcefile);
54 copy(pointObject,
"AprioriRadiusSourceFile",
55 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriradiussourcefile);
56 copy(pointObject,
"JigsawRejected",
57 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_jigsawrejected);
58 copy(pointObject,
"EditLock",
59 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_editlock);
60 copy(pointObject,
"Ignore",
61 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_ignore);
62 copy(pointObject,
"AprioriX",
63 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorix);
64 copy(pointObject,
"AprioriY",
65 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriy);
66 copy(pointObject,
"AprioriZ",
67 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriz);
68 copy(pointObject,
"AdjustedX",
69 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedx);
70 copy(pointObject,
"AdjustedY",
71 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedy);
72 copy(pointObject,
"AdjustedZ",
73 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedz);
74 copy(pointObject,
"LatitudeConstrained",
75 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_latitudeconstrained);
76 copy(pointObject,
"LongitudeConstrained",
77 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_longitudeconstrained);
78 copy(pointObject,
"RadiusConstrained",
79 m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_radiusconstrained);
83 if (pointObject[
"PointType"][0] ==
"Ground") {
84 m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Ground);
86 else if (pointObject[
"PointType"][0] ==
"Tie") {
87 m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Tie);
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(ControlNetFileProtoV0001_PBControlPoint::None);
100 else if (source ==
"User") {
101 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::User);
103 else if (source ==
"AverageOfMeasures") {
105 ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures);
107 else if (source ==
"Reference") {
109 ControlNetFileProtoV0001_PBControlPoint::Reference);
111 else if (source ==
"Basemap") {
112 m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Basemap);
114 else if (source ==
"BundleSolution") {
116 ControlNetFileProtoV0001_PBControlPoint::BundleSolution);
119 QString msg =
"Invalid AprioriXYZSource [" + source +
"]";
124 if (pointObject.
hasKeyword(
"AprioriRadiusSource")) {
125 QString source = pointObject[
"AprioriRadiusSource"][0];
127 if (source ==
"None") {
128 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::None);
130 else if (source ==
"User") {
131 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::User);
133 else if (source ==
"AverageOfMeasures") {
135 ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures);
137 else if (source ==
"Ellipsoid") {
138 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::Ellipsoid);
140 else if (source ==
"DEM") {
141 m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::DEM);
143 else if (source ==
"BundleSolution") {
145 ControlNetFileProtoV0001_PBControlPoint::BundleSolution);
148 QString msg =
"Invalid AprioriRadiusSource, [" + source +
"]";
154 if (pointObject.
hasKeyword(
"AprioriCovarianceMatrix")) {
155 PvlKeyword &matrix = pointObject[
"AprioriCovarianceMatrix"];
165 if (pointObject.
hasKeyword(
"AdjustedCovarianceMatrix")) {
166 PvlKeyword &matrix = pointObject[
"AdjustedCovarianceMatrix"];
177 for (
int groupIndex = 0; groupIndex < pointObject.
groups(); groupIndex ++) {
179 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure measure;
182 copy(group,
"SerialNumber",
183 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_serialnumber);
184 copy(group,
"ChooserName",
185 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_choosername);
186 copy(group,
"DateTime",
187 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_datetime);
188 copy(group,
"Diameter",
189 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_diameter);
190 copy(group,
"EditLock",
191 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_editlock);
192 copy(group,
"Ignore",
193 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_ignore);
194 copy(group,
"JigsawRejected",
195 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_jigsawrejected);
196 copy(group,
"AprioriSample",
197 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_apriorisample);
198 copy(group,
"AprioriLine",
199 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_aprioriline);
200 copy(group,
"SampleSigma",
201 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_samplesigma);
202 copy(group,
"LineSigma",
203 measure, &ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::set_linesigma);
208 double value =
toDouble(group[
"Sample"][0]);
209 measure.mutable_measurement()->set_sample(value);
213 double value =
toDouble(group[
"Line"][0]);
214 measure.mutable_measurement()->set_line(value);
218 double value =
toDouble(group[
"SampleResidual"][0]);
219 measure.mutable_measurement()->set_sampleresidual(value);
223 double value =
toDouble(group[
"LineResidual"][0]);
224 measure.mutable_measurement()->set_lineresidual(value);
228 if (group[
"Reference"][0].toLower() ==
"true") {
234 QString type = group[
"MeasureType"][0].toLower();
235 if (type ==
"candidate") {
236 measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::Candidate);
238 else if (type ==
"manual") {
239 measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::Manual);
241 else if (type ==
"registeredpixel") {
243 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredPixel);
245 else if (type ==
"registeredsubpixel") {
247 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredSubPixel);
251 "Unknown measure type [" + type +
"]",
258 for (
int cmKeyIndex = 0; cmKeyIndex < group.
keywords(); cmKeyIndex ++) {
259 if (group[cmKeyIndex][0] ==
""
260 || group[cmKeyIndex].name() ==
"ZScore"
261 || group[cmKeyIndex].name() ==
"ErrorMagnitude") {
267 ControlNetLogDataProtoV0001_Point_Measure measureLogData;
269 for (
int keyIndex = 0; keyIndex < group.
keywords(); keyIndex++) {
271 QString name = dataKeyword.
name();
275 if (name ==
"Obsolete_Eccentricity") {
278 else if (name ==
"GoodnessOfFit") {
281 else if (name ==
"MinimumPixelZScore") {
284 else if (name ==
"MaximumPixelZScore") {
287 else if (name ==
"PixelShift") {
290 else if (name ==
"WholePixelCorrelation") {
293 else if (name ==
"SubPixelCorrelation") {
296 else if (name ==
"Obsolete_AverageResidual") {
300 QString msg =
"Invalid control measure log data name [" + name +
"]";
308 QString msg =
"Invalid control measure log data value [" + dataKeyword[0] +
"]";
312 ControlNetLogDataProtoV0001_Point_Measure_DataEntry logEntry;
313 logEntry.set_datatype(dataType);
314 logEntry.set_datavalue(value);
315 *measureLogData.add_loggedmeasuredata() = logEntry;
320 *
m_logData->add_measures() = measureLogData;
324 QString msg =
"There is missing required information in the control "
325 "points or measures";
342 : m_pointData(oldPoint.pointData()), m_logData(oldPoint.logData()) {
386 void (ControlNetFileProtoV0001_PBControlPoint::*setter)(
bool)) {
392 QString value = container[keyName][0];
394 value = value.toLower();
396 if (value ==
"true" || value ==
"yes") {
397 (point.data()->*setter)(
true);
419 void (ControlNetFileProtoV0001_PBControlPoint::*setter)(
double)) {
425 double value =
toDouble(container[keyName][0]);
427 (point.data()->*setter)(value);
448 void (ControlNetFileProtoV0001_PBControlPoint::*setter)(
const std::string&)) {
454 QString value = container[keyName][0];
456 (point.data()->*setter)(value.toLatin1().data());
476 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure,
477 void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(
bool)) {
483 QString value = container[keyName][0];
485 value = value.toLower();
487 if (value ==
"true" || value ==
"yes") {
488 (measure.*setter)(
true);
509 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure,
510 void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(
double)) {
516 double value =
toDouble(container[keyName][0]);
518 (measure.*setter)(value);
538 ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure,
539 void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)
540 (
const std::string &)) {
546 QString value = container[keyName][0];
548 (measure.*setter)(value.toLatin1().data());