10 #include <QXmlInputSource>
11 #include <QXmlStreamWriter>
26 #include "XmlStackedHandlerReader.h"
50 xmlReader->pushContentHandler(
new XmlHandler(
this, project));
51 xmlReader->setErrorHandler(
new XmlHandler(
this, project));
68 QString xmlPath = xmlFile.expanded();
69 QFile qXmlFile(xmlPath);
70 if (!qXmlFile.open(QFile::ReadOnly) ) {
72 QString(
"Unable to open xml file, [%1], with read access").arg(xmlPath),
76 QXmlInputSource xmlInputSource(&qXmlFile);
77 xmlReader->pushContentHandler(
new XmlHandler(
this, project));
78 xmlReader->setErrorHandler(
new XmlHandler(
this, project));
79 bool success = xmlReader->parse(xmlInputSource);
82 QString(
"Failed to parse xml file, [%1]").arg(xmlPath),
116 m_id =
new QUuid(other.
m_id->toString());
161 if (&other !=
this) {
164 m_id =
new QUuid(other.
m_id->toString());
200 m_id =
new QUuid(QUuid::createUuid());
294 if (option.compare(
"NONE", Qt::CaseInsensitive) == 0) {
297 else if (option.compare(
"NoPointingFactors", Qt::CaseInsensitive) == 0) {
300 else if (option.compare(
"ANGLES", Qt::CaseInsensitive) == 0) {
303 else if (option.compare(
"AnglesOnly", Qt::CaseInsensitive) == 0) {
306 else if (option.compare(
"VELOCITIES", Qt::CaseInsensitive) == 0) {
309 else if (option.compare(
"AnglesAndVelocity", Qt::CaseInsensitive) == 0) {
312 else if (option.compare(
"ACCELERATIONS", Qt::CaseInsensitive) == 0) {
315 else if (option.compare(
"AnglesVelocityAndAcceleration", Qt::CaseInsensitive) == 0) {
318 else if (option.compare(
"ALL", Qt::CaseInsensitive) == 0) {
321 else if (option.compare(
"AllPolynomialCoefficients", Qt::CaseInsensitive) == 0) {
326 "Unknown bundle instrument pointing solve option " + option +
".",
345 else if (option ==
AnglesOnly)
return "AnglesOnly";
350 "Unknown pointing solve option enum [" +
toString(option) +
"].",
373 bool solvePolynomialOverExisting,
374 double anglesAprioriSigma,
375 double angularVelocityAprioriSigma,
376 double angularAccelerationAprioriSigma) {
403 if (anglesAprioriSigma > 0.0) {
411 if (angularVelocityAprioriSigma > 0.0) {
419 if (angularAccelerationAprioriSigma > 0.0) {
544 if (option.compare(
"NONE", Qt::CaseInsensitive) == 0) {
547 else if (option.compare(
"NoPositionFactors", Qt::CaseInsensitive) == 0) {
550 else if (option.compare(
"POSITIONS", Qt::CaseInsensitive) == 0) {
553 else if (option.compare(
"PositionOnly", Qt::CaseInsensitive) == 0) {
556 else if (option.compare(
"VELOCITIES", Qt::CaseInsensitive) == 0) {
559 else if (option.compare(
"PositionAndVelocity", Qt::CaseInsensitive) == 0) {
562 else if (option.compare(
"ACCELERATIONS", Qt::CaseInsensitive) == 0) {
565 else if (option.compare(
"PositionVelocityAndAcceleration", Qt::CaseInsensitive) == 0) {
568 else if (option.compare(
"ALL", Qt::CaseInsensitive) == 0) {
571 else if (option.compare(
"AllPolynomialCoefficients", Qt::CaseInsensitive) == 0) {
576 "Unknown bundle instrument position solve option " + option +
".",
600 "Unknown position solve option enum [" +
toString(option) +
"].",
621 bool positionOverHermite,
622 double positionAprioriSigma,
623 double velocityAprioriSigma,
624 double accelerationAprioriSigma) {
649 if (positionAprioriSigma > 0.0) {
657 if (velocityAprioriSigma > 0.0) {
665 if (accelerationAprioriSigma > 0.0) {
775 QString pvlName =
"";;
784 pvl +=
PvlKeyword(
"InstrumentPointingSolveOption",
787 pvl +=
PvlKeyword(
"NumberAngleCoefficientsSolved",
792 pvl +=
PvlKeyword(
"SolvePointingPolynomialOverExisting",
805 pvl +=
PvlKeyword(
"InstrumentPointingInterpolationType",
810 pvl +=
PvlKeyword(
"NumberAngleCoefficientsSolved",
"N/A");
814 pvl +=
PvlKeyword(
"SolvePointingPolynomialOverExisting",
"N/A");
815 pvl +=
PvlKeyword(
"AngleAprioriSigmas",
"N/A");
816 pvl +=
PvlKeyword(
"InstrumentPointingInterpolationType",
"N/A");
822 pvl +=
PvlKeyword(
"InstrumentPositionSolveOption",
825 pvl +=
PvlKeyword(
"NumberPositionCoefficientsSolved",
831 PvlKeyword positionSigmas(
"PositionAprioriSigmas");
840 pvl += positionSigmas;
842 pvl +=
PvlKeyword(
"InstrumentPositionInterpolationType",
846 pvl +=
PvlKeyword(
"NumberPositionCoefficientsSolved",
"N/A");
849 pvl +=
PvlKeyword(
"SolvePositionOverHermiteSpline",
"N/A");
850 pvl +=
PvlKeyword(
"PositionAprioriSigmas",
"N/A");
851 pvl +=
PvlKeyword(
"InstrumentPositionInterpolationType",
"N/A");
867 const Project *project)
const {
869 stream.writeStartElement(
"bundleObservationSolveSettings");
870 stream.writeTextElement(
"id",
m_id->toString());
871 stream.writeTextElement(
"instrumentId",
instrumentId());
874 stream.writeStartElement(
"instrumentPointingOptions");
875 stream.writeAttribute(
"solveOption",
884 stream.writeStartElement(
"aprioriPointingSigmas");
887 stream.writeTextElement(
"sigma",
"N/A");
893 stream.writeEndElement();
894 stream.writeEndElement();
897 stream.writeStartElement(
"instrumentPositionOptions");
898 stream.writeAttribute(
"solveOption",
906 stream.writeStartElement(
"aprioriPositionSigmas");
909 stream.writeTextElement(
"sigma",
"N/A");
915 stream.writeEndElement();
916 stream.writeEndElement();
918 stream.writeEndElement();
934 m_xmlHandlerObservationSettings = settings;
935 m_xmlHandlerProject = project;
936 m_xmlHandlerCharacters =
"";
947 m_xmlHandlerProject = NULL;
963 const QString &localName,
964 const QString &qName,
965 const QXmlAttributes &atts) {
966 m_xmlHandlerCharacters =
"";
967 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
968 if (localName ==
"instrumentPointingOptions") {
970 QString pointingSolveOption = atts.value(
"solveOption");
971 if (!pointingSolveOption.isEmpty()) {
972 m_xmlHandlerObservationSettings->m_instrumentPointingSolveOption
976 QString numberCoefSolved = atts.value(
"numberCoefSolved");
977 if (!numberCoefSolved.isEmpty()) {
978 m_xmlHandlerObservationSettings->m_numberCamAngleCoefSolved =
toInt(numberCoefSolved);
981 QString
ckDegree = atts.value(
"degree");
982 if (!ckDegree.isEmpty()) {
983 m_xmlHandlerObservationSettings->m_ckDegree =
toInt(ckDegree);
987 if (!ckSolveDegree.isEmpty()) {
988 m_xmlHandlerObservationSettings->m_ckSolveDegree =
toInt(ckSolveDegree);
991 QString
solveTwist = atts.value(
"solveTwist");
992 if (!solveTwist.isEmpty()) {
993 m_xmlHandlerObservationSettings->m_solveTwist =
toBool(solveTwist);
996 QString solveOverExisting = atts.value(
"solveOverExisting");
997 if (!solveOverExisting.isEmpty()) {
998 m_xmlHandlerObservationSettings->m_solvePointingPolynomialOverExisting =
999 toBool(solveOverExisting);
1002 QString interpolationType = atts.value(
"interpolationType");
1003 if (!interpolationType.isEmpty()) {
1004 m_xmlHandlerObservationSettings->m_pointingInterpolationType =
1009 else if (localName ==
"aprioriPointingSigmas") {
1010 m_xmlHandlerAprioriSigmas.clear();
1012 else if (localName ==
"instrumentPositionOptions") {
1014 QString positionSolveOption = atts.value(
"solveOption");
1015 if (!positionSolveOption.isEmpty()) {
1016 m_xmlHandlerObservationSettings->m_instrumentPositionSolveOption
1020 QString numberCoefSolved = atts.value(
"numberCoefSolved");
1021 if (!numberCoefSolved.isEmpty()) {
1022 m_xmlHandlerObservationSettings->m_numberCamPosCoefSolved =
toInt(numberCoefSolved);
1025 QString
spkDegree = atts.value(
"degree");
1026 if (!spkDegree.isEmpty()) {
1027 m_xmlHandlerObservationSettings->m_spkDegree =
toInt(spkDegree);
1031 if (!spkSolveDegree.isEmpty()) {
1032 m_xmlHandlerObservationSettings->m_spkSolveDegree =
toInt(spkSolveDegree);
1035 QString solveOverHermiteSpline = atts.value(
"solveOverHermiteSpline");
1036 if (!solveOverHermiteSpline.isEmpty()) {
1037 m_xmlHandlerObservationSettings->m_solvePositionOverHermiteSpline =
1038 toBool(solveOverHermiteSpline);
1041 QString interpolationType = atts.value(
"interpolationType");
1042 if (!interpolationType.isEmpty()) {
1043 m_xmlHandlerObservationSettings->m_positionInterpolationType =
1047 else if (localName ==
"aprioriPositionSigmas") {
1048 m_xmlHandlerAprioriSigmas.clear();
1064 m_xmlHandlerCharacters += ch;
1065 return XmlStackedHandler::characters(ch);
1080 const QString &localName,
1081 const QString &qName) {
1082 if (!m_xmlHandlerCharacters.isEmpty()) {
1083 if (localName ==
"id") {
1084 m_xmlHandlerObservationSettings->m_id = NULL;
1085 m_xmlHandlerObservationSettings->m_id =
new QUuid(m_xmlHandlerCharacters);
1087 else if (localName ==
"instrumentId") {
1088 m_xmlHandlerObservationSettings->setInstrumentId(m_xmlHandlerCharacters);
1094 else if (localName ==
"sigma") {
1095 m_xmlHandlerAprioriSigmas.append(m_xmlHandlerCharacters);
1097 else if (localName ==
"aprioriPointingSigmas") {
1098 m_xmlHandlerObservationSettings->m_anglesAprioriSigma.clear();
1099 for (
int i = 0; i < m_xmlHandlerAprioriSigmas.size(); i++) {
1100 if (m_xmlHandlerAprioriSigmas[i] ==
"N/A") {
1101 m_xmlHandlerObservationSettings->m_anglesAprioriSigma.append(
Isis::Null);
1104 m_xmlHandlerObservationSettings->m_anglesAprioriSigma.append(
1105 toDouble(m_xmlHandlerAprioriSigmas[i]));
1109 else if (localName ==
"aprioriPositionSigmas") {
1110 m_xmlHandlerObservationSettings->m_positionAprioriSigma.clear();
1111 for (
int i = 0; i < m_xmlHandlerAprioriSigmas.size(); i++) {
1112 if (m_xmlHandlerAprioriSigmas[i] ==
"N/A") {
1113 m_xmlHandlerObservationSettings->m_positionAprioriSigma.append(
Isis::Null);
1116 m_xmlHandlerObservationSettings->m_positionAprioriSigma.append(
1117 toDouble(m_xmlHandlerAprioriSigmas[i]));
1121 m_xmlHandlerCharacters =
"";
1123 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
1134 stream <<
m_id->toString()
1170 >> anglesSolveOption
1171 >> numCamAngleCoefSolved
1178 >> positionSolveOption
1179 >> numCamPosCoefSolved
1184 >> positionInterpType;
1188 m_id =
new QUuid(
id);
1218 return settings.
write(stream);
1232 return settings.
read(stream);
1241 H5::CompType BundleObservationSolveSettings::compoundH5DataType() {
1243 H5::CompType compoundDataType((
size_t) );
1247 compoundDataType.insertMember(
"InstrumentId", offset, H5::PredType::C_S1);
1250 compoundDataType.insertMember(
"InstrumentPointingSolveOption", offset, H5::PredType::NATIVE_INT);
1253 compoundDataType.insertMember(
"NumCamAngleCoefSolved", offset, H5::PredType::NATIVE_INT);
1256 compoundDataType.insertMember(
"CkDegree", offset, H5::PredType::NATIVE_INT);
1259 compoundDataType.insertMember(
"CkSolveDegree", offset, H5::PredType::NATIVE_INT);
1262 compoundDataType.insertMember(
"SolveTwist", offset, H5::PredType::NATIVE_HBOOL);
1265 compoundDataType.insertMember(
"SolvePointingPolynomialOverExisting", offset, H5::PredType::NATIVE_HBOOL);
1268 ??? compoundDataType.insertMember(
"AnglesAprioriSigma", offset, H5::PredType::NATIVE_DOUBLE);
1271 compoundDataType.insertMember(
"PointingInterpolationType", offset, H5::PredType::NATIVE_INT);
1274 compoundDataType.insertMember(
"InstrumentPositionSolveOption", offset, H5::PredType::NATIVE_INT);
1277 compoundDataType.insertMember(
"NumCamPosCoefSolved", offset, H5::PredType::NATIVE_INT);
1280 compoundDataType.insertMember(
"SpkDegree", offset, H5::PredType::NATIVE_INT);
1283 compoundDataType.insertMember(
"SpkSolveDegree", offset, H5::PredType::NATIVE_INT);
1286 compoundDataType.insertMember(
"SolvePositionOverHermiteSpline", offset, H5::PredType::NATIVE_HBOOL);
1289 ??? compoundDataType.insertMember(
"PositionAprioriSigma", offset, H5::PredType::NATIVE_DOUBLE);
1292 compoundDataType.insertMember(
"PositionInterpolationType", offset, H5::PredType::NATIVE_INT);
1294 return compoundDataType;
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)
Sets the instrument pointing settings.
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 cnetsuite.
QList< double > aprioriPointingSigmas() const
Accesses the a priori pointing sigmas.
int spkSolveDegree() const
Accesses the degree of thecamera position polynomial being fit to in the bundle adjustment (spkSolveD...
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.
void save(QXmlStreamWriter &stream, const Project *project) const
Saves this BundleObservationSolveSettings to an xml stream.
QDataStream & read(QDataStream &stream)
Reads in the state of a BundleObservationSolveSettings from a stream.
int numberCameraAngleCoefficientsSolved() const
Accesses the number of camera angle coefficients in the solution.
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.
InstrumentPositionSolveOption instrumentPositionSolveOption() const
Accesses the instrument position solve option.
bool solvePositionOverHermite() const
Whether or not the polynomial for solving will be fit over an existing Hermite spline.
XmlHandler(BundleObservationSolveSettings *settings, Project *project)
Constructs an XmlHandler for serialization.
void initialize()
Initializes the default state of this BundleObservationSolveSettings.
int numberCameraPositionCoefficientsSolved() const
Accesses the number of camera position coefficients in the solution.
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.
bool solveTwist() const
Accesses the flag for solving for twist.
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.
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.
Object is reading from splined.
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.
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
PvlObject pvlObject(QString name="") const
Serializes this BundleObservationSolveSettings into a PvlObject.
A single keyword-value pair.
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.
SpiceRotation::Source pointingInterpolationType() const
Accesses the SpiceRotation interpolation type for the instrument pointing.
int ckSolveDegree() const
Accesses the degree of the camera angles polynomial being fit to in the bundle adjustment (ckSolveDeg...
QDataStream & write(QDataStream &stream) const
Writes this BundleObservationSolveSettings to a stream.
Kernels plus nth degree polynomial.
InstrumentPointingSolveOption instrumentPointingSolveOption() const
Accesses the instrument pointing solve option.
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 setInstrumentId(QString instrumentId)
Sets the instrument id for this observation.
QList< double > aprioriPositionSigmas() const
Accesses the a priori position sigmas.
InstrumentPositionSolveOption m_instrumentPositionSolveOption
Option for how to solve for instrument position.
This class is used to modify and manage solve settings for 1 to many BundleObservations.
Solve for instrument positions, velocities, and accelerations.
QSet< QString > observationNumbers() const
Returns a list of observation numbers associated with these solve settings.
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.
QString instrumentId() const
Accesses the instrument id for this observation.
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.
InstrumentPositionSolveOption
Options for how to solve for instrument position.
static InstrumentPositionSolveOption stringToInstrumentPositionSolveOption(QString option)
Translates a QString InstrumentPositionSolveOption to its enumerated value.
~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.
SpiceRotation::Source m_pointingInterpolationType
SpiceRotation interpolation type.
Solve for none of the pointing factors.
QSet< QString > m_observationNumbers
Associated observation numbers for these settings.
SpicePosition::Source positionInterpolationType() const
Accesses the SpicePosition interpolation type for the spacecraft position.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
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.
Contains Pvl Groups and Pvl Objects.
bool solvePolyOverPointing() const
Whether or not the solve polynomial will be fit over the existing pointing polynomial.
his enables stack-based XML parsing of XML files.
Solve for pointing angles: right ascension, declination and, optionally, twist.
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)
Sets the instrument pointing settings.
QUuid * m_id
A unique ID for this object (useful for others to reference this object when saving to disk)...
int spkDegree() const
Accesses the degree of the polynomial fit to the original camera position (spkDegree).
int ckDegree() const
Accesses the degree of polynomial fit to original camera angles (ckDegree).
Source
This enum indicates the status of the object.
void addValue(QString value, QString unit="")
Adds a value with units.
BundleObservationSolveSettings & operator=(const BundleObservationSolveSettings &src)
Assigns the state of another BundleObservationSolveSettings to this one.