9#include "BundleSolutionInfo.h" 
   18#include <QXmlStreamWriter> 
   20#include "BundleLidarRangeConstraint.h" 
   21#include "BundleResults.h" 
   23#include "ControlList.h" 
   24#include "ControlMeasure.h" 
   25#include "ControlNet.h" 
   26#include "ControlPoint.h" 
   32#include "PvlKeyword.h" 
   34#include "StatCumProbDistDynCalc.h" 
   35#include "Statistics.h" 
   36#include "XmlStackedHandlerReader.h" 
   51                                         QList<ImageList *> imgList,
 
   53    m_id = 
new QUuid(QUuid::createUuid());
 
   58    m_outputControlName=
"";
 
   63    m_images = 
new QList<ImageList *>(imgList);
 
 
   80                                         QList<ImageList *> imgList,
 
   82    m_id = 
new QUuid(QUuid::createUuid());
 
   87    m_outputControlName=
"";
 
   92    m_images = 
new QList<ImageList *>(imgList);
 
 
  104  BundleSolutionInfo::BundleSolutionInfo(
Project *project,
 
  108    m_id = 
new QUuid(QUuid::createUuid());
 
  113    m_outputControlName=
"";
 
  121    xmlReader->setErrorHandler(
new XmlHandler(
this, project));
 
  122    xmlReader->pushContentHandler(
new XmlHandler(
this, project));
 
 
  167    return m_txtBundleOutputFilename;
 
 
  177    return m_csvSavedImagesFilename;
 
 
  187    return m_csvSavedPointsFilename;
 
 
  197    return m_csvSavedResidualsFilename;
 
 
  241                     oldInputFileName.dir().dirName() + 
"/" + oldInputFileName.name());
 
  246                     oldOutputFileName.dir().dirName() + 
"/" + oldOutputFileName.name());
 
  252    m_outputControlName = newOutputFileName.expanded();
 
 
  273    return m_id->toString().remove(QRegExp(
"[{}]"));
 
 
  329      return m_outputControlName;
 
 
  359    m_outputControlName = 
