9 #include <QXmlStreamWriter> 10 #include <QXmlInputSource> 19 #include "XmlStackedHandlerReader.h" 34 m_observationSolveSettings.append(defaultSolveSettings);
105 xmlReader->setErrorHandler(
new XmlHandler(
this, project));
117 : m_validateNetwork(other.m_validateNetwork),
118 m_cubeList(other.m_cubeList),
119 m_solveObservationMode(other.m_solveObservationMode),
120 m_solveRadius(other.m_solveRadius),
121 m_updateCubeLabel(other.m_updateCubeLabel),
122 m_errorPropagation(other.m_errorPropagation),
123 m_createInverseMatrix(other.m_createInverseMatrix),
124 m_outlierRejection(other.m_outlierRejection),
125 m_outlierRejectionMultiplier(other.m_outlierRejectionMultiplier),
126 m_globalPointCoord1AprioriSigma(other.m_globalPointCoord1AprioriSigma),
127 m_globalPointCoord2AprioriSigma(other.m_globalPointCoord2AprioriSigma),
128 m_globalPointCoord3AprioriSigma(other.m_globalPointCoord3AprioriSigma),
129 m_observationSolveSettings(other.m_observationSolveSettings),
130 m_convergenceCriteria(other.m_convergenceCriteria),
131 m_convergenceCriteriaThreshold(other.m_convergenceCriteriaThreshold),
132 m_convergenceCriteriaMaximumIterations(other.m_convergenceCriteriaMaximumIterations),
133 m_maximumLikelihood(other.m_maximumLikelihood),
134 m_solveTargetBody(other.m_solveTargetBody),
135 m_bundleTargetBody(other.m_bundleTargetBody),
136 m_cpCoordTypeReports(other.m_cpCoordTypeReports),
137 m_cpCoordTypeBundle(other.m_cpCoordTypeBundle),
138 m_outputFilePrefix(other.m_outputFilePrefix){
162 if (&other !=
this) {
164 m_cubeList = other.m_cubeList;
175 m_observationSolveSettings = other.m_observationSolveSettings;
262 bool updateCubeLabel,
263 bool errorPropagation,
267 double globalPointCoord1AprioriSigma,
268 double globalPointCoord2AprioriSigma,
269 double globalPointCoord3AprioriSigma) {
341 m_observationSolveSettings = obsSolveSettingsList;
510 return m_observationSolveSettings.size();
531 if (m_observationSolveSettings[i].observationNumbers().contains(observationNumber)) {
532 return m_observationSolveSettings[i];
535 return defaultSolveSettings;
557 return m_observationSolveSettings[n];
559 QString msg =
"Unable to find BundleObservationSolveSettings with index = [" 572 return m_observationSolveSettings;
597 if (criteria.compare(
"SIGMA0", Qt::CaseInsensitive) == 0) {
600 else if (criteria.compare(
"PARAMETERCORRECTIONS", Qt::CaseInsensitive) == 0) {
604 "Unknown bundle convergence criteria [" + criteria +
"].",
622 if (criteria ==
Sigma0)
return "Sigma0";
625 "Unknown convergence criteria enum [" +
toString(criteria) +
"].",
642 int maximumIterations) {
723 double maxModelCQuantile) {
726 QString msg =
"For bundle adjustments with multiple maximum likelihood estimators, the first " 727 "model must be of type HUBER or HUBER_MODIFIED.";
1046 stream.writeStartElement(
"bundleSettings");
1048 stream.writeStartElement(
"globalSettings");
1052 stream.writeStartElement(
"solveOptions");
1060 stream.writeEndElement();
1062 stream.writeStartElement(
"aprioriSigmas");
1064 stream.writeAttribute(
"pointCoord1",
"N/A");
1070 stream.writeAttribute(
"pointCoord2",
"N/A");
1076 stream.writeAttribute(
"pointCoord3",
"N/A");
1081 stream.writeEndElement();
1083 stream.writeStartElement(
"outlierRejectionOptions");
1089 stream.writeAttribute(
"multiplier",
"N/A");
1091 stream.writeEndElement();
1093 stream.writeStartElement(
"convergenceCriteriaOptions");
1094 stream.writeAttribute(
"convergenceCriteria",
1096 stream.writeAttribute(
"threshold",
1098 stream.writeAttribute(
"maximumIterations",
1100 stream.writeEndElement();
1102 stream.writeStartElement(
"maximumLikelihoodEstimation");
1104 stream.writeStartElement(
"model");
1105 stream.writeAttribute(
"type",
1108 stream.writeEndElement();
1110 stream.writeEndElement();
1112 stream.writeStartElement(
"outputFileOptions");
1114 stream.writeEndElement();
1116 stream.writeEndElement();
1118 if (!m_observationSolveSettings.isEmpty()) {
1119 stream.writeStartElement(
"observationSolveSettingsList");
1120 for (
int i = 0; i < m_observationSolveSettings.size(); i++) {
1121 m_observationSolveSettings[i].save(stream, project);
1123 stream.writeEndElement();
1128 stream.writeEndElement();
1141 m_xmlHandlerBundleSettings = bundleSettings;
1142 m_xmlHandlerProject = project;
1143 m_xmlHandlerCharacters =
"";
1144 m_xmlHandlerObservationSettings.clear();
1171 const QString &localName,
1172 const QString &qName,
1173 const QXmlAttributes &attributes) {
1174 m_xmlHandlerCharacters =
"";
1176 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, attributes)) {
1178 if (localName ==
"solveOptions") {
1180 QString solveObservationModeStr = attributes.value(
"solveObservationMode");
1181 if (!solveObservationModeStr.isEmpty()) {
1182 m_xmlHandlerBundleSettings->m_solveObservationMode =
toBool(solveObservationModeStr);
1185 QString solveRadiusStr = attributes.value(
"solveRadius");
1186 if (!solveRadiusStr.isEmpty()) {
1187 m_xmlHandlerBundleSettings->m_solveRadius =
toBool(solveRadiusStr);
1190 QString coordTypeReportsStr = attributes.value(
"controlPointCoordinateTypeReports");
1191 if (!coordTypeReportsStr.isEmpty()) {
1192 m_xmlHandlerBundleSettings->m_cpCoordTypeReports =
1196 QString coordTypeBundleStr = attributes.value(
"controlPointCoordinateTypeBundle");
1197 if (!coordTypeBundleStr.isEmpty()) {
1198 m_xmlHandlerBundleSettings->m_cpCoordTypeBundle =
1202 QString updateCubeLabelStr = attributes.value(
"updateCubeLabel");
1203 if (!updateCubeLabelStr.isEmpty()) {
1204 m_xmlHandlerBundleSettings->m_updateCubeLabel =
toBool(updateCubeLabelStr);
1207 QString errorPropagationStr = attributes.value(
"errorPropagation");
1208 if (!errorPropagationStr.isEmpty()) {
1209 m_xmlHandlerBundleSettings->m_errorPropagation =
toBool(errorPropagationStr);
1212 QString createInverseMatrixStr = attributes.value(
"createInverseMatrix");
1213 if (!createInverseMatrixStr.isEmpty()) {
1214 m_xmlHandlerBundleSettings->m_createInverseMatrix =
toBool(createInverseMatrixStr);
1217 else if (localName ==
"aprioriSigmas") {
1219 QString globalPointCoord1AprioriSigmaStr = attributes.value(
"pointCoord1");
1220 m_xmlHandlerBundleSettings->m_globalPointCoord1AprioriSigma =
Isis::Null;
1222 if (!globalPointCoord1AprioriSigmaStr.isEmpty()) {
1223 if (globalPointCoord1AprioriSigmaStr ==
"N/A") {
1224 m_xmlHandlerBundleSettings->m_globalPointCoord1AprioriSigma =
Isis::Null;
1227 m_xmlHandlerBundleSettings->m_globalPointCoord1AprioriSigma
1228 =
toDouble(globalPointCoord1AprioriSigmaStr);
1232 QString globalPointCoord2AprioriSigmaStr = attributes.value(
"pointCoord2");
1233 if (!globalPointCoord2AprioriSigmaStr.isEmpty()) {
1234 if (globalPointCoord2AprioriSigmaStr ==
"N/A") {
1235 m_xmlHandlerBundleSettings->m_globalPointCoord2AprioriSigma =
Isis::Null;
1238 m_xmlHandlerBundleSettings->m_globalPointCoord2AprioriSigma
1239 =
toDouble(globalPointCoord2AprioriSigmaStr);
1243 QString globalPointCoord3AprioriSigmaStr = attributes.value(
"radius");
1244 if (!globalPointCoord3AprioriSigmaStr.isEmpty()) {
1245 if (globalPointCoord3AprioriSigmaStr ==
"N/A") {
1246 m_xmlHandlerBundleSettings->m_globalPointCoord3AprioriSigma =
Isis::Null;
1249 m_xmlHandlerBundleSettings->m_globalPointCoord3AprioriSigma
1250 =
toDouble(globalPointCoord3AprioriSigmaStr);
1254 else if (localName ==
"outlierRejectionOptions") {
1255 QString outlierRejectionStr = attributes.value(
"rejection");
1256 if (!outlierRejectionStr.isEmpty()) {
1257 m_xmlHandlerBundleSettings->m_outlierRejection =
toBool(outlierRejectionStr);
1260 QString outlierRejectionMultiplierStr = attributes.value(
"multiplier");
1261 if (!outlierRejectionMultiplierStr.isEmpty()) {
1262 if (outlierRejectionMultiplierStr !=
"N/A") {
1263 m_xmlHandlerBundleSettings->m_outlierRejectionMultiplier
1264 =
toDouble(outlierRejectionMultiplierStr);
1267 m_xmlHandlerBundleSettings->m_outlierRejectionMultiplier = 3.0;
1271 else if (localName ==
"convergenceCriteriaOptions") {
1273 QString convergenceCriteriaStr = attributes.value(
"convergenceCriteria");
1274 if (!convergenceCriteriaStr.isEmpty()) {
1275 m_xmlHandlerBundleSettings->m_convergenceCriteria
1279 QString convergenceCriteriaThresholdStr = attributes.value(
"threshold");
1280 if (!convergenceCriteriaThresholdStr.isEmpty()) {
1281 m_xmlHandlerBundleSettings->m_convergenceCriteriaThreshold
1282 =
toDouble(convergenceCriteriaThresholdStr);
1285 QString convergenceCriteriaMaximumIterationsStr = attributes.value(
"maximumIterations");
1286 if (!convergenceCriteriaMaximumIterationsStr.isEmpty()) {
1287 m_xmlHandlerBundleSettings->m_convergenceCriteriaMaximumIterations
1288 =
toInt(convergenceCriteriaMaximumIterationsStr);
1291 else if (localName ==
"model") {
1292 QString type = attributes.value(
"type");
1293 QString quantile = attributes.value(
"quantile");
1294 if (!type.isEmpty() && !quantile.isEmpty()) {
1295 m_xmlHandlerBundleSettings->m_maximumLikelihood.append(
1296 qMakePair(MaximumLikelihoodWFunctions::stringToModel(type),
1300 else if (localName ==
"outputFileOptions") {
1301 QString outputFilePrefixStr = attributes.value(
"fileNamePrefix");
1302 if (!outputFilePrefixStr.isEmpty()) {
1303 m_xmlHandlerBundleSettings->m_outputFilePrefix = outputFilePrefixStr;
1306 else if (localName ==
"bundleObservationSolveSettings") {
1307 m_xmlHandlerObservationSettings.append(
1322 m_xmlHandlerCharacters += ch;
1323 return XmlStackedHandler::characters(ch);
1337 const QString &qName) {
1338 if (!m_xmlHandlerCharacters.isEmpty()) {
1339 if (localName ==
"validateNetwork") {
1340 m_xmlHandlerBundleSettings->m_validateNetwork =
toBool(m_xmlHandlerCharacters);
1342 else if (localName ==
"observationSolveSettingsList") {
1343 for (
int i = 0; i < m_xmlHandlerObservationSettings.size(); i++) {
1344 m_xmlHandlerBundleSettings->m_observationSolveSettings.append(
1345 *m_xmlHandlerObservationSettings[i]);
1347 m_xmlHandlerObservationSettings.clear();
1350 m_xmlHandlerCharacters =
"";
1352 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
1363 qDebug() <<
"Parse error with BundleSettings at line " << exception.lineNumber()
1364 <<
", " <<
"column " << exception.columnNumber() <<
": " 1365 << qPrintable(exception.message());
bool m_createInverseMatrix
Indicates whether to create the inverse matrix file.
bool solveMeanRadius() const
This method is used to determine whether the bundle adjustment will solve for target body mean radius...
BundleTargetBodyQsp m_bundleTargetBody
A pointer to the target body settings and information.
const double Null
Value for an Isis Null pixel.
The value of sigma0 will be used to determine that the bundle adjustment has converged.
The main project for ipce.
SurfacePoint::CoordinateType m_cpCoordTypeBundle
Indicates the coordinate type used for control points in the bundle adjustment.
void setObservationSolveOptions(QList< BundleObservationSolveSettings > obsSolveSettingsList)
Add the list of solve options for each observation.
bool m_solveObservationMode
Indicates whether to solve for observation mode.
static QString convergenceCriteriaToString(ConvergenceCriteria criteria)
Converts the given BundleSettings::ConvergenceCriteria enumeration to a string.
double convergenceCriteriaThreshold() const
Retrieves the convergence threshold to be used to solve the bundle adjustment.
bool errorPropagation() const
This method is used to determine whether this bundle adjustment will perform error propagation...
QList< QPair< MaximumLikelihoodWFunctions::Model, double > > maximumLikelihoodEstimatorModels() const
Retrieves the list of maximum likelihood estimator (MLE) models with their corresponding C-Quantiles...
void setOutputFilePrefix(QString outputFilePrefix)
Set the output file prefix for the bundle adjustment.
int toInt(const QString &string)
Global function to convert from a string to an integer.
ConvergenceCriteria m_convergenceCriteria
Enumeration used to indicate what criteria to use to determine bundle adjustment convergence.
void setConvergenceCriteria(ConvergenceCriteria criteria, double threshold, int maximumIterations)
Set the convergence criteria options for the bundle adjustment.
SurfacePoint::CoordinateType controlPointCoordTypeBundle() const
Indicates the control point coordinate type for the actual bundle adjust.
int numberTargetBodyParameters() const
This method is used to determine whether the bundle adjustment will solve for target body pole positi...
double m_outlierRejectionMultiplier
The multiplier value for outlier rejection.
bool validateNetwork() const
This method is used to determine whether to validate the network before the bundle adjustment...
QString outputFilePrefix() const
Retrieve the output file prefix.
bool solvePMAcceleration() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
bool updateCubeLabel() const
This method is used to determine whether this bundle adjustment will update the cube labels...
virtual bool characters(const QString &ch)
Add a character from an XML element to the content handler.
SurfacePoint::CoordinateType m_cpCoordTypeReports
Indicates the coordinate type for outputting control points in reports.
bool solvePoleDecVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body pole declin...
QString m_outputFilePrefix
The prefix for all output files.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
int numberSolveSettings() const
Retrieves the number of observation solve settings.
void setCubeList(QString fileName)
BundleSettings::setCubeList.
bool solvePoleDec() const
This method is used to determine whether the bundle adjustment will solve for target body pole declin...
void save(QXmlStreamWriter &stream, const Project *project) const
This method is used to write a BundleSettings object in an XML format.
Model
The supported maximum likelihood estimation models.
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.
bool m_validateNetwork
Indicates whether the network should be validated.
ConvergenceCriteria convergenceCriteria() const
Retrieves the convergence criteria to be used to solve the bundle adjustment.
double m_globalPointCoord3AprioriSigma
The global a priori sigma for radius or Z.
bool fatalError(const QXmlParseException &exception)
Format an error message indicating a problem with BundleSettings.
double globalPointCoord2AprioriSigma() const
Retrieves the global a priori sigma for 2nd coordinate of points for this bundle. ...
void setCreateInverseMatrix(bool createMatrix)
Turn the creation of the inverse correlation matrix file on or off.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Handle end tags for the BundleSettings serialized XML.
Planetocentric latitudinal (lat/lon/rad) coordinates.
A modification to Huber's method propsed by William J.J.
~BundleSettings()
Destroys the BundleSettings object.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Handle an XML start element.
bool outlierRejection() const
This method is used to determine whether outlier rejection will be performed on this bundle adjustmen...
XmlHandler(BundleSettings *bundleSettings, Project *project)
Create an XML Handler (reader) that can populate the BundleSettings class data.
void setBundleTargetBody(BundleTargetBodyQsp bundleTargetBody)
Sets the target body for the bundle adjustment.
void init()
Set Default vales for a BundleSettings object.
void addMaximumLikelihoodEstimatorModel(MaximumLikelihoodWFunctions::Model model, double cQuantile)
Add a maximum likelihood estimator (MLE) model to the bundle adjustment.
bool m_updateCubeLabel
Indicates whether to update cubes.
BundleSettings()
Constructs a BundleSettings object.
QList< QPair< MaximumLikelihoodWFunctions::Model, double > > m_maximumLikelihood
Model and C-Quantile for each of the three maximum likelihood estimations.
All parameter corrections will be used to determine that the bundle adjustment has converged...
SurfacePoint::CoordinateType controlPointCoordTypeReports() const
Indicates the control point coordinate type for reports.
int convergenceCriteriaMaximumIterations() const
Retrieves the maximum number of iterations allowed to solve the bundle adjustment.
#define _FILEINFO_
Macro for the filename and line number.
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Container class for BundleAdjustment settings.
A type of error that cannot be classified as any of the other error types.
QList< BundleObservationSolveSettings > observationSolveSettings() const
Retrieves solve settings for the observation corresponding to the given index.
void setValidateNetwork(bool validate)
Sets the internal flag to indicate whether to validate the network before the bundle adjustment...
BundleSettings & operator=(const BundleSettings &other)
Assignment operator to allow proper copying of the 'other' BundleSettings object to this one...
This class is needed to read/write BundleSettings from/to an XML formateed file.
bool IsSpecial(const double d)
Returns if the input pixel is special.
double m_convergenceCriteriaThreshold
Tolerance value corresponding to the selected convergence criteria.
Body-fixed rectangular x/y/z coordinates.
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
This class is used to modify and manage solve settings for 1 to many BundleObservations.
bool validate(const NaifVertex &v)
Verifies that the given NaifVector or NaifVertex is 3 dimensional.
bool solveRadius() const
This method is used to determine whether this bundle adjustment will solve for radius.
static CoordinateType stringToCoordinateType(QString type)
This method converts the given string value to a SurfacePoint::CoordinateType enumeration.
bool solvePMVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
bool solveTriaxialRadii() const
This method is used to determine whether the bundle adjustment will solve for target body triaxial ra...
static ConvergenceCriteria stringToConvergenceCriteria(QString criteria)
Converts the given string value to a BundleSettings::ConvergenceCriteria enumeration.
bool m_outlierRejection
Indicates whether to perform automatic outlier detection/rejection.
bool solveTargetBody() const
This method is used to determine whether the bundle adjustment will solve for target body...
~XmlHandler()
Destroys BundleSettings::XmlHandler object.
bool m_solveRadius
Indicates whether to solve for point radii.
int m_convergenceCriteriaMaximumIterations
Maximum number of iterations before quitting the bundle adjustment if it has not yet converged to the...
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
double m_globalPointCoord1AprioriSigma
The global a priori sigma for latitude or X.
Namespace for ISIS/Bullet specific routines.
double outlierRejectionMultiplier() const
Retrieves the outlier rejection multiplier for the bundle adjustment.
bool solvePM() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
bool solvePoleRAVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body pole right ...
double globalPointCoord3AprioriSigma() const
Retrieves the global a priori sigma 3rd coordinate of points for this bundle.
bool createInverseMatrix() const
Indicates if the settings will allow the inverse correlation matrix to be created.
bool m_solveTargetBody
Indicates whether to solve for target body.
double m_globalPointCoord2AprioriSigma
The global a priori sigma for longitude or Y.
static QString modelToString(Model model)
Static method to return a string represtentation for a given MaximumLikelihoodWFunctions::Model enum...
void setOutlierRejection(bool outlierRejection, double multiplier=1.0)
Set the outlier rejection options for the bundle adjustment.
bool m_errorPropagation
Indicates whether to perform error propagation.
double globalPointCoord1AprioriSigma() const
Retrieves global a priori sigma for 1st coordinate of points for this bundle.
bool solveObservationMode() const
This method is used to determine whether this bundle adjustment will solve for observation mode...
Manage a stack of content handlers for reading XML files.
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.
BundleTargetBodyQsp bundleTargetBody() const
Retrieves a pointer to target body information for the bundle adjustment.
QString cubeList() const
BundleSettings::cubeList.
bool solvePoleRA() const
This method is used to determine whether the bundle adjustment will solve for target body pole right ...
ConvergenceCriteria
This enum defines the options for the bundle adjustment's convergence.