Commit 96612d2a authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Updated pixel2map to attach IsisCube core labels (including BandBin group) and...

Updated pixel2map to attach IsisCube core labels (including BandBin group) and non-camera specific tables to output cubes. Fixes #4433. Removed unused variable in pixel2map. Fixes #4495.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7269 41f8697f-d340-4b68-9986-7bafba869bb8
parent 1460423f
Loading
Loading
Loading
Loading
+31 −9
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ map <QString, void *> GuiHelpers() {

// Global variables
ProcessGroundPolygons g_processGroundPolygons;
UniversalGroundMap *g_groundMap;
Camera *g_incam;
int g_numIFOVs = 0;

@@ -79,7 +78,6 @@ void IsisMain() {
  double minlon = 360.0;
  double maxlon = 0;
  PvlGroup camGrp;
  PvlGroup bandBinGrp;
  QString lastBandString;

  // Get the combined lat/lon range for all input cubes
@@ -107,14 +105,10 @@ void IsisMain() {
      lastBandString = atts0.bandsString();
    }

    // Get the mapping group and the BandBin group
    // Get the mapping group
    Pvl camMap;
    g_incam->BasicMapping(camMap);
    camGrp = camMap.findGroup("Mapping");
    if (icube->hasGroup("BandBin")) {
      bandBinGrp = icube->group("BandBin");

    }

    g_incam->GroundRange(newminlat, newmaxlat, newminlon, newmaxlon, userMap);
    //set min lat/lon
@@ -282,8 +276,26 @@ void IsisMain() {

  Pvl pvl;
  pvl.addGroup(userGrp);
  pvl.addGroup(bandBinGrp);

  // If there is only one input cube, we need to attach an AlphaCube to the outputs.
  if (list.size() == 1) {
    Cube parent(list[0].toString());
    if (!parent.hasGroup("AlphaCube")) {
      PvlGroup alpha("AlphaCube");
      alpha += PvlKeyword("AlphaSamples", toString(parent.sampleCount()));
      alpha += PvlKeyword("AlphaLines", toString(parent.lineCount()));
      alpha += PvlKeyword("AlphaStartingSample", toString(0.5));
      alpha += PvlKeyword("AlphaStartingLine", toString(0.5));
      alpha += PvlKeyword("AlphaEndingSample", toString(parent.sampleCount() + 0.5));
      alpha += PvlKeyword("AlphaEndingLine", toString(parent.lineCount() + 0.5));
      alpha += PvlKeyword("BetaSamples", toString(parent.sampleCount()));
      alpha += PvlKeyword("BetaLines", toString(parent.lineCount()));
      pvl.addGroup(alpha);
    }
  }

  g_processGroundPolygons.SetStatCubes("TO", pvl, bands);

  bool useCenter = true;
  if (ui.GetString("METHOD") == "CENTER") {
    useCenter = true;
@@ -297,7 +309,6 @@ void IsisMain() {
  for (int f = 0; f < list.size(); f++) {

    Cube cube(list[f].toString(), "r");
    g_groundMap = new UniversalGroundMap(cube);
    // Loop through the input cube and get the all pixels values for all bands
    ProcessByBrick processBrick;
    processBrick.Progress()->SetText("Working on file:  " + list[f].toString());
@@ -310,6 +321,17 @@ void IsisMain() {
    processBrick.StartProcess(rasterizePixel);
    processBrick.EndProcess();
  }
  
  // When there is only one input cube, we want to propagate IsisCube labels to output cubes
  if (list.size() == 1) {
    // Note that polygons and original labels are not propagated
    g_processGroundPolygons.PropagateLabels(list[0].toString());
    // Tell Process which tables we want to propagate
    QList<QString> tablesToPropagate;
    tablesToPropagate << "InstrumentPointing" << "InstrumentPosition" << "BodyRotation"
        << "SunPosition";
    g_processGroundPolygons.PropagateTables(list[0].toString(), tablesToPropagate);
  }
  g_processGroundPolygons.EndProcess();

  // WARNING: rasterizePixel() method alters the current state of the camera.
+4 −0
Original line number Diff line number Diff line
@@ -231,6 +231,10 @@
      Previous pixel2map was ignoring cube attributes when storing the FROM parameter internally.
      Running pixel2map now allows band selection on the FROM cube and FROMLIST cubes. Fixes #4520.
    </change>
    <change name="Ian Humphrey" date="2016-11-30">
      IsisCube labels and tables are now attached to the output cubes if there is a single input
      image. Fixes #4433. Removed unused UniveralGroundMap instance. References #4495.
    </change>
  </history>

  <groups>
+18 −5
Original line number Diff line number Diff line
@@ -596,9 +596,20 @@ namespace Isis {
  /**
   * Propagate the tables from the cube with the given filename to the output
   * cube.  This is done at the time this method is called, not during normal
   * processing.
   * processing. The names of the tables to propagate can be provided through the second paramter,
   * by specifing a list of table names. Not providing any list (or providing an empty list) will
   * propagate all tables.
   *
   * @param fromName QString of the name of the cube containing the tables to propagate.
   * @param tableNames List of QStrings of the names of the tables to propagate; default is empty,
   *                   which indicates that all tables will be propagated.
   *
   * @internal
   *   @history 2016-11-30 Ian Humphrey - Added tableNames parameter so that only specified tables
   *                           will be propagated when calling this method. Note that a default of
   *                           an empty QList is used to propagate all tables. References #4433.
   */
  void Process::PropagateTables(const QString &fromName) {
  void Process::PropagateTables(const QString &fromName, const QList<QString> &tableNames) {
    Cube *fromCube = new Isis::Cube;
    fromCube->open(fromName);
    const Pvl *fromLabels = fromCube->label();
@@ -608,6 +619,7 @@ namespace Isis {
        const PvlObject &object = fromLabels->object(j);

        if (object.isNamed("Table")) {
          if (tableNames.isEmpty() || tableNames.contains(object["Name"])) { 
            Blob table((QString) object["Name"], object.name());
            fromCube->read(table);
            OutputCubes[i]->write(table);
@@ -615,6 +627,7 @@ namespace Isis {
        }
      }
    }
  }

  /**
   * This method allows the programmer to propagate input blobs to the output
+6 −1
Original line number Diff line number Diff line
@@ -148,6 +148,11 @@ namespace Isis {
   *                                           inheritance between Process and its
   *                                           child classes.  Fixes #2215.
   *  @history 2016-04-21 Makayla Shepherd - Added UnsignedWord pixel type handling.
   *  @history 2016-11-30 Ian Humphrey - Added second parameter, tableNames, to PropagateTables()
   *                          to specifiy which tables will be propagated when calling
   *                          PropagateTables(QString, QList<QString>). A default value of an
   *                          empty QList is provided to this parameter which will propagate all
   *                          tables. Updated unitTest to test this change. References #4433.
   */
  class Process {
    protected:
@@ -251,7 +256,7 @@ namespace Isis {
      void PropagateLabels(const bool prop);
      void PropagateLabels(const QString &cube);
      void PropagateTables(const bool prop);
      void PropagateTables(const QString &fromName);
      void PropagateTables(const QString &fromName, const QList<QString>& tableNames = QList<QString>());
      void PropagatePolygons(const bool prop);
      void PropagateHistory(const bool prop);
      void PropagateOriginalLabel(const bool prop);
+6 −0
Original line number Diff line number Diff line
@@ -97,6 +97,12 @@ Record Size = 8
Testing Table propagation (off) ...
Group Table does not exist

Testing Table propagation with list of table names to propagate (Table2) ...
Does output cube have "Table"  ? false
Does output cube have "Table2" ? true
Number of records = 1
Record Size = 4

Testing Polygon propagation (on) ...
Image Polygon does exist
Size: 60
Loading