Commit 8a7f61d5 authored by Kristin Berry's avatar Kristin Berry
Browse files

Updated grid to re-calculate grid for each band for Cubes with band-dependent...

Updated grid to re-calculate grid for each band for Cubes with band-dependent camera models. Fixes #2191

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/isis3NewHorizons@6014 41f8697f-d340-4b68-9986-7bafba869bb8
parent ba341436
Loading
Loading
Loading
Loading
+52 −8
Original line number Diff line number Diff line
@@ -30,8 +30,16 @@ Angle latInc, lonInc;
double lineValue;
bool image;
double bkgndValue;
void changeBand(int band);
Cube *icube; 
UniversalGroundMap *gmap; 
int currentBand = 0;
bool recalculateForEachBand = false; 
bool walkBoundary = false; 
Latitude minLat, maxLat;
Longitude minLon, maxLon;

int inputSamples, inputLines;
int inputSamples, inputLines, inputBands;
GroundGrid *latLonGrid;

void IsisMain() {
@@ -39,7 +47,7 @@ void IsisMain() {

  // We will be processing by line
  ProcessByLine p;
  Cube *icube = p.SetInputCube("FROM");
  icube = p.SetInputCube("FROM");

  UserInterface &ui = Application::GetUserInterface();
  QString mode = ui.GetString("MODE");
@@ -95,6 +103,7 @@ void IsisMain() {

  inputSamples = icube->sampleCount();
  inputLines   = icube->lineCount();
  inputBands = icube->bandCount();

  // Line & sample based grid
  if (mode == "IMAGE") {
@@ -110,8 +119,14 @@ void IsisMain() {
  else {
    p.SetOutputCube("TO");

    UniversalGroundMap *gmap = new UniversalGroundMap(*icube,
        UniversalGroundMap::ProjectionFirst);
    //if > 1 input band and IsBandIndependent = false, need to regenerate grid for 
    // each band
    if ( (inputBands >= 2) && !(icube->camera()->IsBandIndependent()) ) {
      recalculateForEachBand = true; 
    }

    gmap = new UniversalGroundMap(*icube, UniversalGroundMap::ProjectionFirst);

    latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount());

    baseLat = Latitude(ui.GetDouble("BASELAT"),
@@ -124,8 +139,6 @@ void IsisMain() {
    Progress progress;
    progress.SetText("Calculating Grid");

    Latitude minLat, maxLat;

    if (ui.WasEntered("MINLAT"))
      minLat = Latitude(ui.GetDouble("MINLAT"),
        *latLonGrid->GetMappingGroup(), Angle::Degrees);
@@ -134,8 +147,6 @@ void IsisMain() {
      maxLat = Latitude(ui.GetDouble("MAXLAT"),
        *latLonGrid->GetMappingGroup(), Angle::Degrees);

    Longitude minLon, maxLon;

    if (ui.WasEntered("MINLON"))
      minLon = Longitude(ui.GetDouble("MINLON"),
        *latLonGrid->GetMappingGroup(), Angle::Degrees);
@@ -150,6 +161,7 @@ void IsisMain() {

    if (ui.GetBoolean("BOUNDARY"))
      latLonGrid->WalkBoundary();
      walkBoundary = true;

    p.StartProcess(groundGrid);
    p.EndProcess();
@@ -288,8 +300,40 @@ bool groundDrawPoint(int samp, int line, bool latGrid = true) {
  return drawPoint;
}

//If camera is band-dependent, need to re-calculate the grid when changing bands

void changeBand(int band){ 
  Progress progress;

  // change band of UniversalGroundMap
  gmap->SetBand(band);

  //update latLonGrid to use new UniversalGroundMap
  latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount());

  //re-set old ground limits from GUI
  latLonGrid->SetGroundLimits(minLat, minLon, maxLat, maxLon);

  QString progressMessage = QString("Recalculating grid for band %1").arg(band);
  progress.SetText(progressMessage);

  //re-set lat/lon base/in from GUI
  latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress);

  if (walkBoundary)
    latLonGrid->WalkBoundary();

}

// Line processing routine
void groundGrid(Buffer &in, Buffer &out) {

  //check to see if we're in the same band: 
  if ( (currentBand != in.Band()) && recalculateForEachBand ) {
    currentBand = in.Band(); 
    changeBand(currentBand); 
  }

  for (int samp = 1; samp <= in.SampleDimension(); samp++) {
    if (!ticks) {
      if (groundDrawPoint(samp, in.Line())) {
+10 −2
Original line number Diff line number Diff line
@@ -40,10 +40,13 @@
    <def link="Level2">level2</def> <def link="Cube">cubes</def>, or mosaics.  
    The mapping information in the labels will be used to draw grid lines on mosaics 
    and Level2 images.  If the
    latitude and longitde information cannot be calculated or extracted using the image 
    latitude and longitude information cannot be calculated or extracted using the image 
    label contents, then use the IMAGE mode.<br/><br/>
    
    <b>Example Parameter Settings for Grids:</b><br/> <br/>
     For Cubes with an associated band-dependent camera model (latitude, longitude coordinates do not correspond to the same sample, line coordinates 
     in each band,) the grid is recalculated for each band.<br/><br/>    
						     
    <b>Example Parameter Settings for Grids:</b><br/> 
    Example 1: Superimpose a basic latitude/longitude graticule with grid lines drawn
    every 10 degrees based on zero: <br/> 
    MODE=GROUND BASELAT=0 BASELON=0 LATINC=10 LONINC=10<br/><br/>
@@ -158,6 +161,11 @@
      Modified so that the output cube characteristics are obtained from the input cube
      and/or cube characteristics specified on the command line. Fixes #2063.
    </change>
    <change name="Kristin Berry" date="2014-11-25">
      Modified to work on Cubes with associated band-dependent camera models. Now 
      when MODE="GROUND" on a Cube with a band-dependent camera model, the grid will 
      be re-calculated for each band. Fixes #2191.
    </change>
  </history>

  <groups>
+8 −0
Original line number Diff line number Diff line
APPNAME = grid

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/leisaCrop.cub+20,1,38,194 \
	to=$(OUTPUT)/leisaCropTruth.cub > /dev/null;
+9 −4
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ namespace Isis {
      //! Destroys the NewHorizonsLeisaCamera object
      ~NewHorizonsLeisaCamera() {};

      //! Flag that NewHorizonsLeisaCamera is band-dependent. 
      bool IsBandIndependent() {
        return false;
      };

       /**
       * CK frame ID -  - Instrument Code from spacit run on CK
       *  
@@ -77,10 +82,10 @@ namespace Isis {
    private:
      QVector<int> m_originalBand; //!< Stores the band bin OriginalBand keyword values

      QVector<double> m_origTransx;  //!< The original tarnsx affine coefficients from the iak
      QVector<double> m_origTransy;  //!< The original tarnsy affine coefficients from the iak
      QVector<double> m_origTranss; //!< The original tarnss affine coefficients from the iak
      QVector<double> m_origTransl; //!< The original tarnsl affine coefficients from the iak
      QVector<double> m_origTransx;  //!< The original transx affine coefficients from the iak
      QVector<double> m_origTransy;  //!< The original transy affine coefficients from the iak
      QVector<double> m_origTranss; //!< The original transs affine coefficients from the iak
      QVector<double> m_origTransl; //!< The original transl affine coefficients from the iak
  };
};
#endif