Isis 3.0 Programmer Reference
Back | Home
BundleControlPoint.cpp
1 #include "BundleControlPoint.h"
2 
3 #include <QDebug>
4 
5 #include "ControlMeasure.h"
6 #include "Latitude.h"
7 #include "Longitude.h"
8 #include "SpecialPixel.h"
9 
10 namespace Isis {
11 
12 
21  m_controlPoint = controlPoint;
22 
23  // setup vector of BundleMeasures for this control point
24  int numMeasures = controlPoint->GetNumMeasures();
25  for (int i = 0; i < numMeasures; i++) {
26  ControlMeasure *controlMeasure = controlPoint->GetMeasure(i);
27  if (controlMeasure->IsIgnored()) {
28  continue;
29  }
30 
31  addMeasure(controlMeasure);
32  }
33 
34  // initialize to 0.0
35  m_corrections.clear();
36  m_weights.clear();
37  m_nicVector.clear();
38 
39  // initialize to Null for consistency with other bundle classes...
40  m_aprioriSigmas.clear();
44  m_adjustedSigmas.clear();
48  }
49 
50 
58  copy(src);
59  }
60 
61 
66  }
67 
68 
75 
76  // sanity check
77  clear();
78 
80 
81  int numMeasures = src.size();
82 
83  for (int i = 0; i < numMeasures; i++)
84  append(BundleMeasureQsp( new BundleMeasure(*(src.at(i))) ));
85 
89  m_weights = src.m_weights;
91  }
92 
93 
103 
104  BundleMeasureQsp bundleMeasure = BundleMeasureQsp( new BundleMeasure(controlMeasure, this) );
105 
106  append(bundleMeasure);
107 
108  return bundleMeasure;
109  }
110 
111 
119  }
120 
121 
129  }
130 
131 
141  }
142 
143 
152  m_controlPoint->SetRejected(reject);
153  }
154 
155 
163  void BundleControlPoint::setWeights(const BundleSettingsQsp settings, double metersToRadians) {
164 
165  double d;
166 
167  double globalLatitudeAprioriSigma = settings->globalLatitudeAprioriSigma();
168  double globalLongitudeAprioriSigma = settings->globalLongitudeAprioriSigma();
169  double globalRadiusAprioriSigma = settings->globalRadiusAprioriSigma();
170 
172  m_weights[0] = 1.0e+50;
173  m_weights[1] = 1.0e+50;
174  m_weights[2] = 1.0e+50;
175  // m_aprioriSigmas = Isis::Null by default
176  }
178  if (!IsSpecial(globalLatitudeAprioriSigma)) {
179  m_aprioriSigmas[0] = globalLatitudeAprioriSigma;
180  d = globalLatitudeAprioriSigma*metersToRadians;
181  m_weights[0] = 1.0/(d*d);
182  } // else m_aprioriSigma = Isis::Null
183  // m_weights = 0.0
184  if (!IsSpecial(globalLongitudeAprioriSigma)) {
185  m_aprioriSigmas[1] = globalLongitudeAprioriSigma;
186  d = globalLongitudeAprioriSigma*metersToRadians;
187  m_weights[1] = 1.0/(d*d);
188  } // else m_aprioriSigma = Isis::Null
189  // m_weights = 0.0
190  if (!settings->solveRadius()) {
191  m_weights[2] = 1.0e+50;
192  }
193  else {
194  if (!IsSpecial(globalRadiusAprioriSigma)) {
195  m_aprioriSigmas[2] = globalRadiusAprioriSigma;
196  d = globalRadiusAprioriSigma*0.001;
197  m_weights[2] = 1.0/(d*d);
198  }
199  }
200  }
202  if ( m_controlPoint->IsLatitudeConstrained() ) {
203  m_aprioriSigmas[0] = m_controlPoint->GetAprioriSurfacePoint().GetLatSigmaDistance().meters();
204  m_weights[0] = m_controlPoint->GetAprioriSurfacePoint().GetLatWeight();
205  }
206  else if (!IsSpecial(globalLatitudeAprioriSigma)) {
207  m_aprioriSigmas[0] = globalLatitudeAprioriSigma;
208  d = globalLatitudeAprioriSigma*metersToRadians;
209  m_weights[0] = 1.0/(d*d);
210  } // else not constrained and global sigma is Null, then m_aprioriSigmas = Isis::Null
211  // m_weights = 0.0
212 
213  if ( m_controlPoint->IsLongitudeConstrained() ) {
214  m_aprioriSigmas[1] = m_controlPoint->GetAprioriSurfacePoint().GetLonSigmaDistance().meters();
215  m_weights[1] = m_controlPoint->GetAprioriSurfacePoint().GetLonWeight();
216  }
217  else if (!IsSpecial(globalLongitudeAprioriSigma)) {
218  m_aprioriSigmas[1] = globalLongitudeAprioriSigma;
219  d = globalLongitudeAprioriSigma*metersToRadians;
220  m_weights[1] = 1.0/(d*d);
221  } // else not constrained and global sigma is Null, then m_aprioriSigmas = Isis::Null
222  // m_weights = 0.0
223 
224  if (!settings->solveRadius()) {
225  m_weights[2] = 1.0e+50;
226  }
227  else {
228  if ( m_controlPoint->IsRadiusConstrained() ) {
229  m_aprioriSigmas[2] = m_controlPoint->GetAprioriSurfacePoint().GetLocalRadiusSigma().meters();
230  m_weights[2] = m_controlPoint->GetAprioriSurfacePoint().GetLocalRadiusWeight();
231  }
232  else if (!IsSpecial(globalRadiusAprioriSigma)) {
233  m_aprioriSigmas[2] = globalRadiusAprioriSigma;
234  d = globalRadiusAprioriSigma*0.001;
235  m_weights[2] = 1.0/(d*d);
236  } // else not constrained and global sigma is Null, then m_aprioriSigmas = Isis::Null
237  // m_weights = 0.0
238  }
239  }
240  }
241 
242 
250  }
251 
252 
259  return m_controlPoint;
260  }
261 
262 
269  return m_controlPoint->IsRejected();
270  }
271 
272 
279  return this->size();
280  }
281 
282 
292  }
293 
294 
303  return m_controlPoint->GetResidualRms();
304  }
305 
306 
313  return m_controlPoint->GetAdjustedSurfacePoint();
314  }
315 
316 
322  QString BundleControlPoint::id() const {
323  return m_controlPoint->GetId();
324  }
325 
326 
336  return m_controlPoint->GetType();
337  }
338 
339 
340  // ??? why bounded vector ??? can we use linear algebra vector ???
347  boost::numeric::ublas::bounded_vector< double, 3 > &BundleControlPoint::corrections() {
348  return m_corrections;
349  }
350 
351 
358  boost::numeric::ublas::bounded_vector< double, 3 > &BundleControlPoint::aprioriSigmas() {
359  return m_aprioriSigmas;
360 
361  }
362 
363 
370  boost::numeric::ublas::bounded_vector< double, 3 > &BundleControlPoint::adjustedSigmas() {
371  return m_adjustedSigmas;
372  }
373 
374 
381  boost::numeric::ublas::bounded_vector< double, 3 > &BundleControlPoint::weights() {
382  return m_weights;
383  }
384 
385 
391  boost::numeric::ublas::bounded_vector<double, 3> &BundleControlPoint::nicVector() {
392  return m_nicVector;
393  }
394 
395 
402  return m_cholmodQMatrix;
403  }
404 
405 
416  QString BundleControlPoint::formatBundleOutputSummaryString(bool errorPropagation) const {
417 
418  int numRays = numberOfMeasures(); // should this depend on the raw point, as written, or this->size()???
419  int numGoodRays = numRays - numberOfRejectedMeasures();
420  double ResidualRms = residualRms();
421  double lat = m_controlPoint->GetAdjustedSurfacePoint().GetLatitude().degrees();
422  double lon = m_controlPoint->GetAdjustedSurfacePoint().GetLongitude().degrees();
423  double rad = m_controlPoint->GetAdjustedSurfacePoint().GetLocalRadius().kilometers();
424 
425  QString pointType = ControlPoint::PointTypeToString(type()).toUpper();
426 
427  QString output = QString("%1%2%3 of %4%5%6%7%8%9%10%11\n")
428  .arg(id(), 16)
429  .arg(pointType, 15)
430  .arg(numGoodRays, 5)
431  .arg(numRays)
432  .arg(formatValue(ResidualRms, 6, 2))
433  .arg(formatValue(lat, 16, 8)) // deg
434  .arg(formatValue(lon, 16, 8)) // deg
435  .arg(formatValue(rad, 16, 8)) // km
436  .arg(formatLatitudeAdjustedSigmaString(16,8,errorPropagation)) // m
437  .arg(formatLongitudeAdjustedSigmaString(16,8,errorPropagation)) // m
438  .arg(formatRadiusAdjustedSigmaString(16,8,errorPropagation)); // m
439 
440  return output;
441  }
442 
443 
454  double RTM,
455  bool solveRadius) const {
456 
457  int numRays = numberOfMeasures();
458  int numGoodRays = numRays - numberOfRejectedMeasures();
459  double lat = m_controlPoint->GetAdjustedSurfacePoint().GetLatitude().degrees();
460  double lon = m_controlPoint->GetAdjustedSurfacePoint().GetLongitude().degrees();
461  double rad = m_controlPoint->GetAdjustedSurfacePoint().GetLocalRadius().kilometers();
462 
463  // ??? corrections is always zero ??? never set in this class ???
464  // point corrections and initial sigmas
465  double cor_lat_dd = m_corrections(0) * RAD2DEG; // lat correction, decimal degs
466  double cor_lon_dd = m_corrections(1) * RAD2DEG; // lon correction, decimal degs
467  double cor_rad_m = m_corrections(2) * 1000.0; // radius correction, meters
468 
469 
470  double cor_lat_m = m_corrections(0) * RTM; // lat correction, meters
471  double cor_lon_m = m_corrections(1) * RTM * cos(lat*DEG2RAD); // lon correction, meters
472 
473  double latInit = Isis::Null;
474  if (!IsSpecial(lat)) {
475  latInit = lat - cor_lat_dd;
476  }
477 
478 
479  double lonInit = Isis::Null;
480  if (!IsSpecial(lon)) {
481  lonInit = lon - cor_lon_dd;
482  }
483 
484  double radInit = Isis::Null;
485  if (!IsSpecial(rad)) {
486  radInit = rad - m_corrections(2); // km
487  }
488 
489  QString pointType = ControlPoint::PointTypeToString(type()).toUpper();
490 
491  QString output;
492 
493  output = QString(" Label: %1\nStatus: %2\n Rays: %3 of %4\n")
494  .arg(id())
495  .arg(pointType)
496  .arg(numGoodRays)
497  .arg(numRays);
498 
499  QString labels = "\n Point Initial Total Total "
500  " Final Initial Final\n"
501  "Coordinate Value Correction Correction "
502  " Value Accuracy Accuracy\n"
503  " (dd/dd/km) (dd/dd/km) (Meters) "
504  " (dd/dd/km) (Meters) (Meters)\n";
505  output += labels;
506 
507  output += QString(" LATITUDE%1%2%3%4%5%6\n")
508  .arg(formatValue(latInit, 17, 8)) // deg
509  .arg(formatValue(cor_lat_dd, 21, 8)) // deg
510  .arg(formatValue(cor_lat_m, 20, 8)) // m
511  .arg(formatValue(lat, 20, 8)) // deg
512  .arg(formatLatitudeAprioriSigmaString(18,8)) // m
513  .arg(formatLatitudeAdjustedSigmaString(18,8,errorPropagation)); // m
514 
515  output += QString(" LONGITUDE%1%2%3%4%5%6\n")
516  .arg(formatValue(lonInit, 17, 8)) // deg
517  .arg(formatValue(cor_lon_dd, 21, 8)) // deg
518  .arg(formatValue(cor_lon_m, 20, 8)) // m
519  .arg(formatValue(lon, 20, 8)) // deg
520  .arg(formatLongitudeAprioriSigmaString(18,8)) // m
521  .arg(formatLongitudeAdjustedSigmaString(18,8,errorPropagation)); // m
522 
523  output += QString(" RADIUS%1%2%3%4%5%6\n\n")
524  .arg(formatValue(radInit, 17, 8)) // km
525  .arg(formatValue(m_corrections(2), 21, 8)) // km
526  .arg(formatValue(cor_rad_m, 20, 8)) // m
527  .arg(formatValue(rad, 20, 8)) // km
528  .arg(formatRadiusAprioriSigmaString(18,8,solveRadius)) // m
529  .arg(formatRadiusAdjustedSigmaString(18,8,errorPropagation)); // m
530 
531  return output;
532  }
533 
534 
545  QString BundleControlPoint::formatValue(double value, int fieldWidth, int precision) const {
546  QString output;
547  IsSpecial(value) ?
548  output = QString("%1").arg("Null", fieldWidth) :
549  output = QString("%1").arg(value, fieldWidth, 'f', precision);
550  return output;
551  }
552 
553 
565  QString BundleControlPoint::formatAprioriSigmaString(int version, int fieldWidth,
566  int precision, bool solveRadius) const {
567  QString aprioriSigmaStr;
568  QString pointType = ControlPoint::PointTypeToString(type()).toUpper();
569  if (pointType == "CONSTRAINED"||!solveRadius) {
570  pointType = "N/A";
571  }
572  double sigma = m_aprioriSigmas[version];
573  if (IsSpecial(sigma)) { // if globalAprioriSigma <= 0 (including Isis::NUll), then m_aprioriSigmas = Null
574  aprioriSigmaStr = QString("%1").arg(pointType, fieldWidth);
575  }
576  else {
577  aprioriSigmaStr = QString("%1").arg(sigma, fieldWidth, 'f', precision);
578  }
579  return aprioriSigmaStr;
580  }
581 
582 
594  int precision) const {
595  return formatAprioriSigmaString(0, fieldWidth, precision, true);
596  }
597 
598 
610  int precision) const {
611  return formatAprioriSigmaString(1, fieldWidth, precision, true);
612  }
613 
614 
626  int precision,
627  bool solveRadius) const {
628  return formatAprioriSigmaString(2, fieldWidth, precision, solveRadius);
629  }
630 
631 
645  QString BundleControlPoint::formatAdjustedSigmaString(int type, int fieldWidth, int precision,
646  bool errorPropagation) const {
647  QString adjustedSigmaStr;
648 
649  if (!errorPropagation) {
650  adjustedSigmaStr = QString("%1").arg("N/A",fieldWidth);
651  }
652  else {
653  double sigma = Isis::Null;
654  if (type == 0) {
655  sigma = m_controlPoint->GetAdjustedSurfacePoint().GetLatSigmaDistance().meters();
656  }
657  if (type == 1) {
658  sigma = m_controlPoint->GetAdjustedSurfacePoint().GetLonSigmaDistance().meters();
659  }
660  if (type == 2) {
661  sigma = m_controlPoint->GetAdjustedSurfacePoint().GetLocalRadiusSigma().meters();
662  }
663  if (IsSpecial(sigma)) {
664  adjustedSigmaStr = QString("%1").arg("N/A",fieldWidth);
665  }
666  else {
667  adjustedSigmaStr = QString("%1").arg(sigma, fieldWidth, 'f', precision);
668  }
669  }
670 
671  return adjustedSigmaStr;
672  }
673 
674 
686  QString BundleControlPoint::formatLatitudeAdjustedSigmaString(int fieldWidth, int precision,
687  bool errorPropagation) const {
688  return formatAdjustedSigmaString(0, fieldWidth, precision, errorPropagation);
689  }
690 
691 
703  QString BundleControlPoint::formatLongitudeAdjustedSigmaString(int fieldWidth, int precision,
704  bool errorPropagation) const {
705  return formatAdjustedSigmaString(1, fieldWidth, precision, errorPropagation);
706  }
707 
708 
720  QString BundleControlPoint::formatRadiusAdjustedSigmaString(int fieldWidth, int precision,
721  bool errorPropagation) const {
722  return formatAdjustedSigmaString(2, fieldWidth, precision, errorPropagation);
723  }
724 }
This class defines a body-fixed surface point.
Definition: SurfacePoint.h:86
PointType GetType() const
void ZeroNumberOfRejectedMeasures()
Initialize the number of rejected measures to 0.
int numberOfRejectedMeasures() const
Accesses the number of rejected measures for this BundleControlPoint.
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:109
QSharedPointer< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.
void SetNumberOfRejectedMeasures(int numRejected)
Set (update) the number of rejected measures for the control point.
boost::numeric::ublas::bounded_vector< double, 3 > m_adjustedSigmas
adjusted sigmas for point parameters
QString formatAprioriSigmaString(int type, int fieldWidth, int precision, bool solveRadius=false) const
Formats the apriori sigma value indicated by the given type code.
QString formatLatitudeAprioriSigmaString(int fieldWidth, int precision) const
Formats the apriori latitude sigma value.
A Constrained point is a Control Point whose lat/lon/radius is somewhat established and should not be...
Definition: ControlPoint.h:361
A Fixed point is a Control Point whose lat/lon is well established and should not be changed...
Definition: ControlPoint.h:356
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:245
Distance GetLocalRadius() const
Return the radius of the surface point.
BundleControlPoint(ControlPoint *point)
Constructs a BundleControlPoint object from a ControlPoint.
void setRejected(bool reject)
Sets this BundleControlPoint to rejected or not rejected.
BundleMeasureQsp addMeasure(ControlMeasure *controlMeasure)
Creates a BundleMeasure from the given ControlMeasure and appends it to this BundleControlPoint&#39;s mea...
QString formatLatitudeAdjustedSigmaString(int fieldWidth, int precision, bool errorPropagation) const
Formats the adjusted latitude sigma value.
double GetLatWeight() const
Return latitude weight for bundle adjustment Units are 1/(radians)^2.
void copy(const BundleControlPoint &src)
Copies given BundleControlPoint to this BundleControlPoint.
PointType
These are the valid &#39;types&#39; of point.
Definition: ControlPoint.h:349
const double DEG2RAD(0.017453292519943295769237)
Multiplier for converting from degrees to radians.
void computeResiduals()
Computes the residuals for this BundleControlPoint.
boost::numeric::ublas::bounded_vector< double, 3 > & weights()
Accesses the 3 dimensional ordered vector of weight values associated with latitude, longitude, and radius.
int numberOfMeasures() const
Accesses number of measures associated with this BundleControlPoint.
boost::numeric::ublas::bounded_vector< double, 3 > & aprioriSigmas()
Accesses the 3 dimenstional ordered vector of apriori sigmas (apriori latitude, apriori longitude...
A container class for a ControlMeasure.
Definition: BundleMeasure.h:69
ControlPoint * rawControlPoint() const
Accessor for the raw ControlPoint object used for this BundleControlPoint.
QString formatBundleOutputSummaryString(bool errorPropagation) const
Formats an output summary string for this BundleControlPoint.
boost::numeric::ublas::bounded_vector< double, 3 > & adjustedSigmas()
Accesses the 3 dimenstional ordered vector of adjusted sigmas (adjusted latitude, adjusted longitude...
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
Status SetAdjustedSurfacePoint(SurfacePoint newSurfacePoint)
Set or update the surface point relating to this control point.
boost::numeric::ublas::bounded_vector< double, 3 > & corrections()
Accesses the 3 dimensional ordered vector of correction values associated with latitude, longitude, and radius.
A Free point is a Control Point that identifies common measurements between two or more cubes...
Definition: ControlPoint.h:369
Distance GetLonSigmaDistance() const
Return the longiitude sigma in meters.
boost::numeric::ublas::bounded_vector< double, 3 > & nicVector()
Accesses the 3 dimensional ordered NIC vector.
boost::numeric::ublas::bounded_vector< double, 3 > m_nicVector
array of NICs (see Brown, 1976)
ControlPoint * m_controlPoint
&lt; pointer to the control point object this represents
SurfacePoint adjustedSurfacePoint() const
Accesses the adjusted SurfacePoint associated with this BundleControlPoint.
double meters() const
Get the distance in meters.
Definition: Distance.cpp:97
boost::numeric::ublas::bounded_vector< double, 3 > m_aprioriSigmas
apriori sigmas for point parameters
QString GetId() const
Return the Id of the control point.
double GetLonWeight() const
Return longitude weight for bundle adjustment Units are 1/(radians)^2.
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
void zeroNumberOfRejectedMeasures()
Resets the number of rejected measures for this BundleControlPoint to zero.
void setAdjustedSurfacePoint(SurfacePoint surfacePoint)
Sets the adjusted surface point for this BundleControlPoint.
bool isRejected() const
Method used to determine whether this control point is rejected.
boost::numeric::ublas::bounded_vector< double, 3 > m_weights
weights for point parameters
ControlPoint::PointType type() const
Accesses BundleControlPoint&#39;s type.
This class holds information about a control point that BundleAdjust needs to run corretly...
~BundleControlPoint()
Destructor for BundleControlPoint.
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:199
A single control point.
Definition: ControlPoint.h:339
double residualRms() const
Gets the root-mean-square (rms) of the BundleControlPoint&#39;s residuals.
boost::numeric::ublas::bounded_vector< double, 3 > m_corrections
corrections to point parameters
QString formatValue(double value, int fieldWidth, int precision) const
Formats the given double precision value using the specified field width and precision.
Status SetRejected(bool rejected)
Set the jigsawRejected state.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double GetResidualRms() const
Get rms of residuals.
QString formatRadiusAprioriSigmaString(int fieldWidth, int precision, bool solveRadius=false) const
Formats the apriori radius sigma value.
QString formatLongitudeAprioriSigmaString(int fieldWidth, int precision) const
Formats the apriori longitude sigma value.
void setWeights(const BundleSettingsQsp settings, double metersToRadians)
Sets the weights using the given BundleSettings QSharedPointer and a conversion value for meters to r...
int GetNumberOfRejectedMeasures() const
Get the number of rejected measures on the control point.
QSharedPointer< BundleMeasure > BundleMeasureQsp
Definition for BundleMeasureQsp, a shared pointer to a BundleMeasure.
Distance GetLatSigmaDistance() const
Return the latitude sigma in meters.
QString formatRadiusAdjustedSigmaString(int fieldWidth, int precision, bool errorPropagation) const
Formats the adjusted radius sigma value.
SparseBlockRowMatrix m_cholmodQMatrix
The CholMod matrix associated with this point.
a control measurement
double kilometers() const
Get the distance in kilometers.
Definition: Distance.cpp:118
QString formatLongitudeAdjustedSigmaString(int fieldWidth, int precision, bool errorPropagation) const
Formats the adjusted longitude sigma value.
QString id() const
Accesses the Point ID associated with this BundleControlPoint.
QString formatAdjustedSigmaString(int type, int fieldWidth, int precision, bool errorPropagation) const
Formats the adjusted sigma value indicated by the given type code.
QString formatBundleOutputDetailString(bool errorPropagation, double RTM, bool solveRadius=false) const
Formats a detailed output string table for this BundleControlPoint.
void setNumberOfRejectedMeasures(int numRejected)
Sets the number of rejected measures for this BundleControlPoint.
const ControlMeasure * GetMeasure(QString serialNumber) const
Get a control measure based on its cube&#39;s serial number.
SparseBlockRowMatrix & cholmodQMatrix()
Accesses the CholMod matrix associated with this BundleControlPoint.
const double RAD2DEG(57.29577951308232087679815481)
Multiplier for converting from radians to degrees.
double GetLocalRadiusWeight() const
Return radius weight for bundle adjustment Units are 1/(meters)^2.
SparseBlockRowMatrix.
static QString PointTypeToString(PointType type)
Obtain a string representation of a given PointType.
Status ComputeResiduals()
This method computes the BundleAdjust residuals for a point.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:15:00