Skip to content

Commit

Permalink
Removed XmlStackedHandlerReader
Browse files Browse the repository at this point in the history
  • Loading branch information
amystamile-usgs committed Nov 28, 2023
1 parent fb941ad commit f3adebd
Show file tree
Hide file tree
Showing 76 changed files with 162 additions and 721 deletions.
6 changes: 2 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ dependencies:
- pytest
- rclone
- qhull
# - qt>=5.9.6,<5.15.0
# - qwt
- qt-main>=5.15.2
- qwt>=6.2.0
- qt>=5.15.0,<6
- qwt
- sqlite
- suitesparse
- superlu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ find files of those names at the top level of this repository. **/
#include "IException.h"
#include "IString.h"
#include "Project.h"
#include "XmlStackedHandlerReader.h"

#include "Pvl.h"
#include <iostream>
Expand All @@ -43,15 +42,6 @@ namespace Isis {
}


// TODO: should project be const ???
StatCumProbDistDynCalc::StatCumProbDistDynCalc(Project *project,
XmlStackedHandlerReader *xmlReader,
QObject *parent) { // TODO: does xml stuff need project???
initialize();
xmlReader->pushContentHandler(new XmlHandler(this, project)); // TODO: does xml stuff need project???
}



StatCumProbDistDynCalc::StatCumProbDistDynCalc(const StatCumProbDistDynCalc &other)
: m_numberCells(other.m_numberCells),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class QXmlStreamWriter;

