Commit 34d176ff authored by John Bonn's avatar John Bonn
Browse files

Added serialization changes for m4338

parent a4e5d788
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1667,6 +1667,7 @@ namespace Isis {
   */
  BundleResults::XmlHandler::XmlHandler(BundleResults *statistics, Project *project) {
    // TODO: does xml stuff need project???
    m_xmlHandlerCumProCalc = NULL;
    m_xmlHandlerBundleResults = NULL;
    m_xmlHandlerProject = NULL;

+24 −3
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@

namespace Isis {

  // initialize default filenames for csv output.
  const char BundleSolutionInfo::m_csvImagesFilename[] = "bundleout_images.csv";
  const char BundleSolutionInfo::m_csvPointsFilename[] = "bundleout_points.csv";
  const char BundleSolutionInfo::m_csvResidualsFilename[] = "residuals.csv";

  /**
   * Constructor. Creates a BundleSolutionInfo.
   *
@@ -164,6 +169,9 @@ namespace Isis {
    stream.writeTextElement("id", m_id->toString());
    stream.writeTextElement("runTime", runTime());
    stream.writeTextElement("fileName", m_controlNetworkFileName->expanded());
    stream.writeTextElement("imagesCSV", m_csvSavedImagesFilename);
    stream.writeTextElement("pointsCSV", m_csvSavedPointsFilename);
    stream.writeTextElement("residualsCSV", m_csvSavedResidualsFilename);
    stream.writeEndElement(); // end general attributes

    // save settings to stream
@@ -300,6 +308,16 @@ namespace Isis {
      assert(m_xmlHandlerBundleSolutionInfo->m_controlNetworkFileName == NULL);
      m_xmlHandlerBundleSolutionInfo->m_controlNetworkFileName = new FileName(m_xmlHandlerCharacters);
    }
    else if (localName == "imagesCSV") {
      m_xmlHandlerBundleSolutionInfo->m_csvSavedImagesFilename = m_xmlHandlerCharacters;
    }
    else if (localName == "pointsCSV") {
      m_xmlHandlerBundleSolutionInfo->m_csvSavedPointsFilename = m_xmlHandlerCharacters;
    }
    else if (localName == "residualsCSV") {
      m_xmlHandlerBundleSolutionInfo->m_csvSavedResidualsFilename = m_xmlHandlerCharacters;
    }

    m_xmlHandlerCharacters = "";
    return XmlStackedHandler::endElement(namespaceURI, localName, qName);
  }
@@ -1072,8 +1090,9 @@ namespace Isis {
    QList<Statistics> rmsImageLineResiduals = m_statisticsResults->rmsImageLineResiduals();
    QList<Statistics> rmsImageResiduals = m_statisticsResults->rmsImageResiduals();

    QString ofname = "bundleout_images.csv";
    QString ofname = m_csvImagesFilename;
    ofname = m_settings->outputFilePrefix() + ofname;
    m_csvSavedImagesFilename = ofname;

    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
    if (!fpOut) {
@@ -1333,8 +1352,9 @@ namespace Isis {
  bool BundleSolutionInfo::outputPointsCSV() {
    char buf[1056];

    QString ofname = "bundleout_points.csv";
    QString ofname = m_csvPointsFilename;
    ofname = m_settings->outputFilePrefix() + ofname;
    m_csvSavedPointsFilename = ofname;

    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
    if (!fpOut) {
@@ -1447,8 +1467,9 @@ namespace Isis {
  bool BundleSolutionInfo::outputResiduals() {
    char buf[1056];

    QString ofname = "residuals.csv";
    QString ofname = m_csvResidualsFilename;
    ofname = m_settings->outputFilePrefix() + ofname;
    m_csvSavedResidualsFilename = ofname;

    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
    if (!fpOut) {
+13 −0
Original line number Diff line number Diff line
@@ -180,6 +180,19 @@ namespace Isis {
      BundleSettingsQsp   m_settings; //!< The settings from the bundle adjust
      BundleResults      *m_statisticsResults; //!< The results of the bundle adjust
      QList<ImageList *> *m_images; //!< The list of images that were adjusted

      // Hard code these for now but we may allow setting them in future updates.
      // These are default names for the file.  The path comes from BundleSettings.
      static const char m_csvImagesFilename[];
      static const char m_csvPointsFilename[];
      static const char m_csvResidualsFilename[];

      // In theory the path in the BundlesSettings can change while running.  So we save the
      // filenames actually used when the most recent save of the file was done.
      QString m_csvSavedImagesFilename;
      QString m_csvSavedPointsFilename;
      QString m_csvSavedResidualsFilename;

  }; // end BundleSolutionInfo class


+205 −1
Original line number Diff line number Diff line
@@ -6,6 +6,192 @@ Serializing results from the settings/cnet/statistics constructor...
        
        <runTime></runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
            <validateNetwork>Yes</validateNetwork>
            <solveOptions solveObservationMode="No" solveRadius="No" updateCubeLabel="No" errorPropagation="No" createInverseMatrix="No"/>
            <aprioriSigmas latitude="N/A" longitude="N/A" radius="N/A"/>
            <outlierRejectionOptions rejection="No" multiplier="N/A"/>
            <convergenceCriteriaOptions convergenceCriteria="Sigma0" threshold="1.0e-10" maximumIterations="50"/>
            <maximumLikelihoodEstimation/>
            <outputFileOptions fileNamePrefix=""/>
        </globalSettings>
        <observationSolveSettingsList>
            <bundleObservationSolveSettings>
                
                <instrumentId></instrumentId>
                <instrumentPointingOptions solveOption="AnglesOnly" numberCoefSolved="1" degree="2" solveDegree="2" solveTwist="Yes" solveOverExisting="No" interpolationType="3">
                    <aprioriPointingSigmas>
                        <sigma>N/A</sigma>
                    </aprioriPointingSigmas>
                </instrumentPointingOptions>
                <instrumentPositionOptions solveOption="None" numberCoefSolved="0" degree="2" solveDegree="2" solveOverHermiteSpline="No" interpolationType="3">
                    <aprioriPositionSigmas/>
                </instrumentPositionOptions>
            </bundleObservationSolveSettings>
        </observationSolveSettingsList>
    </bundleSettings>
    <bundleResults>
        <correlationMatrix correlationFileName="" covarianceFileName="">
            <imagesAndParameters/>
        </correlationMatrix>
        <generalStatisticsValues>
            <numberFixedPoints>0</numberFixedPoints>
            <numberIgnoredPoints>0</numberIgnoredPoints>
            <numberHeldImages>0</numberHeldImages>
            <rejectionLimit>0.0</rejectionLimit>
            <numberRejectedObservations>0</numberRejectedObservations>
            <numberObservations>0</numberObservations>
            <numberImageParameters>0</numberImageParameters>
            <numberConstrainedPointParameters>0</numberConstrainedPointParameters>
            <numberConstrainedImageParameters>0</numberConstrainedImageParameters>
            <numberConstrainedTargetParameters>0</numberConstrainedTargetParameters>
            <numberUnknownParameters>0</numberUnknownParameters>
            <degreesOfFreedom>-1</degreesOfFreedom>
            <sigma0>0.0</sigma0>
            <converged>No</converged>
        </generalStatisticsValues>
        <rms>
            <residuals x="0.0" y="0.0" xy="0.0"/>
            <sigmas lat="0.0" lon="0.0" rad="0.0"/>
            <imageResidualsLists>
                <residualsList listSize="0"/>
                <sampleList listSize="0"/>
                <lineList listSize="0"/>
            </imageResidualsLists>
            <imageSigmasLists>
                <xSigmas listSize="0"/>
                <ySigmas listSize="0"/>
                <zSigmas listSize="0"/>
                <raSigmas listSize="0"/>
                <decSigmas listSize="0"/>
                <twistSigmas listSize="0"/>
            </imageSigmasLists>
        </rms>
        <elapsedTime time="0.0" errorProp="0.0"/>
        <minMaxSigmas>
            <minLat value="1000000000000.0" pointId=""/>
            <maxLat value="0.0" pointId=""/>
            <minLon value="1000000000000.0" pointId=""/>
            <maxLon value="0.0" pointId=""/>
            <minRad value="1000000000000.0" pointId=""/>
            <maxRad value="0.0" pointId=""/>
        </minMaxSigmas>
        <maximumLikelihoodEstimation numberModels="0" maximumLikelihoodIndex="0" maximumLikelihoodMedianR2Residuals="0.0">
            <cumulativeProbabilityCalculator/>
            <residualsCumulativeProbabilityCalculator/>
        </maximumLikelihoodEstimation>
    </bundleResults>
</bundleSolutionInfo> 



Testing XML serialization 1: round trip serialization of BundleSolution object...
Serializing test XML object to file...

<bundleSolutionInfo>
    <generalAttributes>
        
        <runTime></runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
            <validateNetwork>Yes</validateNetwork>
            <solveOptions solveObservationMode="No" solveRadius="No" updateCubeLabel="No" errorPropagation="No" createInverseMatrix="No"/>
            <aprioriSigmas latitude="N/A" longitude="N/A" radius="N/A"/>
            <outlierRejectionOptions rejection="No" multiplier="N/A"/>
            <convergenceCriteriaOptions convergenceCriteria="Sigma0" threshold="1.0e-10" maximumIterations="50"/>
            <maximumLikelihoodEstimation/>
            <outputFileOptions fileNamePrefix=""/>
        </globalSettings>
        <observationSolveSettingsList>
            <bundleObservationSolveSettings>
                
                <instrumentId></instrumentId>
                <instrumentPointingOptions solveOption="AnglesOnly" numberCoefSolved="1" degree="2" solveDegree="2" solveTwist="Yes" solveOverExisting="No" interpolationType="3">
                    <aprioriPointingSigmas>
                        <sigma>N/A</sigma>
                    </aprioriPointingSigmas>
                </instrumentPointingOptions>
                <instrumentPositionOptions solveOption="None" numberCoefSolved="0" degree="2" solveDegree="2" solveOverHermiteSpline="No" interpolationType="3">
                    <aprioriPositionSigmas/>
                </instrumentPositionOptions>
            </bundleObservationSolveSettings>
        </observationSolveSettingsList>
    </bundleSettings>
    <bundleResults>
        <correlationMatrix correlationFileName="" covarianceFileName="">
            <imagesAndParameters/>
        </correlationMatrix>
        <generalStatisticsValues>
            <numberFixedPoints>0</numberFixedPoints>
            <numberIgnoredPoints>0</numberIgnoredPoints>
            <numberHeldImages>0</numberHeldImages>
            <rejectionLimit>0.0</rejectionLimit>
            <numberRejectedObservations>0</numberRejectedObservations>
            <numberObservations>0</numberObservations>
            <numberImageParameters>0</numberImageParameters>
            <numberConstrainedPointParameters>0</numberConstrainedPointParameters>
            <numberConstrainedImageParameters>0</numberConstrainedImageParameters>
            <numberConstrainedTargetParameters>0</numberConstrainedTargetParameters>
            <numberUnknownParameters>0</numberUnknownParameters>
            <degreesOfFreedom>-1</degreesOfFreedom>
            <sigma0>0.0</sigma0>
            <converged>No</converged>
        </generalStatisticsValues>
        <rms>
            <residuals x="0.0" y="0.0" xy="0.0"/>
            <sigmas lat="0.0" lon="0.0" rad="0.0"/>
            <imageResidualsLists>
                <residualsList listSize="0"/>
                <sampleList listSize="0"/>
                <lineList listSize="0"/>
            </imageResidualsLists>
            <imageSigmasLists>
                <xSigmas listSize="0"/>
                <ySigmas listSize="0"/>
                <zSigmas listSize="0"/>
                <raSigmas listSize="0"/>
                <decSigmas listSize="0"/>
                <twistSigmas listSize="0"/>
            </imageSigmasLists>
        </rms>
        <elapsedTime time="0.0" errorProp="0.0"/>
        <minMaxSigmas>
            <minLat value="1000000000000.0" pointId=""/>
            <maxLat value="0.0" pointId=""/>
            <minLon value="1000000000000.0" pointId=""/>
            <maxLon value="0.0" pointId=""/>
            <minRad value="1000000000000.0" pointId=""/>
            <maxRad value="0.0" pointId=""/>
        </minMaxSigmas>
        <maximumLikelihoodEstimation numberModels="0" maximumLikelihoodIndex="0" maximumLikelihoodMedianR2Residuals="0.0">
            <cumulativeProbabilityCalculator/>
            <residualsCumulativeProbabilityCalculator/>
        </maximumLikelihoodEstimation>
    </bundleResults>
</bundleSolutionInfo> 


Testing XML: reading serialized BundleResults back in...
Testing XML: Object deserialized as (should match object above):

<bundleSolutionInfo>
    <generalAttributes>
        
        <runTime></runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
@@ -93,6 +279,9 @@ Testing copy constructor...
        
        <runTime></runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
@@ -180,6 +369,9 @@ Testing assignment operator to set this equal to itself...
        
        <runTime></runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
@@ -267,6 +459,9 @@ Testing assignment operator to create a new results object...
        
        <runTime></runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
@@ -354,6 +549,9 @@ Testing mutator methods...
        
        <runTime>xxx</runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV></imagesCSV>
        <pointsCSV></pointsCSV>
        <residualsCSV></residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
@@ -444,7 +642,7 @@ Testing error throws...

Testing output methods

Testing XML serialization 1: round trip serialization of fully populated BundleSolution object...
Testing XML serialization 2: round trip serialization of fully populated BundleSolution object...
Serializing test XML object to file...

<bundleSolutionInfo>
@@ -452,6 +650,9 @@ Serializing test XML object to file...
        
        <runTime>xxx</runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV>bundleout_images.csv</imagesCSV>
        <pointsCSV>bundleout_points.csv</pointsCSV>
        <residualsCSV>residuals.csv</residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
@@ -551,6 +752,9 @@ Testing XML: Object deserialized as (should match object above):
        
        <runTime>xxx</runTime>
        <fileName>cnetfile.net</fileName>
        <imagesCSV>bundleout_images.csv</imagesCSV>
        <pointsCSV>bundleout_points.csv</pointsCSV>
        <residualsCSV>residuals.csv</residualsCSV>
    </generalAttributes>
    <bundleSettings>
        <globalSettings>
+43 −15
Original line number Diff line number Diff line
@@ -141,6 +141,35 @@ int main(int argc, char *argv[]) {

    printXml(results);


    qDebug() << "";
    qDebug() << "Testing XML serialization 1: round trip serialization of BundleSolution object...";
    qDebug() << "Serializing test XML object to file...";
    printXml(results);    // save XML to test log for comparison
    FileName xmlFile1("./BundleSolutionInfo1.xml");
    QString xmlPath1 = xmlFile1.expanded();
    QFile qXmlFile1(xmlPath1);
    if (!qXmlFile1.open(QIODevice::WriteOnly|QIODevice::Text)) {
      throw IException(IException::Io,
                       QString("Unable to open xml file, [%1],  with write access").arg(xmlPath1),
                       _FILEINFO_);
    }
    QXmlStreamWriter writer(&qXmlFile1);
    writer.setAutoFormatting(true);
    writer.writeStartDocument();
    Project *project = NULL;
    results.save(writer, project);
    writer.writeEndDocument();
    qXmlFile1.close();

    qDebug() << "Testing XML: reading serialized BundleResults back in...";
    XmlStackedHandlerReader reader1;
    BundleSolutionInfoXmlHandlerTester bsFromXml1(project, &reader1, xmlFile1);
    qDebug() << "Testing XML: Object deserialized as (should match object above):";
    printXml(bsFromXml1);  // Save comparison output to log file



    qDebug() << "Testing copy constructor...";

    BundleSolutionInfo copySolutionInfo(results);
@@ -260,30 +289,29 @@ int main(int argc, char *argv[]) {


    qDebug() << "";
    qDebug() << "Testing XML serialization 1: round trip serialization of fully populated BundleSolution object...";
    qDebug() << "Testing XML serialization 2: round trip serialization of fully populated BundleSolution object...";
    qDebug() << "Serializing test XML object to file...";
    printXml(results);    // save XML to test log for comparison
    FileName xmlFile("./BundleSolutionInfo.xml");
    QString xmlPath = xmlFile.expanded();
    QFile qXmlFile(xmlPath);
    if (!qXmlFile.open(QIODevice::WriteOnly|QIODevice::Text)) {
    FileName xmlFile2("./BundleSolutionInfo2.xml");
    QString xmlPath2 = xmlFile2.expanded();
    QFile qXmlFile2(xmlPath2);
    if (!qXmlFile2.open(QIODevice::WriteOnly|QIODevice::Text)) {
      throw IException(IException::Io,
                       QString("Unable to open xml file, [%1],  with write access").arg(xmlPath),
                       QString("Unable to open xml file, [%1],  with write access").arg(xmlPath2),
                       _FILEINFO_);
    }
    QXmlStreamWriter writer(&qXmlFile);
    writer.setAutoFormatting(true);
    writer.writeStartDocument();
    Project *project = NULL;
    results.save(writer, project);
    writer.writeEndDocument();
    qXmlFile.close();
    QXmlStreamWriter writer2(&qXmlFile2);
    writer2.setAutoFormatting(true);
    writer2.writeStartDocument();
    results.save(writer2, project);
    writer2.writeEndDocument();
    qXmlFile2.close();

    qDebug() << "Testing XML: reading serialized BundleResults back in...";
    XmlStackedHandlerReader reader;
    BundleSolutionInfoXmlHandlerTester bsFromXml(project, &reader, xmlFile);
    BundleSolutionInfoXmlHandlerTester bsFromXml2(project, &reader, xmlFile2);
    qDebug() << "Testing XML: Object deserialized as (should match object above):";
    printXml(bsFromXml);  // Save comparison output to log file
    printXml(bsFromXml2);  // Save comparison output to log file


    qDebug() << "";