10 #include <QXmlInputSource> 11 #include <QXmlStreamWriter> 21 #include "XmlStackedHandlerReader.h" 46 xmlReader->setErrorHandler(
new XmlHandler(
this, project));
63 QString xmlPath = xmlFile.
expanded();
64 QFile qXmlFile(xmlPath);
65 if (!qXmlFile.open(QFile::ReadOnly) ) {
67 QString(
"Unable to open xml file, [%1], with read access").arg(xmlPath),
71 QXmlInputSource xmlInputSource(&qXmlFile);
73 xmlReader->setErrorHandler(
new XmlHandler(
this, project));
74 bool success = xmlReader->parse(xmlInputSource);
77 QString(
"Failed to parse xml file, [%1]").arg(xmlPath),
111 m_id =
new QUuid(other.
m_id->toString());
156 if (&other !=
this) {
159 m_id =
new QUuid(other.
m_id->toString());
195 m_id =
new QUuid(QUuid::createUuid());
302 if (option.compare(
"NONE", Qt::CaseInsensitive) == 0) {
305 else if (option.compare(
"NoPointingFactors", Qt::CaseInsensitive) == 0) {
308 else if (option.compare(
"ANGLES", Qt::CaseInsensitive) == 0) {
311 else if (option.compare(
"AnglesOnly", Qt::CaseInsensitive) == 0) {
314 else if (option.compare(
"VELOCITIES", Qt::CaseInsensitive) == 0) {
317 else if (option.compare(
"AnglesAndVelocity", Qt::CaseInsensitive) == 0) {
320 else if (option.compare(
"ACCELERATIONS", Qt::CaseInsensitive) == 0) {
323 else if (option.compare(
"AnglesVelocityAndAcceleration", Qt::CaseInsensitive) == 0) {
326 else if (option.compare(
"ALL", Qt::CaseInsensitive) == 0) {
329 else if (option.compare(
"AllPolynomialCoefficients", Qt::CaseInsensitive) == 0) {
334 "Unknown bundle instrument pointing solve option " + option +
".",
353 else if (option ==
AnglesOnly)
return "AnglesOnly";
358 "Unknown pointing solve option enum [" +
toString(option) +
"].",
381 bool solvePolynomialOverExisting,
382 double anglesAprioriSigma,
383 double angularVelocityAprioriSigma,
384 double angularAccelerationAprioriSigma,
QList<double> * additionalPointingSigmas) {
411 if (anglesAprioriSigma > 0.0) {
419 if (angularVelocityAprioriSigma > 0.0) {
427 if (angularAccelerationAprioriSigma > 0.0) {
437 if (additionalPointingSigmas) {
438 for (
int i=0;i < additionalPointingSigmas->count();i++) {
562 if (option.compare(
"NONE", Qt::CaseInsensitive) == 0) {
565 else if (option.compare(
"NoPositionFactors", Qt::CaseInsensitive) == 0) {
568 else if (option.compare(
"POSITIONS", Qt::CaseInsensitive) == 0) {
571 else if (option.compare(
"PositionOnly", Qt::CaseInsensitive) == 0) {
574 else if (option.compare(
"VELOCITIES", Qt::CaseInsensitive) == 0) {
577 else if (option.compare(
"PositionAndVelocity", Qt::CaseInsensitive) == 0) {
580 else if (option.compare(
"ACCELERATIONS", Qt::CaseInsensitive) == 0) {
583 else if (option.compare(
"PositionVelocityAndAcceleration", Qt::CaseInsensitive) == 0) {
586 else if (option.compare(
"ALL", Qt::CaseInsensitive) == 0) {
589 else if (option.compare(
"AllPolynomialCoefficients", Qt::CaseInsensitive) == 0) {
594 "Unknown bundle instrument position solve option " + option +
".",
618 "Unknown position solve option enum [" +
toString(option) +
"].",
638 bool positionOverHermite,
639 double positionAprioriSigma,
640 double velocityAprioriSigma,
641 double accelerationAprioriSigma,
667 if (positionAprioriSigma > 0.0) {
675 if (velocityAprioriSigma > 0.0) {
683 if (accelerationAprioriSigma > 0.0) {
693 if (additionalPositionSigmas) {
694 for (
int i=0;i < additionalPositionSigmas->count();i++) {
800 const Project *project)
const {
802 stream.writeStartElement(
"bundleObservationSolveSettings");
803 stream.writeTextElement(
"id",
m_id->toString());
804 stream.writeTextElement(
"instrumentId",
instrumentId());
807 stream.writeStartElement(
"instrumentPointingOptions");
808 stream.writeAttribute(
"solveOption",
817 stream.writeStartElement(
"aprioriPointingSigmas");
820 stream.writeTextElement(
"sigma",
"N/A");
826 stream.writeEndElement();
827 stream.writeEndElement();
830 stream.writeStartElement(
"instrumentPositionOptions");
831 stream.writeAttribute(
"solveOption",
839 stream.writeStartElement(
"aprioriPositionSigmas");
842 stream.writeTextElement(
"sigma",
"N/A");
848 stream.writeEndElement();
849 stream.writeEndElement();
851 stream.writeEndElement();
867 m_xmlHandlerObservationSettings = settings;
868 m_xmlHandlerProject = project;
869 m_xmlHandlerCharacters =
"";
880 m_xmlHandlerProject = NULL;
896 const QString &localName,
897 const QString &qName,
898 const QXmlAttributes &atts) {
899 m_xmlHandlerCharacters =
"";
900 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
901 if (localName ==
"instrumentPointingOptions") {
903 QString pointingSolveOption = atts.value(
"solveOption");
904 if (!pointingSolveOption.isEmpty()) {
905 m_xmlHandlerObservationSettings->m_instrumentPointingSolveOption
909 QString numberCoefSolved = atts.value(
"numberCoefSolved");
910 if (!numberCoefSolved.isEmpty()) {
911 m_xmlHandlerObservationSettings->m_numberCamAngleCoefSolved =
toInt(numberCoefSolved);
914 QString
ckDegree = atts.value(
"degree");
916 m_xmlHandlerObservationSettings->m_ckDegree =
toInt(
ckDegree);
924 QString
solveTwist = atts.value(
"solveTwist");
929 QString solveOverExisting = atts.value(
"solveOverExisting");
930 if (!solveOverExisting.isEmpty()) {
931 m_xmlHandlerObservationSettings->m_solvePointingPolynomialOverExisting =
932 toBool(solveOverExisting);
935 QString interpolationType = atts.value(
"interpolationType");
936 if (!interpolationType.isEmpty()) {
937 m_xmlHandlerObservationSettings->m_pointingInterpolationType =
942 else if (localName ==
"aprioriPointingSigmas") {
943 m_xmlHandlerAprioriSigmas.clear();
945 else if (localName ==
"instrumentPositionOptions") {
947 QString positionSolveOption = atts.value(
"solveOption");
948 if (!positionSolveOption.isEmpty()) {
949 m_xmlHandlerObservationSettings->m_instrumentPositionSolveOption
953 QString numberCoefSolved = atts.value(
"numberCoefSolved");
954 if (!numberCoefSolved.isEmpty()) {
955 m_xmlHandlerObservationSettings->m_numberCamPosCoefSolved =
toInt(numberCoefSolved);
958 QString
spkDegree = atts.value(
"degree");
968 QString solveOverHermiteSpline = atts.value(
"solveOverHermiteSpline");
969 if (!solveOverHermiteSpline.isEmpty()) {
970 m_xmlHandlerObservationSettings->m_solvePositionOverHermiteSpline =
971 toBool(solveOverHermiteSpline);
974 QString interpolationType = atts.value(
"interpolationType");
975 if (!interpolationType.isEmpty()) {
976 m_xmlHandlerObservationSettings->m_positionInterpolationType =
980 else if (localName ==
"aprioriPositionSigmas") {
981 m_xmlHandlerAprioriSigmas.clear();
997 m_xmlHandlerCharacters += ch;
998 return XmlStackedHandler::characters(ch);
1013 const QString &localName,
1014 const QString &qName) {
1015 if (!m_xmlHandlerCharacters.isEmpty()) {
1016 if (localName ==
"id") {
1017 m_xmlHandlerObservationSettings->m_id = NULL;
1018 m_xmlHandlerObservationSettings->m_id =
new QUuid(m_xmlHandlerCharacters);
1020 else if (localName ==
"instrumentId") {
1021 m_xmlHandlerObservationSettings->setInstrumentId(m_xmlHandlerCharacters);
1027 else if (localName ==
"sigma") {
1028 m_xmlHandlerAprioriSigmas.append(m_xmlHandlerCharacters);
1030 else if (localName ==
"aprioriPointingSigmas") {
1031 m_xmlHandlerObservationSettings->m_anglesAprioriSigma.clear();
1032 for (
int i = 0; i < m_xmlHandlerAprioriSigmas.size(); i++) {
1033 if (m_xmlHandlerAprioriSigmas[i] ==
"N/A") {
1034 m_xmlHandlerObservationSettings->m_anglesAprioriSigma.append(
Isis::Null);
1037 m_xmlHandlerObservationSettings->m_anglesAprioriSigma.append(
1038 toDouble(m_xmlHandlerAprioriSigmas[i]));
1042 else if (localName ==
"aprioriPositionSigmas") {
1043 m_xmlHandlerObservationSettings->m_positionAprioriSigma.clear();
1044 for (
int i = 0; i < m_xmlHandlerAprioriSigmas.size(); i++) {
1045 if (m_xmlHandlerAprioriSigmas[i] ==
"N/A") {
1046 m_xmlHandlerObservationSettings->m_positionAprioriSigma.append(
Isis::Null);
1049 m_xmlHandlerObservationSettings->m_positionAprioriSigma.append(
1050 toDouble(m_xmlHandlerAprioriSigmas[i]));
1054 m_xmlHandlerCharacters =
"";
1056 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
static InstrumentPointingSolveOption stringToInstrumentPointingSolveOption(QString option)
Translates a QString InstrumentPointingSolveOption to its enumerated value.
const double Null
Value for an Isis Null pixel.
The main project for ipce.
int m_ckSolveDegree
Degree of the camera angles polynomial being fit to in the bundle adjustment.
File name manipulation and expansion.
Object is calculated from nth degree polynomial.
QSet< QString > observationNumbers() const
Returns a list of observation numbers associated with these solve settings.
int numberCameraPositionCoefficientsSolved() const
Accesses the number of camera position coefficients in the solution.
InstrumentPositionSolveOption instrumentPositionSolveOption() const
Accesses the instrument position solve option.
bool removeObservationNumber(QString observationNumber)
Removes an observation number from this solve settings.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Solve for instrument positions only.
bool m_solvePositionOverHermiteSpline
The polynomial will be fit over an existing Hermite spline.
XmlHandler(BundleObservationSolveSettings *settings, Project *project)
Constructs an XmlHandler for serialization.
bool solvePositionOverHermite() const
Whether or not the polynomial for solving will be fit over an existing Hermite spline.
SpicePosition::Source positionInterpolationType() const
Accesses the SpicePosition interpolation type for the spacecraft position.
void initialize()
Initializes the default state of this BundleObservationSolveSettings.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Solve for pointing angles, their velocities and their accelerations.
virtual bool characters(const QString &ch)
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.
A type of error that occurred when performing an actual I/O operation.
QString m_instrumentId
The spacecraft instrument id for this observation.
int m_spkSolveDegree
Degree of the camera position polynomial being fit to in the bundle adjustment.
int m_numberCamAngleCoefSolved
The number of camera angle coefficients in solution.
BundleObservationSolveSettings()
Constructor with default parameter initializations.
int ckDegree() const
Accesses the degree of polynomial fit to original camera angles (ckDegree).
InstrumentPointingSolveOption instrumentPointingSolveOption() const
Accesses the instrument pointing solve option.
QList< double > m_positionAprioriSigma
The instrument pointing a priori sigmas.
Solve for all coefficients in the polynomials fit to the instrument positions.
SpicePosition::Source m_positionInterpolationType
SpicePosition interpolation types.
int ckSolveDegree() const
Accesses the degree of the camera angles polynomial being fit to in the bundle adjustment (ckSolveDeg...
Object is reading from splined.
int spkSolveDegree() const
Accesses the degree of thecamera position polynomial being fit to in the bundle adjustment (spkSolveD...
void addObservationNumber(QString observationNumber)
Associates an observation number with these solve settings.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Solve for instrument positions and velocities.
bool m_solvePointingPolynomialOverExisting
The polynomial will be fit over the existing pointing polynomial.
#define _FILEINFO_
Macro for the filename and line number.
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
void save(QXmlStreamWriter &stream, const Project *project) const
Saves this BundleObservationSolveSettings to an xml stream.
static QString instrumentPointingSolveOptionToString(InstrumentPointingSolveOption option)
Tranlsates an enumerated InstrumentPointingSolveOption value to its string representation.
A type of error that cannot be classified as any of the other error types.
bool solvePolyOverPointing() const
Whether or not the solve polynomial will be fit over the existing pointing polynomial.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Kernels plus nth degree polynomial.
bool IsSpecial(const double d)
Returns if the input pixel is special.
Source
The rotation can come from one of 3 places for an Isis cube.
void setInstrumentPositionSettings(InstrumentPositionSolveOption option, int spkDegree=2, int spkSolveDegree=2, bool positionOverHermite=false, double positionAprioriSigma=-1.0, double velocityAprioriSigma=-1.0, double accelerationAprioriSigma=-1.0, QList< double > *additionalPositionSigmas=nullptr)
Sets the instrument pointing settings.
void setInstrumentId(QString instrumentId)
Sets the instrument id for this observation.
InstrumentPositionSolveOption m_instrumentPositionSolveOption
Option for how to solve for instrument position.
QList< double > aprioriPositionSigmas() const
Accesses the a priori position sigmas.
This class is used to modify and manage solve settings for 1 to many BundleObservations.
Solve for instrument positions, velocities, and accelerations.
QList< double > m_anglesAprioriSigma
The image position a priori sigmas.The size of the list is equal to the number of coefficients in the...
Solve for pointing angles and their angular velocities.
int m_spkDegree
Degree of the polynomial fit to the original camera position.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
bool m_solveTwist
Solve for "twist" angle.
Solve for none of the position factors.
void setInstrumentPointingSettings(InstrumentPointingSolveOption option, bool solveTwist, int ckDegree=2, int ckSolveDegree=2, bool solvePolynomialOverExisting=false, double anglesAprioriSigma=-1.0, double angularVelocityAprioriSigma=-1.0, double angularAccelerationAprioriSigma=-1.0, QList< double > *additionalPointingSigmas=nullptr)
Sets the instrument pointing settings.
InstrumentPointingSolveOption m_instrumentPointingSolveOption
Option for how to solve for instrument pointing.
~BundleObservationSolveSettings()
Destructor.
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
int m_numberCamPosCoefSolved
The number of camera position coefficients in the solution.
int numberCameraAngleCoefficientsSolved() const
Accesses the number of camera angle coefficients in the solution.
InstrumentPositionSolveOption
Options for how to solve for instrument position.
static InstrumentPositionSolveOption stringToInstrumentPositionSolveOption(QString option)
Translates a QString InstrumentPositionSolveOption to its enumerated value.
Namespace for ISIS/Bullet specific routines.
~XmlHandler()
XmlHandler destructor.
From nth degree polynomial.
Solve for all coefficients in the polynomials fit to the pointing angles.
InstrumentPointingSolveOption
Options for how to solve for instrument pointing.
QString instrumentId() const
Accesses the instrument id for this observation.
SpiceRotation::Source m_pointingInterpolationType
SpiceRotation interpolation type.
Solve for none of the pointing factors.
QSet< QString > m_observationNumbers
Associated observation numbers for these settings.
static QString instrumentPositionSolveOptionToString(InstrumentPositionSolveOption option)
Translates an enumerated InstrumentPositionSolveOption to its string representation.
int m_ckDegree
Degree of the polynomial fit to the original camera angles.
SpiceRotation::Source pointingInterpolationType() const
Accesses the SpiceRotation interpolation type for the instrument pointing.
Manage a stack of content handlers for reading XML files.
int spkDegree() const
Accesses the degree of the polynomial fit to the original camera position (spkDegree).
Solve for pointing angles: right ascension, declination and, optionally, twist.
bool solveTwist() const
Accesses the flag for solving for twist.
QUuid * m_id
A unique ID for this object (useful for others to reference this object when saving to disk)...
QList< double > aprioriPointingSigmas() const
Accesses the a priori pointing sigmas.
Source
This enum indicates the status of the object.
BundleObservationSolveSettings & operator=(const BundleObservationSolveSettings &src)
Assigns the state of another BundleObservationSolveSettings to this one.