name;
 
 
  369    return m_outputControlName;
 
 
  405                       "Results for this bundle is NULL.",
 
 
  462    std::vector<QString> outputColumns;
 
  464    outputColumns.push_back(
"Image,");
 
  465    outputColumns.push_back(
"rms,");
 
  466    outputColumns.push_back(
"rms,");
 
  467    outputColumns.push_back(
"rms,");
 
  469    QStringList observationParameters = observation->parameterList();
 
  471    for (
int i = 0; i < observationParameters.size(); i++) {
 
  472      for (
int j = 0; j < 5; j++) {
 
  473        outputColumns.push_back(observationParameters[i] + 
",");
 
  478    int ncolumns = outputColumns.size();
 
  479    for (
int i = 0; i < ncolumns; i++) {
 
  480      QString str = outputColumns.at(i);
 
  481      snprintf(buf, 
sizeof(buf), 
"%s", (
const char*)str.toLatin1().data());
 
  484    snprintf(buf, 
sizeof(buf), 
"\n");
 
  487    outputColumns.clear();
 
  489    outputColumns.push_back(
"Filename,");
 
  490    outputColumns.push_back(
"sample res,");
 
  491    outputColumns.push_back(
"line res,");
 
  492    outputColumns.push_back(
"total res,");
 
  494    for (
int i = 0; i < observationParameters.size(); i++) {
 
  495      outputColumns.push_back(
"Initial,");
 
  496      outputColumns.push_back(
"Correction,");
 
  497      outputColumns.push_back(
"Final,");
 
  498      outputColumns.push_back(
"Apriori Sigma,");
 
  499      outputColumns.push_back(
"Adj Sigma,");
 
  503    ncolumns = outputColumns.size();
 
  504    for (
int i = 0; i < ncolumns; i++) {
 
  505      QString str = outputColumns.at(i);
 
  506      snprintf(buf, 
sizeof(buf), 
"%s", (
const char*)str.toLatin1().data());
 
  509    snprintf(buf, 
sizeof(buf), 
"\n");
 
 
  540    for (
int i = 0; i < numObservations; i++) {
 
  545    int numValidLidarPoints = 0;
 
  547      numValidLidarPoints = lidarData->numberLidarPoints();
 
  550    int numInnerConstraints = 0;
 
  551    int numDistanceConstraints = 0;
 
  554    int convergenceCriteria = 1;
 
  556    snprintf(buf, 
sizeof(buf), 
"JIGSAW: BUNDLE ADJUSTMENT\n=========================\n");
 
  558    snprintf(buf, 
sizeof(buf), 
"\n                       Run Time: %s",
 
  561    snprintf(buf, 
sizeof(buf), 
"\n                       Network Filename: %s",
 
  565    snprintf(buf, 
sizeof(buf),
"\n                       Cube List: %s",
 
  566                m_settings->cubeList().toStdString().c_str() );
 
  570    snprintf(buf, 
sizeof(buf), 
"\n                       Output Network Filename: %s",
 
  573    snprintf(buf, 
sizeof(buf),
"\n                       Output File Prefix: %s",
 
  574                m_settings->outputFilePrefix().toStdString().c_str() );
 
  577    snprintf(buf, 
sizeof(buf), 
"\n                       Network Id: %s",
 
  580    snprintf(buf, 
sizeof(buf), 
"\n                       Network Description: %s",\
 
  584      snprintf(buf, 
sizeof(buf), 
"\n            Lidar Data Filename: %s",
 
  588    snprintf(buf, 
sizeof(buf), 
"\n                       Target: %s",
 
  591    snprintf(buf, 
sizeof(buf), 
"\n\n                       Linear Units: kilometers");
 
  593    snprintf(buf, 
sizeof(buf), 
"\n                       Angular Units: decimal degrees");
 
  595    snprintf(buf, 
sizeof(buf), 
"\n\nINPUT: SOLVE OPTIONS\n====================\n");
 
  599      snprintf(buf, 
sizeof(buf), 
"\n                   OBSERVATIONS: ON"):
 
  600      snprintf(buf, 
sizeof(buf), 
"\n                   OBSERVATIONS: OFF");
 
  604      snprintf(buf, 
sizeof(buf), 
"\n                         RADIUS: ON"):
 
  605      snprintf(buf, 
sizeof(buf), 
"\n                         RADIUS: OFF");
 
  609      snprintf(buf, 
sizeof(buf), 
"\n                    TARGET BODY: ON"):
 
  610      snprintf(buf, 
sizeof(buf), 
"\n                    TARGET BODY: OFF");
 
  614      snprintf(buf, 
sizeof(buf), 
"\n                         UPDATE: YES"):
 
  615      snprintf(buf, 
sizeof(buf), 
"\n                         UPDATE: NO");
 
  619      snprintf(buf, 
sizeof(buf), 
"\n              ERROR PROPAGATION: ON"):
 
  620      snprintf(buf, 
sizeof(buf), 
"\n              ERROR PROPAGATION: OFF");
 
  624      snprintf(buf, 
sizeof(buf), 
"\n  CONTROL POINT COORDINATE TYPE FOR REPORTS: LATITUDINAL"):
 
  625      snprintf(buf, 
sizeof(buf), 
"\n  CONTROL POINT COORDINATE TYPE FOR REPORTS: RECTANGULAR");
 
  629      snprintf(buf, 
sizeof(buf), 
"\n  CONTROL POINT COORDINATE TYPE FOR BUNDLE: LATITUDINAL"):
 
  630      snprintf(buf, 
sizeof(buf), 
"\n  CONTROL POINT COORDINATE TYPE FOR BUNDLE: RECTANGULAR");
 
  634      snprintf(buf, 
sizeof(buf), 
"\n              OUTLIER REJECTION: ON");
 
  636      snprintf(buf, 
sizeof(buf), 
"\n           REJECTION MULTIPLIER: %lf",
 
  642      snprintf(buf, 
sizeof(buf), 
"\n              OUTLIER REJECTION: OFF");
 
  644      snprintf(buf, 
sizeof(buf), 
"\n           REJECTION MULTIPLIER: N/A");
 
  649    snprintf(buf, 
sizeof(buf), 
"\n              CONTROL POINT COORDINATE TYPE FOR REPORTS:  %s",
 
  653    snprintf(buf, 
sizeof(buf), 
"\n              CONTROL POINT COORDINATE TYPE FOR BUNDLE:  %s",
 
  656    snprintf(buf, 
sizeof(buf), 
"\n\nMAXIMUM LIKELIHOOD ESTIMATION\n============================\n");
 
  659    for (
int tier = 0; tier < 3; tier++) {
 
  660      if (tier < m_statisticsResults->numberMaximumLikelihoodModels()) {
 
  661        snprintf(buf, 
sizeof(buf), 
"\n                         Tier %d Enabled: TRUE", tier);
 
  663        snprintf(buf, 
sizeof(buf), 
"\n               Maximum Likelihood Model: %s",
 
  666                              maximumLikelihoodModelWFunc(tier).model()).toLatin1().data());
 
  668        snprintf(buf, 
sizeof(buf), 
"\n    Quantile used for tweaking constant: %lf",
 
  671        snprintf(buf, 
sizeof(buf), 
"\n   Quantile weighted R^2 Residual value: %lf",
 
  674        snprintf(buf, 
sizeof(buf), 
"\n       Approx. weighted Residual cutoff: %s",
 
  678        if (tier != 2) fpOut << 
"\n";
 
  681        snprintf(buf, 
sizeof(buf), 
"\n                         Tier %d Enabled: FALSE", tier);
 
  686    snprintf(buf, 
sizeof(buf), 
"\n\nINPUT: CONVERGENCE CRITERIA\n===========================\n");
 
  688    snprintf(buf, 
sizeof(buf), 
"\n                         SIGMA0: %e",
 
  691    snprintf(buf, 
sizeof(buf), 
"\n             MAXIMUM ITERATIONS: %d",
 
  692                  m_settings->convergenceCriteriaMaximumIterations());
 
  701    int pointingSolveDegree = globalSettings.numberCameraAngleCoefficientsSolved();
 
  702    QList<double> pointingSigmas = globalSettings.aprioriPointingSigmas();
 
  703    int positionSolveDegree = globalSettings.numberCameraPositionCoefficientsSolved();
 
  704    QList<double> positionSigmas = globalSettings.aprioriPositionSigmas();
 
  706    snprintf(buf, 
sizeof(buf), 
"\n\nINPUT: CAMERA POINTING OPTIONS\n==============================\n");
 
  708    switch (pointingSolveDegree) {
 
  710        snprintf(buf, 
sizeof(buf),
"\n                          CAMSOLVE: NONE");
 
  713        snprintf(buf, 
sizeof(buf),
"\n                          CAMSOLVE: ANGLES");
 
  716        snprintf(buf, 
sizeof(buf),
"\n                          CAMSOLVE: ANGLES, VELOCITIES");
 
  719        snprintf(buf, 
sizeof(buf),
"\n                          CAMSOLVE: ANGLES, VELOCITIES, ACCELERATIONS");
 
  722        snprintf(buf, 
sizeof(buf),
"\n                          CAMSOLVE: ALL POLYNOMIAL COEFFICIENTS (%d)" 
  724                    "\n                     CKSOLVEDEGREE: %d",
 
  726                globalSettings.ckDegree(),
 
  727                globalSettings.ckSolveDegree());
 
  731    globalSettings.solveTwist() ?
 
  732        snprintf(buf, 
sizeof(buf), 
"\n                             TWIST: ON"):
 
  733        snprintf(buf, 
sizeof(buf), 
"\n                             TWIST: OFF");
 
  735    globalSettings.solvePolyOverPointing() ?
 
  736        snprintf(buf, 
sizeof(buf), 
"\n POLYNOMIAL OVER EXISTING POINTING: ON"):
 
  737        snprintf(buf, 
sizeof(buf), 
"\nPOLYNOMIAL OVER EXISTING POINTING : OFF");
 
  740    snprintf(buf, 
sizeof(buf), 
"\n\nINPUT: SPACECRAFT OPTIONS\n=========================\n");
 
  742    switch (positionSolveDegree) {
 
  744        snprintf(buf, 
sizeof(buf),
"\n                        SPSOLVE: NONE");
 
  747        snprintf(buf, 
sizeof(buf),
"\n                        SPSOLVE: POSITION");
 
  750        snprintf(buf, 
sizeof(buf),
"\n                        SPSOLVE: POSITION, VELOCITIES");
 
  753        snprintf(buf, 
sizeof(buf),
"\n                        SPSOLVE: POSITION, VELOCITIES, ACCELERATIONS");
 
  756        snprintf(buf, 
sizeof(buf),
"\n                        SPSOLVE: ALL POLYNOMIAL COEFFICIENTS (%d)" 
  758                    "\n                 SPKSOLVEDEGREE: %d",
 
  760                globalSettings.spkDegree(),
 
  761                globalSettings.spkSolveDegree());
 
  765    globalSettings.solvePositionOverHermite() ?
 
  766        snprintf(buf, 
sizeof(buf), 
"\n POLYNOMIAL OVER HERMITE SPLINE: ON"):
 
  767        snprintf(buf, 
sizeof(buf), 
"\nPOLYNOMIAL OVER HERMITE SPLINE : OFF");
 
  770    snprintf(buf, 
sizeof(buf), 
"\n\nINPUT: GLOBAL IMAGE PARAMETER UNCERTAINTIES\n===========================================\n");
 
  774    switch (
m_settings->controlPointCoordTypeReports()) {
 
  776        coord1Str = 
"LATITUDE";
 
  777        coord2Str = 
"LONGITUDE";
 
  778        coord3Str = 
"RADIUS";
 
  786         IString msg =
"Unknown surface point coordinate type enum [" 
  795      snprintf(buf, 
sizeof(buf),
"\n               POINT %s SIGMA: N/A", coord1Str.toLatin1().data()):
 
  796      snprintf(buf, 
sizeof(buf),
"\n               POINT %s SIGMA: %lf (meters)", coord1Str.toLatin1().data(),
 
  801      snprintf(buf, 
sizeof(buf),
"\n              POINT %s SIGMA: N/A", coord2Str.toLatin1().data()):
 
  802      snprintf(buf, 
sizeof(buf),
"\n              POINT %s SIGMA: %lf (meters)", coord2Str.toLatin1().data(),
 
  807      snprintf(buf, 
sizeof(buf),
"\n                 POINT %s SIGMA: N/A", coord3Str.toLatin1().data()):
 
  808      snprintf(buf, 
sizeof(buf),
"\n                 POINT %s SIGMA: %lf (meters)", coord3Str.toLatin1().data(),
 
  811    (positionSolveDegree < 1 || positionSigmas[0] == 
Isis::Null) ?
 
  812        snprintf(buf, 
sizeof(buf),
"\n          SPACECRAFT POSITION SIGMA: N/A"):
 
  813        snprintf(buf, 
sizeof(buf),
"\n          SPACECRAFT POSITION SIGMA: %lf (meters)",
 
  817    (positionSolveDegree < 2 || positionSigmas[1] == 
Isis::Null) ?
 
  818        snprintf(buf, 
sizeof(buf),
"\n          SPACECRAFT VELOCITY SIGMA: N/A"):
 
  819        snprintf(buf, 
sizeof(buf),
"\n          SPACECRAFT VELOCITY SIGMA: %lf (m/s)",
 
  823    (positionSolveDegree < 3 || positionSigmas[2] == 
Isis::Null) ?
 
  824        snprintf(buf, 
sizeof(buf),
"\n      SPACECRAFT ACCELERATION SIGMA: N/A"):
 
  825        snprintf(buf, 
sizeof(buf),
"\n      SPACECRAFT ACCELERATION SIGMA: %lf (m/s/s)",
 
  829    (pointingSolveDegree < 1 || pointingSigmas[0] == 
Isis::Null) ?
 
  830        snprintf(buf, 
sizeof(buf),
"\n                CAMERA ANGLES SIGMA: N/A"):
 
  831        snprintf(buf, 
sizeof(buf),
"\n                CAMERA ANGLES SIGMA: %lf (dd)",
 
  835    (pointingSolveDegree < 2 || pointingSigmas[1] == 
Isis::Null) ?
 
  836        snprintf(buf, 
sizeof(buf),
"\n      CAMERA ANGULAR VELOCITY SIGMA: N/A"):
 
  837        snprintf(buf, 
sizeof(buf),
"\n      CAMERA ANGULAR VELOCITY SIGMA: %lf (dd/s)",
 
  841    (pointingSolveDegree < 3 || pointingSigmas[2] == 
Isis::Null) ?
 
  842        snprintf(buf, 
sizeof(buf),
"\n  CAMERA ANGULAR ACCELERATION SIGMA: N/A"):
 
  843        snprintf(buf, 
sizeof(buf),
"\n  CAMERA ANGULAR ACCELERATION SIGMA: %lf (dd/s/s)",
 
  848      snprintf(buf, 
sizeof(buf), 
"\n\nINPUT: TARGET BODY OPTIONS\n==============================\n");
 
  852        snprintf(buf, 
sizeof(buf),
"\n                             POLE: RIGHT ASCENSION");
 
  854        snprintf(buf, 
sizeof(buf),
"\n                                 : DECLINATION\n");
 
  858        snprintf(buf, 
sizeof(buf),
"\n                             POLE: RIGHT ASCENSION\n");
 
  862        snprintf(buf, 
sizeof(buf),
"\n                             POLE: DECLINATION\n");
 
  868        snprintf(buf, 
sizeof(buf),
"\n                   PRIME MERIDIAN: W0 (OFFSET)");
 
  872          snprintf(buf, 
sizeof(buf),
"\n                                 : WDOT (SPIN RATE)");
 
  876          snprintf(buf, 
sizeof(buf),
"\n                               :W ACCELERATION");
 
  883          snprintf(buf, 
sizeof(buf),
"\n                            RADII: MEAN");
 
  887          snprintf(buf, 
sizeof(buf),
"\n                            RADII: TRIAXIAL");
 
  893    snprintf(buf, 
sizeof(buf), 
"\n\nJIGSAW: RESULTS\n===============\n");
 
  895    snprintf(buf, 
sizeof(buf), 
"\n                         Images: %6d",numImages);
 
  897    snprintf(buf, 
sizeof(buf), 
"\n                         Points: %6d",numValidPoints);
 
  900    if (numValidLidarPoints > 0) {
 
  901      snprintf(buf, 
sizeof(buf), 
"\n                   Lidar Points: %6d",numValidLidarPoints);
 
  905    snprintf(buf, 
sizeof(buf), 
"\n                 Total Measures: %6d",
 
  910    snprintf(buf, 
sizeof(buf), 
"\n             Total Observations: %6d",
 
  915    snprintf(buf, 
sizeof(buf), 
"\n              Good Observations: %6d",
 
  919    snprintf(buf, 
sizeof(buf), 
"\n          Rejected Observations: %6d",
 
  924      snprintf(buf, 
sizeof(buf), 
"\n   Constrained Point Parameters: %6d",
 
  930      snprintf(buf, 
sizeof(buf), 
"\n   Constrained Image Parameters: %6d",
 
  936      snprintf(buf, 
sizeof(buf), 
"\n  Constrained Target Parameters: %6d",
 
  942      snprintf(buf, 
sizeof(buf), 
"\n        Lidar Range Constraints: %6d",
 
  947    snprintf(buf, 
sizeof(buf), 
"\n                       Unknowns: %6d",
 
  951    if (numInnerConstraints > 0) {
 
  952      snprintf(buf, 
sizeof(buf), 
"\n      Inner Constraints: %6d", numInnerConstraints);
 
  956    if (numDistanceConstraints > 0) {
 
  957      snprintf(buf, 
sizeof(buf), 
"\n   Distance Constraints: %d", numDistanceConstraints);
 
  961    snprintf(buf, 
sizeof(buf), 
"\n             Degrees of Freedom: %6d", numDegreesOfFreedom);
 
  964    snprintf(buf, 
sizeof(buf), 
"\n           Convergence Criteria: %6.3g",
 
  968    if (convergenceCriteria == 1) {
 
  969      snprintf(buf, 
sizeof(buf), 
"(Sigma0)");
 
  977      snprintf(buf, 
sizeof(buf), 
"(Maximum reached)");
 
  983    snprintf(buf, 
sizeof(buf), 
" Error Propagation Elapsed Time: %6.4lf (seconds)\n",
 
  986    snprintf(buf, 
sizeof(buf), 
"             Total Elapsed Time: %6.4lf (seconds)\n",
 
  992      snprintf(buf, 
sizeof(buf), 
"\n           Residual Percentiles:\n");
 
  998        for (
int bin = 1;bin < 34;bin++) {
 
  999          double cumProb = double(bin) / 100.0;
 
 1002                  residualsCumulativeProbabilityDistribution().value(cumProb);
 
 1005                  residualsCumulativeProbabilityDistribution().value(cumProb + 0.33);
 
 1008                  residualsCumulativeProbabilityDistribution().value(cumProb + 0.66);
 
 1009          snprintf(buf, 
sizeof(buf), 
"                 Percentile %3d: %+8.3lf" 
 1010                       "                 Percentile %3d: %+8.3lf" 
 1011                       "                 Percentile %3d: %+8.3lf\n",
 
 1013                                         bin + 33, resValue33,
 
 1014                                         bin + 66, resValue66);
 
 1019        QString msg = 
"Failed to output residual percentiles for bundleout";
 
 1023        snprintf(buf, 
sizeof(buf), 
"\n              Residual Box Plot:");
 
 1025        snprintf(buf, 
sizeof(buf), 
"\n                        minimum: %+8.3lf",
 
 1028        snprintf(buf, 
sizeof(buf), 
"\n                     Quartile 1: %+8.3lf",
 
 1031        snprintf(buf, 
sizeof(buf), 
"\n                         Median: %+8.3lf",
 
 1034        snprintf(buf, 
sizeof(buf), 
"\n                     Quartile 3: %+8.3lf",
 
 1037        snprintf(buf, 
sizeof(buf), 
"\n                        maximum: %+8.3lf\n",
 
 1042        QString msg = 
"Failed to output residual box plot for bundleout";
 
 1049    int filePadding = 0;
 
 1051    for (
int i = 0; i < numObservations; i++) {
 
 1055      for (
int j = 0; j < numImagesInObservation; j++) {
 
 1058        if (bundleImage->fileName().length() > filePadding) {
 
 1059          filePadding = bundleImage->fileName().length();
 
 1064    snprintf(buf, 
sizeof(buf), 
"\nIMAGE MEASURES SUMMARY\n==========================\n\n");
 
 1069    QString header(
"Measures                            RMS(pixels)");
 
 1071      header += 
"                                   Lidar RMS(pixels)";
 
 1074    snprintf(buf, 
sizeof(buf),
"%*s\n", header.length() + 11 + filePadding, header.toLatin1().data());
 
 1077    QString dividers(
"***************************   *******************************************");
 
 1079      dividers += 
"   *******************************************";
 
 1081    snprintf(buf, 
sizeof(buf),
"%*s\n", dividers.length() + 1 + filePadding, dividers.toLatin1().data());
 
 1084    QString fields(
"|  Accepted  |   Total    |   |   Samples   |    Lines    |    Total    |");
 
 1086      fields += 
"   |   Samples   |    Lines    |    Total    |";
 
 1088    snprintf(buf, 
sizeof(buf),
"%*s\n", fields.length() + 1 + filePadding, fields.toLatin1().data());
 
 1091    int numMeasures, numLidarMeasures;
 
 1092    int numRejectedMeasures, numLidarRejectedMeasures;
 
 1093    int numUsed, numLidarUsed;
 
 1095    Statistics rmsSamplesTotal,rmsLinesTotal,rmsTotals;
 
 1097    for (
int i = 0; i < numObservations; i++) {
 
 1101      for (
int j = 0; j < numImagesInObservation; j++) {
 
 1106                                        rmsImageSampleResiduals()[imageIndex].Rms();
 
 1108                                        rmsImageLineResiduals()[imageIndex].Rms();
 
 1110                                        rmsImageResiduals()[imageIndex].Rms();
 
 1111        rmsSamplesTotal.AddData(rmsSampleResiduals);
 
 1112        rmsLinesTotal.AddData(rmsLineResiduals);
 
 1113        rmsTotals.AddData(rmsLandSResiduals);
 
 1116            (bundleImage->serialNumber());
 
 1119            GetNumberOfJigsawRejectedMeasuresInImage(bundleImage->serialNumber());
 
 1121        numUsed = numMeasures - numRejectedMeasures;
 
 1123        QString filename = bundleImage->fileName();
 
 1125        List = filename.split(
"/");
 
 1127        snprintf(buf, 
sizeof(buf),
"%-*s" ,filePadding + 1, bundleImage->fileName().toLatin1().data());
 
 1130        snprintf(buf, 
sizeof(buf), 
" %12d %12d     ", numUsed, numMeasures);
 
 1133        snprintf(buf, 
sizeof(buf),
"%13.4lf %13.4lf %13.4lf",
 
 1134                rmsSampleResiduals,rmsLineResiduals,rmsLandSResiduals);
 
 1140                                          rmsLidarImageSampleResiduals()[imageIndex].Rms();
 
 1142                                        rmsLidarImageLineResiduals()[imageIndex].Rms();
 
 1144                                          rmsLidarImageResiduals()[imageIndex].Rms();
 
 1147                             GetNumberOfValidMeasuresInImage(bundleImage->serialNumber());
 
 1150                             GetNumberOfJigsawRejectedMeasuresInImage(bundleImage->serialNumber());
 
 1152          numLidarUsed = numLidarMeasures - numLidarRejectedMeasures;
 
 1154          snprintf(buf, 
sizeof(buf), 
" %12d %12d     ", numLidarUsed, numLidarMeasures);
 
 1157          snprintf(buf, 
sizeof(buf),
"%13.4lf %13.4lf %13.4lf",
 
 1158                  rmsLidarSampleResiduals,rmsLidarLineResiduals,rmsLidarLandSResiduals);
 
 1163        snprintf(buf, 
sizeof(buf), 
" \n");
 
 1171    snprintf(buf, 
sizeof(buf),
"%*s", -(filePadding + 33), 
"\nTotal RMS:");
 
 1173    snprintf(buf, 
sizeof(buf),
"%13.4lf %13.4lf %13.4lf\n",
 
 1174    rmsSamplesTotal.Rms(),rmsLinesTotal.Rms(),rmsTotals.Rms());
 
 
 1200    bool errorProp = 
false;
 
 1205    QList<QString> outputCsvFileNames;
 
 1208    if (instrumentIds.size() == 1) {
 
 1209      QString ofname = 
"bundleout_images.csv";
 
 1210      ofname = 
m_settings->outputFilePrefix() + ofname;
 
 1211      m_csvSavedImagesFilename = ofname;
 
 1212      outputCsvFileNames.push_back(ofname);
 
 1216      for (
int i = 0; i < instrumentIds.size(); i++) {
 
 1217        QString updatedInstrumentId = instrumentIds[i];
 
 1221        updatedInstrumentId.replace(
"/", 
"_").replace(
" ", 
"_");
 
 1222        QString ofname = 
"bundleout_images_" + updatedInstrumentId + 
".csv";
 
 1223        ofname = 
m_settings->outputFilePrefix() + ofname;
 
 1224        m_csvSavedImagesFilename = ofname;
 
 1225        outputCsvFileNames.push_back(ofname);
 
 1229    for (
int i = 0; i < instrumentIds.size(); i++) {
 
 1231      std::ofstream fpOut(outputCsvFileNames[i].toLatin1().data(), std::ios::out);
 
 1236      QList<BundleObservationQsp> observations =
 
 1239      int nObservations = observations.size();
 
 1243      for (
int j = 0; j < nObservations; j++ ) {
 
 1248        int observationIndex = observation->index();
 
 1250        for (
int obsIndex = 0; obsIndex < observationIndex; obsIndex++) {
 
 1258        int numImages = observation->size();
 
 1260        for (
int k = 0; k < numImages; k++) {
 
 1263          snprintf(buf, 
sizeof(buf), 
"%s", image->fileName().toLatin1().data());
 
 1265          snprintf(buf, 
sizeof(buf),
",");
 
 1268          fpOut << 
toString(rmsImageSampleResiduals[imgIndex].Rms()).toLatin1().data();
 
 1269          snprintf(buf, 
sizeof(buf),
",");
 
 1272          fpOut << 
toString(rmsImageLineResiduals[imgIndex].Rms()).toLatin1().data();
 
 1273          snprintf(buf, 
sizeof(buf),
",");
 
 1276          fpOut << 
toString(rmsImageResiduals[imgIndex].Rms()).toLatin1().data();
 
 1277          snprintf(buf, 
sizeof(buf),
",");
 
 1280          QString observationString =
 
 1281              observation->bundleOutputCSV(errorProp);
 
 1284          if (observationString.right(1)==
",") {
 
 1285              observationString.truncate(observationString.length()-1);
 
 1288          fpOut << (
const char*) observationString.toLatin1().data();
 
 1290          snprintf(buf, 
sizeof(buf),
"\n");
 
 
 1310    QString ofname = 
"bundleout.txt";
 
 1311    ofname = 
m_settings->outputFilePrefix() + ofname;
 
 1313    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
 
 1318    m_txtBundleOutputFilename = ofname;
 
 1327    bool berrorProp = 
false;
 
 1334      snprintf(buf, 
sizeof(buf), 
"\nTARGET BODY\n==========================\n");
 
 1337      snprintf(buf, 
sizeof(buf), 
"\n   Target         Initial            Total               " 
 1338                   "Final           Initial           Final\n" 
 1339                   "Parameter         Value            Correction           " 
 1340                   "Value             Accuracy          Accuracy\n");
 
 1343      QString targetString =
 
 1344          m_settings->bundleTargetBody()->formatBundleOutputString(berrorProp);
 
 1345      fpOut << (
const char*)targetString.toLatin1().data();
 
 1349    snprintf(buf, 
sizeof(buf), 
"\nIMAGE EXTERIOR ORIENTATION\n==========================\n");
 
 1352    QMap<QString, QStringList> imagesAndParameters;
 
 1355      imagesAndParameters.insert( 
"target", 
m_settings->bundleTargetBody()->parameterList() );
 
 1358    for (
int i = 0; i < nObservations; i++) {
 
 1365      int numImages = observation->size();
 
 1366      for (
int j = 0; j < numImages; j++) {
 
 1368        snprintf(buf, 
sizeof(buf), 
"\nImage Full File Name: %s\n", image->fileName().toLatin1().data());
 
 1370        snprintf(buf, 
sizeof(buf), 
"\nImage Serial Number: %s\n", image->serialNumber().toLatin1().data());
 
 1373        snprintf(buf, 
sizeof(buf),
"Image           Initial                 Total                  Final                                      Accuracy\n");
 
 1375        snprintf(buf, 
sizeof(buf),
"Parameter       Value                   Correction             Value                      Initial           Final           Units\n");
 
 1378        snprintf(buf, 
sizeof(buf),
"                                                                                          " 
 1379                    "***************************************\n");
 
 1382        observation->bundleOutputString(fpOut,berrorProp);
 
 1384        foreach ( QString image, observation->imageNames() ) {
 
 1385          imagesAndParameters.insert( image, observation->parameterList() );
 
 1398      snprintf(buf, 
sizeof(buf), 
"\n\n\nPOINTS UNCERTAINTY SUMMARY\n==========================\n\n");
 
 1405      snprintf(buf, 
sizeof(buf), 
"RMS Sigma %s(m)%20.8lf\n", coordName.toLatin1().data(),
 
 1408      snprintf(buf, 
sizeof(buf), 
"MIN Sigma %s(m)%20.8lf at %s\n", coordName.toLatin1().data(),
 
 1412      snprintf(buf, 
sizeof(buf), 
"MAX Sigma %s(m)%20.8lf at %s\n\n", coordName.toLatin1().data(),
 
 1420      snprintf(buf, 
sizeof(buf), 
"RMS Sigma %s(m)%20.8lf\n", coordName.toLatin1().data(),
 
 1423      snprintf(buf, 
sizeof(buf), 
"MIN Sigma %s(m)%20.8lf at %s\n", coordName.toLatin1().data(),
 
 1427      snprintf(buf, 
sizeof(buf), 
"MAX Sigma %s(m)%20.8lf at %s\n\n", coordName.toLatin1().data(),
 
 1434                                        SurfacePoint::Three);
 
 1436        snprintf(buf, 
sizeof(buf), 
"RMS Sigma %s(m)%20.8lf\n", coordName.toLatin1().data(),
 
 1439        snprintf(buf, 
sizeof(buf), 
"MIN Sigma %s(m)%20.8lf at %s\n", coordName.toLatin1().data(),
 
 1443        snprintf(buf, 
sizeof(buf), 
"MAX Sigma %s(m)%20.8lf at %s\n", coordName.toLatin1().data(),
 
 1449        snprintf(buf, 
sizeof(buf), 
"   RMS Sigma Radius(m)                 N/A\n");
 
 1451        snprintf(buf, 
sizeof(buf), 
"   MIN Sigma Radius(m)                 N/A\n");
 
 1453        snprintf(buf, 
sizeof(buf), 
"   MAX Sigma Radius(m)                 N/A\n");
 
 1460      snprintf(buf, 
sizeof(buf), 
"\n\nPOINTS SUMMARY\n==============\n%103s" 
 1461            "Sigma          Sigma              Sigma\n" 
 1462            "           Label         Status     Rays    RMS" 
 1463            "        Latitude       Longitude          Radius" 
 1464            "        Latitude       Longitude          Radius\n", 
"");
 
 1467      snprintf(buf, 
sizeof(buf), 
"\n\nPOINTS SUMMARY\n==============\n%103s" 
 1468            "Sigma          Sigma              Sigma\n" 
 1469            "           Label         Status     Rays    RMS" 
 1470            "         Point X            Point Y          Point Z" 
 1471            "         Point X            Point Y          Point Z\n", 
"");
 
 1476    for (
int i = 0; i < nPoints; i++) {
 
 1479      QString pointSummaryString =
 
 1480          bundleControlPoint->formatBundleOutputSummaryString(berrorProp);
 
 1481      fpOut << (
const char*)pointSummaryString.toLatin1().data();
 
 1485    for (
int i = 0; i < nLidarPoints; i++) {
 
 1489      QString pointSummaryString =
 
 1490          lidarControlPoint->formatBundleOutputSummaryString(berrorProp);
 
 1491      fpOut << (
const char*)pointSummaryString.toLatin1().data();
 
 1495    snprintf(buf, 
sizeof(buf), 
"\n\nPOINTS DETAIL\n=============\n\n");
 
 1498    bool solveRadius = 
m_settings->solveRadius();
 
 1500    for (
int i = 0; i < nPoints; i++) {
 
 1504      QString pointDetailString =
 
 1505          bundleControlPoint->formatBundleOutputDetailString(berrorProp, solveRadius);
 
 1506      fpOut << (
const char*)pointDetailString.toLatin1().data();
 
 1509    for (
int i = 0; i < nLidarPoints; i++) {
 
 1513      QString pointDetailString =
 
 1514          bundleLidarControlPoint->formatBundleOutputDetailString(berrorProp, solveRadius);
 
 1515      fpOut << (
const char*)pointDetailString.toLatin1().data();
 
 
 1532    QString ofname = 
"bundleout_points.csv";
 
 1533    ofname = 
m_settings->outputFilePrefix() + ofname;
 
 1534    m_csvSavedPointsFilename = ofname;
 
 1536    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
 
 1543    double dLat, dLon, dRadius;
 
 1545    double dSigmaLat, dSigmaLong, dSigmaRadius;
 
 1550    int numMeasures, numRejectedMeasures;
 
 1551    double dResidualRms;
 
 1555      snprintf(buf, 
sizeof(buf), 
",,,,,3-d,3-d,3-d,Sigma,Sigma,Sigma,Correction,Correction,Correction,Coordinate," 
 1556              "Coordinate,Coordinate\nPoint,Point,Accepted,Rejected,Residual,Latitude,Longitude," 
 1557              "Radius,Latitude,Longitude,Radius,Latitude,Longitude,Radius,X,Y,Z\nLabel,Status," 
 1558              "Measures,Measures,RMS,(dd),(dd),(km),(m),(m),(m),(m),(m),(m),(km),(km),(km)\n");
 
 1561      snprintf(buf, 
sizeof(buf), 
",,,,,3-d,3-d,3-d,Correction,Correction,Correction,Coordinate,Coordinate," 
 1562              "Coordinate\nPoint,Point,Accepted,Rejected,Residual,Latitude,Longitude,Radius," 
 1563              "Latitude,Longitude,Radius,X,Y,Z\nLabel,Status,Measures,Measures,RMS,(dd),(dd),(km)," 
 1564              "(m),(m),(m),(km),(km),(km)\n");
 
 1568    for (
int i = 0; i < numPoints; i++) {
 
 1571      if (!bundlecontrolpoint) {
 
 1575      if (bundlecontrolpoint->isRejected()) {
 
 1579      dLat              = bundlecontrolpoint->adjustedSurfacePoint().GetLatitude().degrees();
 
 1580      dLon              = bundlecontrolpoint->adjustedSurfacePoint().GetLongitude().degrees();
 
 1581      dRadius           = bundlecontrolpoint->adjustedSurfacePoint().GetLocalRadius().kilometers();
 
 1582      dX                = bundlecontrolpoint->adjustedSurfacePoint().GetX().kilometers();
 
 1583      dY                = bundlecontrolpoint->adjustedSurfacePoint().GetY().kilometers();
 
 1584      dZ                = bundlecontrolpoint->adjustedSurfacePoint().GetZ().kilometers();
 
 1585      numMeasures         = bundlecontrolpoint->numberOfMeasures();
 
 1586      numRejectedMeasures = bundlecontrolpoint->numberOfRejectedMeasures();
 
 1587      dResidualRms      = bundlecontrolpoint->residualRms();
 
 1590      boost::numeric::ublas::bounded_vector< double, 3 > corrections = bundlecontrolpoint->
 
 1593      cor_lat_m = bundlecontrolpoint->adjustedSurfacePoint().LatitudeToMeters(corrections[0]);
 
 1594      cor_lon_m = bundlecontrolpoint->adjustedSurfacePoint().LongitudeToMeters(corrections[1]);
 
 1595      cor_rad_m  = corrections[2]*1000.0;
 
 1598        strStatus = 
"FIXED";
 
 1601        strStatus = 
"CONSTRAINED";
 
 1607        strStatus = 
"UNKNOWN";
 
 1611        dSigmaLat = bundlecontrolpoint->adjustedSurfacePoint().GetLatSigmaDistance().meters();
 
 1612        dSigmaLong = bundlecontrolpoint->adjustedSurfacePoint().GetLonSigmaDistance().meters();
 
 1613        dSigmaRadius = bundlecontrolpoint->adjustedSurfacePoint().GetLocalRadiusSigma().meters();
 
 1615        snprintf(buf, 
sizeof(buf), 
"%s,%s,%d,%d,%6.2lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf," 
 1616                     "%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf\n",
 
 1617                bundlecontrolpoint->id().toLatin1().data(), strStatus.toLatin1().data(),
 
 1618                numMeasures, numRejectedMeasures, dResidualRms, dLat, dLon, dRadius, dSigmaLat,
 
 1619                dSigmaLong, dSigmaRadius, cor_lat_m, cor_lon_m, cor_rad_m, dX, dY, dZ);
 
 1622        snprintf(buf, 
sizeof(buf), 
"%s,%s,%d,%d,%6.2lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf," 
 1623                     "%16.8lf,%16.8lf\n",
 
 1624                bundlecontrolpoint->id().toLatin1().data(), strStatus.toLatin1().data(),
 
 1625                numMeasures, numRejectedMeasures, dResidualRms, dLat, dLon, dRadius, cor_lat_m,
 
 1626                cor_lon_m, cor_rad_m, dX, dY, dZ);
 
 
 1645    QString ofname = 
"bundleout_lidar.csv";
 
 1646    ofname = 
m_settings->outputFilePrefix() + ofname;
 
 1647    m_csvSavedPointsFilename = ofname;
 
 1649    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
 
 1662      snprintf(buf, 
sizeof(buf), 
",,measured,a priori,adjusted,adjusted\n" 
 1663              "point,image,range,sigma,range,sigma,residual\n" 
 1664              "id,name,(km),(km),(km),(km),(km)\n");
 
 1667      snprintf(buf, 
sizeof(buf), 
",,measured,a priori,adjusted\n" 
 1668                   "point,image,range,sigma,range,residual\n" 
 1669                   "id,name,(km),(km),(km),(km)\n");
 
 1673    for (
int i = 0; i < numPoints; i++) {
 
 1676      if (!point || point->isRejected()) {
 
 1680      int nRangeConstraints = point->numberRangeConstraints();
 
 1681      for (
int j = 0; j < nRangeConstraints; j++) {
 
 1684        QString str = rangeConstraint->formatBundleOutputString(
m_settings->errorPropagation());
 
 
 1703    QString ofname = 
"residuals.csv";
 
 1704    ofname = 
m_settings->outputFilePrefix() + ofname;
 
 1705    m_csvSavedResidualsFilename = ofname;
 
 1707    std::ofstream fpOut(ofname.toLatin1().data(), std::ios::out);
 
 1714    snprintf(buf, 
sizeof(buf), 
",,,x image,y image,Measured,Measured,sample,line,Residual Vector\n");
 
 1716    snprintf(buf, 
sizeof(buf), 
"Point,Image,Image,coordinate,coordinate," 
 1717                 "Sample,Line,residual,residual,Magnitude\n");
 
 1719    snprintf(buf, 
sizeof(buf), 
"Label,Filename,Serial Number,(mm),(mm)," 
 1720                 "(pixels),(pixels),(pixels),(pixels),(pixels),Rejected\n");
 
 1726    int numMeasures = 0;
 
 1731    for (
int i = 0; i < numPoints; i++) {
 
 1733      numMeasures = bundleControlPoint->size();
 
 1735      if (bundleControlPoint->rawControlPoint()->IsIgnored()) {
 
 1739      for (
int j = 0; j < numMeasures; j++) {
 
 1740        bundleMeasure = bundleControlPoint->at(j);
 
 1742        Camera *measureCamera = bundleMeasure->camera();
 
 1743        if (!measureCamera) {
 
 1747        if (bundleMeasure->isRejected()) {
 
 1748          snprintf(buf, 
sizeof(buf), 
"%s,%s,%s,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,*\n",
 
 1749                  bundleControlPoint->id().toLatin1().data(),
 
 1750                  bundleMeasure->parentBundleImage()->fileName().toLatin1().data(),
 
 1751                  bundleMeasure->cubeSerialNumber().toLatin1().data(),
 
 1752                  bundleMeasure->focalPlaneMeasuredX(),
 
 1753                  bundleMeasure->focalPlaneMeasuredY(),
 
 1754                  bundleMeasure->sample(),
 
 1755                  bundleMeasure->line(),
 
 1756                  bundleMeasure->sampleResidual(),
 
 1757                  bundleMeasure->lineResidual(),
 
 1758                  bundleMeasure->residualMagnitude());
 
 1761          snprintf(buf, 
sizeof(buf), 
"%s,%s,%s,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf\n",
 
 1762                  bundleControlPoint->id().toLatin1().data(),
 
 1763                  bundleMeasure->parentBundleImage()->fileName().toLatin1().data(),
 
 1764                  bundleMeasure->cubeSerialNumber().toLatin1().data(),
 
 1765                  bundleMeasure->focalPlaneMeasuredX(),
 
 1766                  bundleMeasure->focalPlaneMeasuredY(),
 
 1767                  bundleMeasure->sample(),
 
 1768                  bundleMeasure->line(),
 
 1769                  bundleMeasure->sampleResidual(),
 
 1770                  bundleMeasure->lineResidual(),
 
 1771                  bundleMeasure->residualMagnitude());
 
 1782    for (
int i = 0; i < numPoints; i++) {
 
 1784      numMeasures = bundleLidarPoint->size();
 
 1786      if (bundleLidarPoint->rawControlPoint()->IsIgnored()) {
 
 1790      for (
int j = 0; j < numMeasures; j++) {
 
 1791        bundleMeasure = bundleLidarPoint->at(j);
 
 1793        Camera *measureCamera = bundleMeasure->camera();
 
 1794        if (!measureCamera) {
 
 1798        if (bundleMeasure->isRejected()) {
 
 1799          snprintf(buf, 
sizeof(buf), 
"%s,%s,%s,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,*\n",
 
 1800                  bundleLidarPoint->id().toLatin1().data(),
 
 1801                  bundleMeasure->parentBundleImage()->fileName().toLatin1().data(),
 
 1802                  bundleMeasure->cubeSerialNumber().toLatin1().data(),
 
 1803                  bundleMeasure->focalPlaneMeasuredX(),
 
 1804                  bundleMeasure->focalPlaneMeasuredY(),
 
 1805                  bundleMeasure->sample(),
 
 1806                  bundleMeasure->line(),
 
 1807                  bundleMeasure->sampleResidual(),
 
 1808                  bundleMeasure->lineResidual(),
 
 1809                  bundleMeasure->residualMagnitude());
 
 1812          snprintf(buf, 
sizeof(buf), 
"%s,%s,%s,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf,%16.8lf\n",
 
 1813                  bundleLidarPoint->id().toLatin1().data(),
 
 1814                  bundleMeasure->parentBundleImage()->fileName().toLatin1().data(),
 
 1815                  bundleMeasure->cubeSerialNumber().toLatin1().data(),
 
 1816                  bundleMeasure->focalPlaneMeasuredX(),
 
 1817                  bundleMeasure->focalPlaneMeasuredY(),
 
 1818                  bundleMeasure->sample(),
 
 1819                  bundleMeasure->line(),
 
 1820                  bundleMeasure->sampleResidual(),
 
 1821                  bundleMeasure->lineResidual(),
 
 1822                  bundleMeasure->residualMagnitude());
 
 
 1854    QString relativePath;
 
 1855    QString relativeBundlePath;
 
 1864      if (oldPath != newPath) {
 
 1866        QDir bundleDir(newPath);
 
 1867        if (!bundleDir.mkpath(bundleDir.path())) {
 
 1869                           QString(
"Failed to create directory [%1]")
 
 1870                             .arg(bundleSolutionInfoRoot.
path()),
 
 1875        if (!QFile::copy(oldFile, newFile)) {
 
 1877                           QString(
"Failed to copy file [%1] to new file [%2]")
 
 1881        newFile = newPath + 
"/" + 
FileName(m_txtBundleOutputFilename).
name();
 
 1882        if (!QFile::copy(m_txtBundleOutputFilename, newFile)) {
 
 1884                           QString(
"Failed to copy file [%1] to new file [%2]")
 
 1885                             .arg(m_txtBundleOutputFilename).arg(newFile),
 
 1888        newFile = newPath + 
"/" + 
FileName(m_csvSavedImagesFilename).
name();
 
 1889        if (!QFile::copy(m_csvSavedImagesFilename, newFile)) {
 
 1891                           QString(
"Failed to copy file [%1] to new file [%2]")
 
 1892                             .arg(m_csvSavedImagesFilename).arg(newFile),
 
 1895        newFile = newPath + 
"/" + 
FileName(m_csvSavedPointsFilename).
name();
 
 1896        if (!QFile::copy(m_csvSavedPointsFilename, newFile)) {
 
 1898                           QString(
"Failed to copy file [%1] to new file [%2]")
 
 1899                             .arg(m_csvSavedPointsFilename).arg(newFile),
 
 1902        newFile = newPath + 
"/" + 
FileName(m_csvSavedResidualsFilename).
name();
 
 1903        if (!QFile::copy(m_csvSavedResidualsFilename, newFile)) {
 
 1905                           QString(
"Failed to copy file [%1] to new file [%2]")
 
 1906                             .arg(m_csvSavedResidualsFilename).arg(newFile),
 
 1914      if (relativePath.startsWith(
"/")) {
 
 1915        relativePath.remove(0,1);
 
 1921      if (relativeBundlePath.startsWith(
"/")) {
 
 1922        relativeBundlePath.remove(0,1);
 
 1924      relativeBundlePath += 
"/";
 
 1927    stream.writeStartElement(
"bundleSolutionInfo");
 
 1929    stream.writeStartElement(
"generalAttributes");
 
 1930    stream.writeTextElement(
"id", 
m_id->toString());
 
 1931    stream.writeTextElement(
"name", 
m_name);
 
 1932    stream.writeTextElement(
"runTime", 
runTime());
 
 1934    stream.writeTextElement(
"inputFileName",
 
 1936    stream.writeTextElement(
"bundleOutTXT",
 
 1937                            relativeBundlePath + 
FileName(m_txtBundleOutputFilename).
name());
 
 1938    stream.writeTextElement(
"imagesCSV",
 
 1939                            relativeBundlePath + 
FileName(m_csvSavedImagesFilename).
name());
 
 1940    stream.writeTextElement(
"pointsCSV",
 
 1941                            relativeBundlePath + 
FileName(m_csvSavedPointsFilename).
name());
 
 1942    stream.writeTextElement(
"residualsCSV",
 
 1943                            relativeBundlePath + 
FileName(m_csvSavedResidualsFilename).
name());
 
 1944    stream.writeEndElement(); 
 
 1955        stream.writeStartElement(
"imageLists");
 
 1959        stream.writeEndElement();
 
 1963      stream.writeStartElement(
"outputControl");
 
 1965      stream.writeEndElement();
 
 1968    stream.writeEndElement(); 
 
 
 1982    m_xmlHandlerProject = project;
 
 
 2002    m_xmlHandlerCharacters += ch;
 
 2003    return XmlStackedHandler::characters(ch);
 
 
 2018                                                    const QString &localName,
 
 2019                                                    const QString &qName,
 
 2020                                                    const QXmlAttributes &atts) {
 
 2021    m_xmlHandlerCharacters = 
"";
 
 2023    if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
 
 2025      if (localName == 
"bundleSettings") {
 
 2026        m_xmlHandlerBundleSolutionInfo->m_settings =
 
 2029      else if (localName == 
"bundleResults") {
 
 2030        m_xmlHandlerBundleSolutionInfo->m_statisticsResults = 
new BundleResults(m_xmlHandlerProject,
 
 2033      else if (localName == 
"imageList") {
 
 2034        m_xmlHandlerBundleSolutionInfo->m_adjustedImages->append(
 
 2035            new ImageList(m_xmlHandlerProject, reader()));
 
 2037      else if (localName == 
"outputControl") {
 
 2038        FileName outputControlPath = 
FileName(m_xmlHandlerProject->bundleSolutionInfoRoot() + 
"/" 
 2039                                              + m_xmlHandlerBundleSolutionInfo->runTime());
 
 2041        m_xmlHandlerBundleSolutionInfo->m_outputControl = 
new Control(outputControlPath, reader());
 
 
 2058                                                  const QString &localName,
 
 2059                                                  const QString &qName) {
 
 2061    QString projectRoot;
 
 2062    if (m_xmlHandlerProject) {
 
 2063      projectRoot = m_xmlHandlerProject->projectRoot() + 
"/";
 
 2066    if (localName == 
"id") {
 
 2068      assert(m_xmlHandlerBundleSolutionInfo->m_id);
 
 2069      delete m_xmlHandlerBundleSolutionInfo->m_id;
 
 2070      m_xmlHandlerBundleSolutionInfo->m_id = 
new QUuid(m_xmlHandlerCharacters);
 
 2072    else if (localName == 
"name") {
 
 2073      m_xmlHandlerBundleSolutionInfo->m_name = m_xmlHandlerCharacters;
 
 2075    else if (localName == 
"runTime") {
 
 2076      m_xmlHandlerBundleSolutionInfo->m_runTime = m_xmlHandlerCharacters;
 
 2078    else if (localName == 
"inputFileName") {
 
 2079      assert(m_xmlHandlerBundleSolutionInfo->m_inputControlNetFileName == NULL);
 
 2080      m_xmlHandlerBundleSolutionInfo->m_inputControlNetFileName = 
new FileName(
 
 2081        projectRoot + m_xmlHandlerCharacters);
 
 2083    else if (localName == 
"bundleOutTXT") {
 
 2084      m_xmlHandlerBundleSolutionInfo->m_txtBundleOutputFilename =
 
 2085        projectRoot + m_xmlHandlerCharacters;
 
 2087    else if (localName == 
"imagesCSV") {
 
 2088      m_xmlHandlerBundleSolutionInfo->m_csvSavedImagesFilename =
 
 2089        projectRoot + m_xmlHandlerCharacters;
 
 2091    else if (localName == 
"pointsCSV") {
 
 2092      m_xmlHandlerBundleSolutionInfo->m_csvSavedPointsFilename =
 
 2093        projectRoot + m_xmlHandlerCharacters;
 
 2095    else if (localName == 
"residualsCSV") {
 
 2096      m_xmlHandlerBundleSolutionInfo->m_csvSavedResidualsFilename =
 
 2097        projectRoot + m_xmlHandlerCharacters;
 
 2100    m_xmlHandlerCharacters = 
"";
 
 2101    return XmlStackedHandler::endElement(namespaceURI, localName, qName);
 
 
 2114                                                 SurfacePoint::CoordIndex coordIdx)
 const {
 
 2116    switch (
m_settings->controlPointCoordTypeReports()) {
 
 2119          case SurfacePoint::One:
 
 2120            coordName = 
" Latitude";
 
 2122          case SurfacePoint::Two:
 
 2123            coordName = 
"Longitude";
 
 2125          case SurfacePoint::Three:
 
 2126            coordName = 
"   Radius";
 
 2129            IString msg = 
"Unknown surface point index enum [" 
 2137          case SurfacePoint::One:
 
 2138            coordName = 
"POINT X";
 
 2140          case SurfacePoint::Two:
 
 2141            coordName = 
"POINT Y";
 
 2143          case SurfacePoint::Three:
 
 2144            coordName = 
"POINT Z";
 
 2147            IString msg = 
"Unknown surface point index enum [" 
 2154      IString msg = 
"Unknown surface point coordinate type enum [" 
 
This class is used to modify and manage solve settings for 1 to many BundleObservations.
 
A container class for statistical results from a BundleAdjust solution.
 
double elapsedTimeErrorProp() const
Returns the elapsed time for error propagation.
 
int numberRejectedObservations() const
Returns the number of observation that were rejected.
 
QString minSigmaCoord2PointId() const
Returns the minimum sigma point id for coordinate 2.
 
QList< Statistics > rmsImageSampleResiduals() const
Returns the list of RMS image sample residuals statistics.
 
ControlNetQsp outputControlNet() const
Returns a shared pointer to the output control network.
 
int numberObservations() const
Returns the number of observations.
 
MaximumLikelihoodWFunctions maximumLikelihoodModelWFunc(int modelIndex) const
Returns the maximum likelihood model at the given index.
 
double sigmaCoord3StatisticsRms() const
Returns the RMS of the adjusted sigmas for coordinate 3.
 
double sigma0() const
Returns the Sigma0 of the bundle adjustment.
 
bool converged() const
Returns whether or not the bundle adjustment converged.
 
double maximumLikelihoodModelQuantile(int modelIndex) const
Returns the quantile of the maximum likelihood model at the given index.
 
int numberConstrainedPointParameters() const
Returns the number of constrained point parameters.
 
int iterations() const
Returns the number of iterations taken by the BundleAdjust.
 
QString minSigmaCoord1PointId() const
Returns the minimum sigma point id for coordinate 1.
 
void save(QXmlStreamWriter &stream, const Project *project) const
Saves the BundleResults object to an XML file.
 
QVector< BundleControlPointQsp > & bundleControlPoints()
Returns a reference to the BundleControlPoint vector.
 
void setCorrMatImgsAndParams(QMap< QString, QStringList > imgsAndParams)
Set the images and their associated parameters of the correlation matrix.
 
Distance maxSigmaCoord2Distance() const
Returns the maximum sigma distance for coordinate 2.
 
int numberUnknownParameters() const
Returns the number of unknown parameters.
 
QVector< BundleLidarControlPointQsp > & bundleLidarControlPoints()
Returns a reference to the BundleLidarControlPoint vector.
 
LidarDataQsp outputLidarData() const
Returns a shared pointer to the output LidarData object.
 
double sigmaCoord2StatisticsRms() const
Returns the RMS of the adjusted sigmas for coordinate 2.
 
Distance minSigmaCoord3Distance() const
Returns the minimum sigma distance for coordinate 3.
 
QString maxSigmaCoord1PointId() const
Returns the maximum sigma point id for coordinate 1.
 
int numberConstrainedTargetParameters() const
Return the number of constrained target parameters.
 
StatCumProbDistDynCalc residualsCumulativeProbabilityDistribution() const
Returns the cumulative probability distribution of the residuals used for reporting.
 
double elapsedTime() const
Returns the elapsed time for the bundle adjustment.
 
QList< Statistics > rmsImageResiduals() const
Returns the list of RMS image residuals statistics.
 
const BundleObservationVector & observations() const
Returns a reference to the observations used by the BundleAdjust.
 
Distance minSigmaCoord1Distance() const
Returns the minimum sigma distance for coordinate 1.
 
QString minSigmaCoord3PointId() const
Returns the minimum sigma point id for coordinate 3.
 
QList< Statistics > rmsImageLineResiduals() const
Returns the list of RMS image line residuals statistics.
 
int numberLidarRangeConstraintEquations() const
Return the number of lidar range constraint equations.
 
Distance maxSigmaCoord3Distance() const
Returns the maximum sigma distance for coordinate 3.
 
Distance maxSigmaCoord1Distance() const
Returns the maximum sigma distance for coordinate 1.
 
QString maxSigmaCoord3PointId() const
Returns the maximum sigma point id for coordinate 3.
 
QString maxSigmaCoord2PointId() const
Returns the maximum sigma point id for coordinate 2.
 
int numberConstrainedImageParameters() const
Returns the number of constrained image parameters.
 
double sigmaCoord1StatisticsRms() const
Returns the RMS of the adjusted sigmas for coordinate 1.
 
Distance minSigmaCoord2Distance() const
Returns the minimum sigma distance for coordinate 2.
 
int degreesOfFreedom() const
Returns the degrees of freedom.
 
Container class for BundleAdjustment settings.
 
This class is used to read an images.xml file into an image list.
 
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Handle an XML end element.
 
virtual bool characters(const QString &ch)
Adds characters to m_xmlHandlerCharacters.
 
XmlHandler(BundleSolutionInfo *bundleSolutionInfo, Project *project)
Create an XML Handler (reader) that can populate the BundleSolutionInfo class data.
 
QString m_xmlHandlerCharacters
List of characters that have been handled.
 
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Handle an XML start element.
 
BundleSolutionInfo * m_xmlHandlerBundleSolutionInfo
The bundleSolutionInfo object.
 
Container class for BundleAdjustment results.
 
bool outputResiduals()
Outputs image coordinate residuals to a csv file.
 
bool outputImagesCSV()
Outputs the bundleout_images.csv file which contains Jigsaw data about the images within each observa...
 
BundleSettingsQsp m_settings
Bundle settings.
 
QString inputControlNetFileName() const
Returns the name of the input control network.
 
QString m_runTime
Run time of the bundle adjustment.
 
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Saves the BundleSolutionInfo to the project.
 
QString inputLidarDataFileName() const
Returns name of input lidar data file (if any).
 
void addAdjustedImages(ImageList *images)
Adds a list of images that were adjusted (their labels were updated).
 
QString savedPointsFilename()
Returns filename of output bundle points csv file.
 
QUuid * m_id
A unique ID for this BundleSolutionInfo object (useful for others to reference this object when savin...
 
BundleSettingsQsp bundleSettings()
Returns bundle settings.
 
void setName(QString name)
Sets the name of the bundle.
 
QList< ImageList * > * m_adjustedImages
Adjusted image list.
 
FileName * m_inputControlNetFileName
Input control network file name.
 
void setOutputControl(Control *outputControl)
Returns the name of the output control network.
 
QList< ImageList * > adjustedImages() const
Returns the list of images that were adjusted after a bundle.
 
QList< ImageList * > * m_images
Input image list.
 
FileName * m_inputLidarDataFileName
Input lidar data file name.
 
QString surfacePointCoordName(SurfacePoint::CoordinateType type, SurfacePoint::CoordIndex coordInx) const
Determine the control point coordinate name.
 
QString savedResidualsFilename()
Returns filename of output bundle residuals csv file.
 
void setOutputControlName(QString name)
Sets m_outputControlName.
 
BundleResults bundleResults()
Returns the bundle results.
 
QString id() const
Get a unique, identifying string associated with this BundleSolutionInfo object.
 
void setRunTime(QString runTime)
Sets the run time, and the name if a name is not already set.
 
bool outputPointsCSV()
Outputs point data to a csv file.
 
QString outputControlName() const
Returns m_outputControlName.
 
void updateFileName(Project *)
TODO: change description below to something more like english.
 
QString outputControlNetFileName() const
Returns the name of the output control network.
 
BundleResults * m_statisticsResults
Bundle statistical results.
 
~BundleSolutionInfo()
Destructor.
 
QString runTime() const
Returns the run time.
 
bool outputHeader(std::ofstream &fpOut)
Output header for bundle results file.
 
LidarData * m_outputLidarDataSet
QList of adjusted lidar points.
 
QString name() const
Returns the name of the bundle.
 
QString savedBundleOutputFilename()
Returns bundleout text filename.
 
bool outputText()
Outputs a text file with the results of the BundleAdjust.
 
Control * m_outputControl
Output control.
 
QString savedImagesFilename()
Returns filename of output bundle images csv file.
 
QList< ImageList * > imageList()
Returns the images used in the bundle.
 
void setOutputStatistics(BundleResults statisticsResults)
Sets the stat results.
 
QString m_name
Name of the bundle. Defaults to the id.
 
bool outputImagesCSVHeader(std::ofstream &fpOut, BundleObservationQsp observations)
Outputs the header for the bundleout_images.csv file.
 
Control * control() const
Returns bundle output Control object.
 
bool outputLidarCSV()
Outputs lidar data to a csv file.
 
This represents an ISIS control net in a project-based GUI interface.
 
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Method to write this Control object's member data to an XML stream.
 
QString fileName() const
Access the name of the control network file associated with this Control.
 
@ Constrained
A Constrained point is a Control Point whose lat/lon/radius is somewhat established and should not be...
 
@ Free
A Free point is a Control Point that identifies common measurements between two or more cubes.
 
@ Fixed
A Fixed point is a Control Point whose lat/lon is well established and should not be changed.
 
double meters() const
Get the distance in meters.
 
File name manipulation and expansion.
 
QString path() const
Returns the path of the file name.
 
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
 
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
 
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
 
@ Unknown
A type of error that cannot be classified as any of the other error types.
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
@ Io
A type of error that occurred when performing an actual I/O operation.
 
Adds specific functionality to C++ strings.
 
Internalizes a list of images and allows for operations on the entire list.
 
static QString modelToString(Model model)
Static method to return a string represtentation for a given MaximumLikelihoodWFunctions::Model enum.
 
QString weightedResidualCutoff()
Method to return a string represtentation of the weighted residual cutoff (if it exists) for the Maxi...
 
double tweakingConstant() const
Returns the current tweaking constant.
 
The main project for ipce.
 
static QString cnetRoot(QString projectRoot)
Appends the root directory name 'cnets' to the project.
 
QString bundleSolutionInfoRoot() const
Accessor for the root directory of the results data.
 
static QString bundleSolutionInfoRoot(QString projectRoot)
Appends the root directory name 'bundle' to the project results directory.
 
QString newProjectRoot() const
Get the top-level folder of the new project.
 
QString projectRoot() const
Get the top-level folder of the project.
 
double min()
Returns the maximum observation so far included in the dynamic calculation.
 
double value(double cumProb)
Provides the value of the variable that has the given cumulative probility (according the current est...
 
double max()
Returns the maximum observation so far included in the dynamic calculation.
 
This class is used to accumulate statistics on double arrays.
 
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
 
@ Latitudinal
Planetocentric latitudinal (lat/lon/rad) coordinates.
 
@ Rectangular
Body-fixed rectangular x/y/z coordinates.
 
static QString coordinateTypeToString(CoordinateType type)
Converts the given SurfacePoint::CoordinateType enumeration to a string.
 
Manage a stack of content handlers for reading XML files.
 
static QString CurrentLocalTime()
Returns the current local time This time is taken directly from the system clock, so if the system cl...
 
This is free and unencumbered software released into the public domain.
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
 
QSharedPointer< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.
 
QSharedPointer< BundleLidarRangeConstraint > BundleLidarRangeConstraintQsp
Typdef for BundleLidarRangeConstraint QSharedPointer.
 
const double Null
Value for an Isis Null pixel.