namespace Isis {
class Project;// ??? does xml stuff need project???
class XmlStackedHandlerReader;

/**
* @brief This class is used to approximate cumulative probibility distributions of a stream of
Expand Down Expand Up @@ -70,8 +69,6 @@ namespace Isis {
// Observations"
public:
StatCumProbDistDynCalc(unsigned int nodes=20, QObject *parent = 0); //individual qunatile value to be calculated
StatCumProbDistDynCalc(Project *project, XmlStackedHandlerReader *xmlReader,
QObject *parent = 0); // TODO: does xml stuff need project???
StatCumProbDistDynCalc(const StatCumProbDistDynCalc &other);
~StatCumProbDistDynCalc();
StatCumProbDistDynCalc &operator=(const StatCumProbDistDynCalc &other);
Expand Down
23 changes: 10 additions & 13 deletions isis/src/base/objs/StatCumProbDistDynCalc/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ find files of those names at the top level of this repository. **/
#include <QDataStream>
#include <QDebug>
#include <QXmlStreamWriter>
#include <QXmlInputSource>

#include <iostream>

#include "FileName.h"
#include "IException.h"
#include "Preference.h"
#include "StatCumProbDistDynCalc.h"
#include "XmlStackedHandlerReader.h"

using namespace std;
using namespace Isis;
Expand All @@ -38,8 +36,7 @@ using namespace Isis;
namespace Isis {
class StatisticsXmlHandlerTester : public StatCumProbDistDynCalc {
public:
StatisticsXmlHandlerTester(Project *project, XmlStackedHandlerReader *reader,
FileName xmlFile) : StatCumProbDistDynCalc(project, reader) {
StatisticsXmlHandlerTester(FileName xmlFile) : StatCumProbDistDynCalc() {

QString xmlPath(xmlFile.expanded());
QFile file(xmlPath);
Expand All @@ -49,15 +46,16 @@ namespace Isis {
QString("Unable to open xml file, [%1], with read access").arg(xmlPath),
_FILEINFO_);
}
QXmlStreamReader reader(&file);

QXmlInputSource xmlInputSource(&file);
bool success = reader->parse(xmlInputSource);
if (!success) {
while (!reader.atEnd()) {
reader.readNext();
}
if (reader.hasError()) {
throw IException(IException::Unknown,
QString("Failed to parse xml file, [%1]").arg(xmlPath),
_FILEINFO_);
QString("Failed to parse xml file, [%1]").arg(xmlPath),
_FILEINFO_);
}

}

~StatisticsXmlHandlerTester() {
Expand Down Expand Up @@ -174,8 +172,7 @@ int main(int argc, char *argv[]) {
// read xml with no attributes or values
FileName emptyXmlFile("./unitTest_NoElementValues.xml");
Project *project = NULL;
XmlStackedHandlerReader reader;
StatisticsXmlHandlerTester statsFromEmptyXml(project, &reader, emptyXmlFile);
StatisticsXmlHandlerTester statsFromEmptyXml(emptyXmlFile);
qDebug() << "Testing XML: read XML with no attributes or values "
"to StatCumProbDistDynCalc object... Then try to get "
"min from object with no observations.";
Expand Down Expand Up @@ -633,7 +630,7 @@ int main(int argc, char *argv[]) {
qXmlFile.close();
// read xml
qDebug() << "Testing XML: read XML to StatCumProbDistDynCalc object...";
StatisticsXmlHandlerTester statsFromXml(project, &reader, xmlFile);
StatisticsXmlHandlerTester statsFromXml(xmlFile);
qDebug() << "Min = " << statsFromXml.min();
qDebug() << "Max = " << statsFromXml.max();
qDebug() << "";
Expand Down
9 changes: 0 additions & 9 deletions isis/src/base/objs/Statistics/Statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ find files of those names at the top level of this repository. **/
#include "Project.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"
#include "XmlStackedHandlerReader.h"

using namespace std;

Expand All @@ -32,14 +31,6 @@ namespace Isis {
Reset(); // initialize
}


Statistics::Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent) { // TODO: does xml stuff need project???
// m_id = NULL;
SetValidRange();
Reset(); // initialize
xmlReader->pushContentHandler(new XmlHandler(this, project)); // TODO: does xml stuff need project???
}

/**
* Constructs a Statistics object from an input Pvl
*
Expand Down
2 changes: 0 additions & 2 deletions isis/src/base/objs/Statistics/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class QXmlStreamWriter;

namespace Isis {
class Project;// ??? does xml stuff need project???
class XmlStackedHandlerReader;
/**
* @brief This class is used to accumulate statistics on double arrays.
*
Expand Down Expand Up @@ -95,7 +94,6 @@ namespace Isis {
Q_OBJECT
public:
Statistics(QObject *parent = 0);
Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent = 0);
Statistics(const PvlGroup &inStats, QObject *parent = 0);
// TODO: does xml read/write stuff need Project input???
Statistics(const Statistics &other);
Expand Down
20 changes: 9 additions & 11 deletions isis/src/base/objs/Statistics/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ find files of those names at the top level of this repository. **/
#include <QDebug>
#include <QDataStream>
#include <QXmlStreamWriter>
#include <QXmlInputSource>

#include <iostream>

#include "FileName.h"
#include "IException.h"
#include "Preference.h"
#include "Statistics.h"
#include "XmlStackedHandlerReader.h"

using namespace std;
using namespace Isis;
Expand All @@ -33,8 +31,7 @@ using namespace Isis;
namespace Isis {
class StatisticsXmlHandlerTester : public Statistics {
public:
StatisticsXmlHandlerTester(Project *project, XmlStackedHandlerReader *reader,
FileName xmlFile) : Statistics(project, reader) {
StatisticsXmlHandlerTester(FileName xmlFile) : Statistics() {

QString xmlPath(xmlFile.expanded());
QFile file(xmlPath);
Expand All @@ -45,14 +42,16 @@ namespace Isis {
_FILEINFO_);
}

QXmlInputSource xmlInputSource(&file);
bool success = reader->parse(xmlInputSource);
if (!success) {
QXmlStreamReader reader(&file);

while (!reader.atEnd()) {
reader.readNext();
}
if (reader.hasError()) {
throw IException(IException::Unknown,
QString("Failed to parse xml file, [%1]").arg(xmlPath),
_FILEINFO_);
}

}

~StatisticsXmlHandlerTester() {
Expand Down Expand Up @@ -388,8 +387,7 @@ int main(int argc, char *argv[]) {
qXmlFile.close();
// read xml
qDebug() << "Testing XML: read XML to Statistics object...";
XmlStackedHandlerReader reader;
StatisticsXmlHandlerTester statsFromXml(project, &reader, xmlFile);
StatisticsXmlHandlerTester statsFromXml(xmlFile);
qDebug() << "Average: " << statsFromXml.Average();
qDebug() << "Variance: " << statsFromXml.Variance();
qDebug() << "Rms: " << statsFromXml.Rms();
Expand Down Expand Up @@ -421,7 +419,7 @@ int main(int argc, char *argv[]) {
// read xml with no attributes or values
qDebug() << "Testing XML: read XML with no attributes or values to Statistics object...";
FileName emptyXmlFile("./unitTest_NoElementValues.xml");
StatisticsXmlHandlerTester statsFromEmptyXml(project, &reader, emptyXmlFile);
StatisticsXmlHandlerTester statsFromEmptyXml(emptyXmlFile);
qDebug() << "Average: " << statsFromEmptyXml.Average();
qDebug() << "Variance: " << statsFromEmptyXml.Variance();
qDebug() << "Rms: " << statsFromEmptyXml.Rms();
Expand Down
28 changes: 3 additions & 25 deletions isis/src/control/objs/BundleResults/BundleResults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ find files of those names at the top level of this repository. **/
#include "SerialNumberList.h"
#include "StatCumProbDistDynCalc.h"
#include "Statistics.h"
#include "XmlStackedHandlerReader.h"

using namespace boost::numeric::ublas;

Expand All @@ -60,26 +59,6 @@ namespace Isis {
}


/**
* Construct this BundleResults object from XML.
*
* @param bundleSettingsFolder Where the settings XML for this bundle adjustment
* resides - /work/.../projectRoot/images/import1
* @param xmlReader An XML reader that's up to a <bundleSettings/> tag.
* @param parent The Qt-relationship parent.
*/
BundleResults::BundleResults(Project *project, XmlStackedHandlerReader *xmlReader,
QObject *parent) : QObject(parent) {
// TODO: does xml stuff need project???

initialize();

xmlReader->pushContentHandler(new XmlHandler(this, project));
xmlReader->setErrorHandler(new XmlHandler(this, project));

}


/**
* Copy constructor for BundleResults. Creates this BundleResults object as a copy
* of another BundleResults object.
Expand Down Expand Up @@ -2135,7 +2114,7 @@ namespace Isis {
else if (qName == "statisticsItem") {
// add statistics object to the xml handler's current statistics list.
m_xmlHandlerStatisticsList.append(
new Statistics(m_xmlHandlerProject, reader()));
new Statistics());
}
else if (qName == "elapsedTime") {
QString time = atts.value("time");
Expand Down Expand Up @@ -2340,12 +2319,11 @@ namespace Isis {
else if (qName == "cumulativeProbabilityCalculator") {
m_xmlHandlerBundleResults->m_cumPro = NULL;
m_xmlHandlerBundleResults->m_cumPro =
new StatCumProbDistDynCalc(m_xmlHandlerProject, reader());
new StatCumProbDistDynCalc();
}
else if (qName == "residualsCumulativeProbabilityCalculator") {
m_xmlHandlerBundleResults->m_cumProRes = NULL;
m_xmlHandlerBundleResults->m_cumProRes = new StatCumProbDistDynCalc(m_xmlHandlerProject,
reader());
m_xmlHandlerBundleResults->m_cumProRes = new StatCumProbDistDynCalc();
}
}
return true;
Expand Down
3 changes: 0 additions & 3 deletions isis/src/control/objs/BundleResults/BundleResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace Isis {
class PvlObject;
class SerialNumberList;
class StatCumProbDistDynCalc;
class XmlStackedHandlerReader;

/**
* A container class for statistical results from a BundleAdjust solution.
Expand Down Expand Up @@ -92,8 +91,6 @@ namespace Isis {
Q_OBJECT
public:
BundleResults(QObject *parent = 0);
// TODO: does xml stuff need project???
BundleResults(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent = 0);
BundleResults(const BundleResults &src);
~BundleResults();
BundleResults &operator=(const BundleResults &src);
Expand Down
22 changes: 9 additions & 13 deletions isis/src/control/objs/BundleResults/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ find files of those names at the top level of this repository. **/
#include <QString>
#include <QtDebug>
#include <QXmlStreamWriter>
#include <QXmlInputSource>

#include "BundleControlPoint.h"
#include "IsisBundleObservation.h"
Expand All @@ -29,7 +28,6 @@ find files of those names at the top level of this repository. **/
#include "MaximumLikelihoodWFunctions.h"
#include "Preference.h"
#include "PvlObject.h"
#include "XmlStackedHandlerReader.h"


using namespace std;
Expand All @@ -51,12 +49,9 @@ namespace Isis {
/**
* Constructs the tester object from an xml file.
*
* @param project The project object the tester belongs to.
* @param reader The XmlStackedHandlerReader that reads the xml file.
* @param xmlFile The xml file to construct the tester from.
*/
BundleResultsXmlHandlerTester(Project *project, XmlStackedHandlerReader *reader,
FileName xmlFile) : BundleResults(project, reader) {
BundleResultsXmlHandlerTester(FileName xmlFile) : BundleResults() {

m_file.setFileName(xmlFile.expanded());

Expand All @@ -66,14 +61,16 @@ namespace Isis {
_FILEINFO_);
}

QXmlInputSource xmlInputSource(&m_file);
bool success = reader->parse(xmlInputSource);
if (!success) {
QXmlStreamReader reader(&m_file);

while (!reader.atEnd()) {
reader.readNext();
}
if (reader.hasError()) {
throw IException(IException::Unknown,
QString("Failed to parse xml file, [%1]").arg(m_file.fileName()),
_FILEINFO_);
}

}

/**
Expand Down Expand Up @@ -330,8 +327,7 @@ int main(int argc, char *argv[]) {
qXmlFile.close();

qDebug() << "Testing XML: reading serialized BundleResults back in...";
XmlStackedHandlerReader reader;
BundleResultsXmlHandlerTester bsFromXml(project, &reader, xmlFile);
BundleResultsXmlHandlerTester bsFromXml(xmlFile);
qDebug() << "Testing XML: Object deserialized as (should match object above):";
printXml(bsFromXml);

Expand Down Expand Up @@ -381,7 +377,7 @@ int main(int argc, char *argv[]) {
qXmlFileR.close();

qDebug() << "Testing rectangular XML: reading serialized BundleResults back in...";
BundleResultsXmlHandlerTester bsRectFromXml(project, &reader, xmlFileR);
BundleResultsXmlHandlerTester bsRectFromXml(xmlFileR);
// Set the output control net in bsRectFromXml in order to get the desired coordinate type
bsRectFromXml.setOutputControlNet(ControlNetQsp(new ControlNet(outNet)));
qDebug() << "Testing rectangular XML: Object deserialized as (should match object above):";
Expand Down
Loading

0 comments on commit f3adebd

Please sign in to comment.