Unverified Commit d15126ea authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

fixes bug where cam2map doesn't project multiple bands on band dependent...

fixes bug where cam2map doesn't project multiple bands on band dependent camera models (fixes #4635) (#4926)

* lro wac and Marci can now be projected when there exists bands created from phocube

* added marcicam test
parent bc7381f1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -462,7 +462,9 @@ namespace Isis {
  bool cam2mapForward::Xform(double &outSample, double &outLine,
                             const double inSample, const double inLine) {
    // See if the input image coordinate converts to a lat/lon
    if (!p_incam->SetImage(inSample,inLine)) return false;
    if (!p_incam->SetImage(inSample,inLine)) {
      return false;
    }

    // Does that ground coordinate work in the map projection
    double lat = p_incam->UniversalLatitude();
@@ -568,6 +570,7 @@ namespace Isis {
  }

  void bandChange(const int band) {
    // band dependant band change
    incam->SetBand(band);
  }
}
+18 −9
Original line number Diff line number Diff line
@@ -232,28 +232,35 @@ namespace Isis {
  void LroWideAngleCamera::SetBand(const int vband) {

    // Sanity check on requested band
    int maxbands = min(p_detectorStartLines.size(), p_frameletOffsets.size());
    if ((vband <= 0) || (vband > maxbands)) {
    int maxVirtualBands = min(p_detectorStartLines.size(), p_frameletOffsets.size());
    if (((vband <= 0) || (vband > maxVirtualBands)) && (vband > Bands())) {
      ostringstream mess;
      mess << "Requested virtual band (" << vband
           << ") outside valid (BandBin/Center) limits (1 - " << maxbands
           << ") outside valid (BandBin/Center) limits (1 - " << maxVirtualBands
           <<  ")";
      throw IException(IException::Programmer, mess.str(), _FILEINFO_);
    }

    //  Set up valid band access
    Camera::SetBand(vband);
    if ((vband > maxVirtualBands) && (vband <= Bands())) {
      // probably switching to a band from phocube or similar
      // instead of a different filter band, so just re-use the 
      // properties from the current band. 
      return;
    }

    PushFrameCameraDetectorMap *dmap = NULL;
    dmap = (PushFrameCameraDetectorMap *) DetectorMap();
    dmap->SetBandFirstDetectorLine(p_detectorStartLines[vband - 1]);
    dmap->SetFrameletOffset(p_frameletOffsets[vband - 1]);
    dmap->SetBandFirstDetectorLine(p_detectorStartLines.at(vband - 1));
    dmap->SetFrameletOffset(p_frameletOffsets.at(vband - 1));

    SetFocalLength(p_focalLength[vband-1]);
    SetFocalLength(p_focalLength.at(vband-1));

    LroWideAngleCameraFocalPlaneMap *fplane = (LroWideAngleCameraFocalPlaneMap *) FocalPlaneMap();
    fplane->setBand(vband);
    fplane->SetDetectorOrigin(p_boreSightSample[vband-1] + 1.0,
                              p_boreSightLine[vband-1]   + 1.0);
    fplane->SetDetectorOrigin(p_boreSightSample.at(vband-1) + 1.0,
                              p_boreSightLine.at(vband-1)   + 1.0);

    LroWideAngleCameraDistortionMap *distort = (LroWideAngleCameraDistortionMap *) DistortionMap();
    distort->setBand(vband);
@@ -321,7 +328,9 @@ namespace Isis {
   * @return bool False
   */
  bool LroWideAngleCamera::IsBandIndependent() {
    return false;
    // only band independant if there is one filter 
    // band on the image
    return p_frameletOffsets.size() == 1;
  }


+24 −5
Original line number Diff line number Diff line
@@ -178,14 +178,33 @@ namespace Isis {
   * @param vband The band number to set
   */
  void MarciCamera::SetBand(const int vband) {
    // Sanity check on requested band
    int maxVirtualBands = min(p_detectorStartLines.size(), p_frameletOffsets.size());
    
    if (((vband <= 0) || (vband > maxVirtualBands)) && (vband > Bands())) {
      ostringstream mess;
      mess << "Requested virtual band (" << vband
           << ") outside valid (BandBin/Center) limits (1 - " << maxVirtualBands
           <<  ")";
      throw IException(IException::Programmer, mess.str(), _FILEINFO_);
    }

    Camera::SetBand(vband);
    
    if ((vband > maxVirtualBands) && (vband <= Bands())) {
      // probably switching to a band from phocube or similar
      // instead of a different filter band, so just re-use the 
      // properties from the current band. 
      return;
    }

    PushFrameCameraDetectorMap *dmap = (PushFrameCameraDetectorMap *)DetectorMap();
    dmap->SetBandFirstDetectorLine(p_detectorStartLines[vband-1]);
    dmap->SetFrameletOffset(p_frameletOffsets[vband-1]);
    dmap->SetBandFirstDetectorLine(p_detectorStartLines.at(vband-1));
    dmap->SetFrameletOffset(p_frameletOffsets.at(vband-1));

    MarciDistortionMap *distmap = (MarciDistortionMap *)DistortionMap();
    distmap->SetFilter(p_filterNumbers[vband-1]);
    distmap->SetFilter(p_filterNumbers.at(vband-1));
    
  }


@@ -193,7 +212,7 @@ namespace Isis {
  /**
   * The camera model is band dependent, so this method returns false
   *  
   * @return bool False
   * @return bool false
   */
  bool MarciCamera::IsBandIndependent() {
    return false;
+41 −0
Original line number Diff line number Diff line
#include "MarciCamera.h" 
#include "PushFrameCameraDetectorMap.h"

#include "Fixtures.h"
#include "gmock/gmock.h"

using namespace Isis;

TEST_F(TempTestingFiles, UnitTestMarciCameraPhocubeBandChange) {

  QString cubeFileName = "data/marcical/P12_005901_3391_MA_00N096W_cropped.cub";
  
  // simulate phocube 
  std::istringstream bbin_stream(R"( 
     Group = BandBin
       FilterName   = BLUE
       OriginalBand = (1, 1, 1, 1, 1)
       Name         = ("Phase Angle", "Emission Angle", "Incidence Angle",
                       Latitude, Longitude)
       Center       = (1.0, 1.0, 1.0, 1.0, 1.0)
       Width        = (1.0, 1.0, 1.0, 1.0, 1.0)
     End_Group
  )");
   
  PvlGroup newbbin;
  bbin_stream >> newbbin;
  
  Cube cube(cubeFileName);
  Pvl *isisLabel = cube.label();
  PvlGroup &ogbbin = isisLabel->findGroup("BandBin", Pvl::Traverse);
  ogbbin = newbbin;
  
  Camera *cam = cube.camera();
  PushFrameCameraDetectorMap *dmap = (PushFrameCameraDetectorMap*) cam->DetectorMap();

  // properties should BLUE filter's properties after band change 
  cam->SetBand(1);
  EXPECT_EQ(dmap->GetBandFirstDetectorLine(), 709);
  cam->SetBand(4);
  EXPECT_EQ(dmap->GetBandFirstDetectorLine(), 709);
}
 No newline at end of file
+1 −1

File changed.

Contains only whitespace changes.