9#include "BundleSettings.h"
17#include <QXmlStreamWriter>
18#include <QXmlInputSource>
20#include "BundleObservationSolveSettings.h"
21#include "IException.h"
24#include "PvlKeyword.h"
26#include "SpecialPixel.h"
41 m_observationSolveSettings.append(defaultSolveSettings);
100 : m_validateNetwork(other.m_validateNetwork),
101 m_cubeList(other.m_cubeList),
102 m_solveObservationMode(other.m_solveObservationMode),
103 m_solveRadius(other.m_solveRadius),
104 m_updateCubeLabel(other.m_updateCubeLabel),
105 m_errorPropagation(other.m_errorPropagation),
106 m_createInverseMatrix(other.m_createInverseMatrix),
107 m_outlierRejection(other.m_outlierRejection),
108 m_outlierRejectionMultiplier(other.m_outlierRejectionMultiplier),
109 m_globalPointCoord1AprioriSigma(other.m_globalPointCoord1AprioriSigma),
110 m_globalPointCoord2AprioriSigma(other.m_globalPointCoord2AprioriSigma),
111 m_globalPointCoord3AprioriSigma(other.m_globalPointCoord3AprioriSigma),
112 m_observationSolveSettings(other.m_observationSolveSettings),
113 m_convergenceCriteria(other.m_convergenceCriteria),
114 m_convergenceCriteriaThreshold(other.m_convergenceCriteriaThreshold),
115 m_convergenceCriteriaMaximumIterations(other.m_convergenceCriteriaMaximumIterations),
116 m_maximumLikelihood(other.m_maximumLikelihood),
117 m_solveTargetBody(other.m_solveTargetBody),
118 m_bundleTargetBody(other.m_bundleTargetBody),
119 m_cpCoordTypeReports(other.m_cpCoordTypeReports),
120 m_cpCoordTypeBundle(other.m_cpCoordTypeBundle),
121 m_outputFilePrefix(other.m_outputFilePrefix){
145 if (&other !=
this) {
147 m_cubeList = other.m_cubeList;
158 m_observationSolveSettings = other.m_observationSolveSettings;
245 bool updateCubeLabel,
246 bool errorPropagation,
250 double globalPointCoord1AprioriSigma,
251 double globalPointCoord2AprioriSigma,
252 double globalPointCoord3AprioriSigma) {
323 QList<BundleObservationSolveSettings> obsSolveSettingsList) {
324 m_observationSolveSettings = obsSolveSettingsList;
493 return m_observationSolveSettings.size();
514 if (m_observationSolveSettings[i].observationNumbers().contains(observationNumber)) {
515 return m_observationSolveSettings[i];
518 return defaultSolveSettings;
537 return m_observationSolveSettings[n];
539 QString msg =
"Unable to find BundleObservationSolveSettings with index = ["
552 return m_observationSolveSettings;
577 if (criteria.compare(
"SIGMA0", Qt::CaseInsensitive) == 0) {
580 else if (criteria.compare(
"PARAMETERCORRECTIONS", Qt::CaseInsensitive) == 0) {
584 "Unknown bundle convergence criteria [" + criteria +
"].",
602 if (criteria ==
Sigma0)
return "Sigma0";
605 "Unknown convergence criteria enum [" +
toString(criteria) +
"].",
622 int maximumIterations) {
703 double maxModelCQuantile) {
706 QString msg =
"For bundle adjustments with multiple maximum likelihood estimators, the first "
707 "model must be of type HUBER or HUBER_MODIFIED.";
723 QList< QPair< MaximumLikelihoodWFunctions::Model, double > >
1026 stream.writeStartElement(
"bundleSettings");
1028 stream.writeStartElement(
"globalSettings");
1032 stream.writeStartElement(
"solveOptions");
1040 stream.writeEndElement();
1042 stream.writeStartElement(
"aprioriSigmas");
1044 stream.writeAttribute(
"pointCoord1",
"N/A");
1050 stream.writeAttribute(
"pointCoord2",
"N/A");
1056 stream.writeAttribute(
"pointCoord3",
"N/A");
1061 stream.writeEndElement();
1063 stream.writeStartElement(
"outlierRejectionOptions");
1069 stream.writeAttribute(
"multiplier",
"N/A");
1071 stream.writeEndElement();
1073 stream.writeStartElement(
"convergenceCriteriaOptions");
1074 stream.writeAttribute(
"convergenceCriteria",
1076 stream.writeAttribute(
"threshold",
1078 stream.writeAttribute(
"maximumIterations",
1080 stream.writeEndElement();
1082 stream.writeStartElement(
"maximumLikelihoodEstimation");
1084 stream.writeStartElement(
"model");
1085 stream.writeAttribute(
"type",
1088 stream.writeEndElement();
1090 stream.writeEndElement();
1092 stream.writeStartElement(
"outputFileOptions");
1094 stream.writeEndElement();
1096 stream.writeEndElement();
1098 if (!m_observationSolveSettings.isEmpty()) {
1099 stream.writeStartElement(
"observationSolveSettingsList");
1100 for (
int i = 0; i < m_observationSolveSettings.size(); i++) {
1101 m_observationSolveSettings[i].save(stream, project);
1103 stream.writeEndElement();
1108 stream.writeEndElement();
1111 void BundleSettings::readBundleSettings(QXmlStreamReader *xmlReader) {
1113 Q_ASSERT(xmlReader->name() ==
"bundleSettings");
1114 while (xmlReader->readNextStartElement()) {
1115 if (xmlReader->qualifiedName() ==
"globalSettings") {
1116 while (xmlReader->readNextStartElement()) {
1117 if (xmlReader->qualifiedName() ==
"validateNetwork") {
1123 else if (xmlReader->qualifiedName() ==
"solveOptions") {
1128 QStringRef
solveRadius = xmlReader->attributes().value(
"solveRadius");
1150 QStringRef
updateCubeLabel = xmlReader->attributes().value(
"updateCubeLabel");
1154 QStringRef
errorPropagation = xmlReader->attributes().value(
"errorPropagation");
1162 xmlReader->skipCurrentElement();
1164 else if (xmlReader->qualifiedName() ==
"aprioriSigmas") {
1192 xmlReader->skipCurrentElement();
1194 else if (xmlReader->qualifiedName() ==
"outlierRejectionOptions") {
1208 xmlReader->skipCurrentElement();
1210 else if (xmlReader->qualifiedName() ==
"convergenceCriteriaOptions") {
1215 QStringRef threshold = xmlReader->attributes().value(
"threshold");
1216 if (!threshold.isEmpty()) {
1219 QStringRef maximumIterations = xmlReader->attributes().value(
"maximumIterations");
1220 if (!maximumIterations.isEmpty()) {
1223 xmlReader->skipCurrentElement();
1225 else if (xmlReader->qualifiedName() ==
"maximumLikelihoodEstimation") {
1226 while (xmlReader->readNextStartElement()) {
1227 if (xmlReader->qualifiedName() ==
"model") {
1228 QStringRef type = xmlReader->attributes().value(
"type");
1229 QStringRef quantile = xmlReader->attributes().value(
"quantile");
1230 if (!type.isEmpty() && !quantile.isEmpty()) {
1231 m_maximumLikelihood.append(qMakePair(MaximumLikelihoodWFunctions::stringToModel(type.toString()), quantile.toDouble()));
1233 xmlReader->skipCurrentElement();
1236 xmlReader->skipCurrentElement();
1240 else if (xmlReader->qualifiedName() ==
"outputFileOptions") {
1241 QStringRef fileNamePrefix = xmlReader->attributes().value(
"fileNamePrefix");
1242 if (!fileNamePrefix.isEmpty()) {
1245 xmlReader->skipCurrentElement();
1248 xmlReader->skipCurrentElement();
1252 else if (xmlReader->qualifiedName() ==
"observationSolveSettingsList") {
1253 m_observationSolveSettings.clear();
1254 while (xmlReader->readNextStartElement()) {
1255 if (xmlReader->qualifiedName() ==
"bundleObservationSolveSettings") {
1257 m_observationSolveSettings.append(*settings);
1260 xmlReader->skipCurrentElement();
1265 xmlReader->skipCurrentElement();
This class is used to modify and manage solve settings for 1 to many BundleObservations.
Container class for BundleAdjustment settings.
bool m_createInverseMatrix
Indicates whether to create the inverse matrix file.
double globalPointCoord2AprioriSigma() const
Retrieves the global a priori sigma for 2nd coordinate of points for this bundle.
bool validateNetwork() const
This method is used to determine whether to validate the network before the bundle adjustment.
int convergenceCriteriaMaximumIterations() const
Retrieves the maximum number of iterations allowed to solve the bundle adjustment.
bool m_solveRadius
Indicates whether to solve for point radii.
BundleSettings & operator=(const BundleSettings &other)
Assignment operator to allow proper copying of the 'other' BundleSettings object to this one.
double globalPointCoord3AprioriSigma() const
Retrieves the global a priori sigma 3rd coordinate of points for this bundle.
void addMaximumLikelihoodEstimatorModel(MaximumLikelihoodWFunctions::Model model, double cQuantile)
Add a maximum likelihood estimator (MLE) model to the bundle adjustment.
BundleSettings()
Constructs a BundleSettings object.
QString m_outputFilePrefix
The prefix for all output files.
bool m_solveObservationMode
Indicates whether to solve for observation mode.
SurfacePoint::CoordinateType controlPointCoordTypeBundle() const
Indicates the control point coordinate type for the actual bundle adjust.
bool errorPropagation() const
This method is used to determine whether this bundle adjustment will perform error propagation.
void setConvergenceCriteria(ConvergenceCriteria criteria, double threshold, int maximumIterations)
Set the convergence criteria options for the bundle adjustment.
bool solvePMVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
double m_globalPointCoord2AprioriSigma
The global a priori sigma for longitude or Y.
void save(QXmlStreamWriter &stream, const Project *project) const
This method is used to write a BundleSettings object in an XML format.
ConvergenceCriteria
This enum defines the options for the bundle adjustment's convergence.
@ Sigma0
The value of sigma0 will be used to determine that the bundle adjustment has converged.
@ ParameterCorrections
All parameter corrections will be used to determine that the bundle adjustment has converged.
BundleTargetBodyQsp bundleTargetBody() const
Retrieves a pointer to target body information for the bundle adjustment.
void setCreateInverseMatrix(bool createMatrix)
Turn the creation of the inverse correlation matrix file on or off.
bool solveMeanRadius() const
This method is used to determine whether the bundle adjustment will solve for target body mean radius...
bool solveRadius() const
This method is used to determine whether this bundle adjustment will solve for radius.
void init()
Set Default vales for a BundleSettings object.
bool solveTriaxialRadii() const
This method is used to determine whether the bundle adjustment will solve for target body triaxial ra...
BundleTargetBodyQsp m_bundleTargetBody
A pointer to the target body settings and information.
ConvergenceCriteria m_convergenceCriteria
Enumeration used to indicate what criteria to use to determine bundle adjustment convergence.
double m_globalPointCoord3AprioriSigma
The global a priori sigma for radius or Z.
bool solvePMAcceleration() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
QList< BundleObservationSolveSettings > observationSolveSettings() const
Retrieves solve settings for the observation corresponding to the given index.
void setBundleTargetBody(BundleTargetBodyQsp bundleTargetBody)
Sets the target body for the bundle adjustment.
int numberTargetBodyParameters() const
This method is used to determine whether the bundle adjustment will solve for target body pole positi...
QString outputFilePrefix() const
Retrieve the output file prefix.
double globalPointCoord1AprioriSigma() const
Retrieves global a priori sigma for 1st coordinate of points for this bundle.
bool updateCubeLabel() const
This method is used to determine whether this bundle adjustment will update the cube labels.
double m_convergenceCriteriaThreshold
Tolerance value corresponding to the selected convergence criteria.
double m_outlierRejectionMultiplier
The multiplier value for outlier rejection.
bool outlierRejection() const
This method is used to determine whether outlier rejection will be performed on this bundle adjustmen...
void setOutputFilePrefix(QString outputFilePrefix)
Set the output file prefix for the bundle adjustment.
bool solvePoleRA() const
This method is used to determine whether the bundle adjustment will solve for target body pole right ...
bool solvePoleDecVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body pole declin...
static QString convergenceCriteriaToString(ConvergenceCriteria criteria)
Converts the given BundleSettings::ConvergenceCriteria enumeration to a string.
void setValidateNetwork(bool validate)
Sets the internal flag to indicate whether to validate the network before the bundle adjustment.
~BundleSettings()
Destroys the BundleSettings object.
static ConvergenceCriteria stringToConvergenceCriteria(QString criteria)
Converts the given string value to a BundleSettings::ConvergenceCriteria enumeration.
SurfacePoint::CoordinateType m_cpCoordTypeReports
Indicates the coordinate type for outputting control points in reports.
bool m_outlierRejection
Indicates whether to perform automatic outlier detection/rejection.
bool m_errorPropagation
Indicates whether to perform error propagation.
bool createInverseMatrix() const
Indicates if the settings will allow the inverse correlation matrix to be created.
bool solvePoleRAVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body pole right ...
QString cubeList() const
BundleSettings::cubeList.
QList< QPair< MaximumLikelihoodWFunctions::Model, double > > m_maximumLikelihood
Model and C-Quantile for each of the three maximum likelihood estimations.
void setOutlierRejection(bool outlierRejection, double multiplier=1.0)
Set the outlier rejection options for the bundle adjustment.
ConvergenceCriteria convergenceCriteria() const
Retrieves the convergence criteria to be used to solve the bundle adjustment.
QList< QPair< MaximumLikelihoodWFunctions::Model, double > > maximumLikelihoodEstimatorModels() const
Retrieves the list of maximum likelihood estimator (MLE) models with their corresponding C-Quantiles.
bool solvePoleDec() const
This method is used to determine whether the bundle adjustment will solve for target body pole declin...
bool m_validateNetwork
Indicates whether the network should be validated.
double m_globalPointCoord1AprioriSigma
The global a priori sigma for latitude or X.
int numberSolveSettings() const
Retrieves the number of observation solve settings.
void setSolveOptions(bool solveObservationMode=false, bool updateCubeLabel=false, bool errorPropagation=false, bool solveRadius=false, SurfacePoint::CoordinateType coordTypeBundle=SurfacePoint::Latitudinal, SurfacePoint::CoordinateType coordTypeReports=SurfacePoint::Latitudinal, double globalPointCoord1AprioriSigma=Isis::Null, double globalPointCoord2AprioriSigma=Isis::Null, double globalPointCoord3AprioriSigma=Isis::Null)
Set the solve options for the bundle adjustment.
SurfacePoint::CoordinateType controlPointCoordTypeReports() const
Indicates the control point coordinate type for reports.
bool solvePM() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
void setCubeList(QString fileName)
BundleSettings::setCubeList.
bool m_updateCubeLabel
Indicates whether to update cubes.
double convergenceCriteriaThreshold() const
Retrieves the convergence threshold to be used to solve the bundle adjustment.
void setObservationSolveOptions(QList< BundleObservationSolveSettings > obsSolveSettingsList)
Add the list of solve options for each observation.
bool solveObservationMode() const
This method is used to determine whether this bundle adjustment will solve for observation mode.
int m_convergenceCriteriaMaximumIterations
Maximum number of iterations before quitting the bundle adjustment if it has not yet converged to the...
bool solveTargetBody() const
This method is used to determine whether the bundle adjustment will solve for target body.
double outlierRejectionMultiplier() const
Retrieves the outlier rejection multiplier for the bundle adjustment.
bool m_solveTargetBody
Indicates whether to solve for target body.
SurfacePoint::CoordinateType m_cpCoordTypeBundle
Indicates the coordinate type used for control points in the bundle adjustment.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ Programmer
This error is for when a programmer made an API call that was illegal.
static QString modelToString(Model model)
Static method to return a string represtentation for a given MaximumLikelihoodWFunctions::Model enum.
Model
The supported maximum likelihood estimation models.
@ HuberModified
A modification to Huber's method propsed by William J.J.
The main project for ipce.
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
@ Latitudinal
Planetocentric latitudinal (lat/lon/rad) coordinates.
@ Rectangular
Body-fixed rectangular x/y/z coordinates.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
const double Null
Value for an Isis Null pixel.
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
bool IsSpecial(const double d)
Returns if the input pixel is special.
bool validate(const NaifVertex &v)
Verifies that the given NaifVector or NaifVertex is 3 dimensional.