コード例 #1
0
ファイル: MoonAlbedo.cpp プロジェクト: corburn/ISIS
  /**
    * Set the albedo dependent phase function normalization parameter.
    * This is an emperically derived coefficient. This parameter
    * is limited to non-zero values.
    *
    * @param h  Normalization function parameter, default is 0.048
    */
  void MoonAlbedo::SetNormH(const double h) {
    if(h == 0.0) {
      std::string msg = "Invalid value of normalization h [" +
                        IString(h) + "]";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    p_normH = h;
  }
コード例 #2
0
ファイル: MoonAlbedo.cpp プロジェクト: corburn/ISIS
  /**
    * Set the albedo dependent phase function normalization parameter.
    * This is an emperically derived coefficient. This parameter is
    * limited to values >= 0.
    *
    * @param bsh1  Normalization function parameter, default is 0.08
    */
  void MoonAlbedo::SetNormBsh1(const double bsh1) {
    if(bsh1 < 0.0) {
      std::string msg = "Invalid value of normalization bsh1 [" +
                        IString(bsh1) + "]";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    p_normBsh1 = bsh1;
  }
コード例 #3
0
ファイル: ShadeAtm.cpp プロジェクト: corburn/ISIS
  /**
    * Set the normalization function parameter. This is the
    * reference phase angle to which the image photometry will
    * be normalized. This parameter is limited to values that are
    * >=0 and <180.
    *
    * @param pharef  Normalization function parameter, default
    *                is 0.0
    */
  void ShadeAtm::SetNormPharef(const double pharef) {
    if(pharef < 0.0 || pharef >= 180.0) {
      std::string msg = "Invalid value of normalization pharef [" +
                        IString(pharef) + "]";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    p_normPharef = pharef;
  }
コード例 #4
0
ファイル: ShadeAtm.cpp プロジェクト: corburn/ISIS
  /**
    * Set the normalization function parameter. This is the
    * reference incidence angle to which the image photometry will
    * be normalized. This parameter is limited to values that are
    * >=0 and <90.
    *
    * @param incref  Normalization function parameter, default
    *                is 0.0
    */
  void ShadeAtm::SetNormIncref(const double incref) {
    if(incref < 0.0 || incref >= 90.0) {
      std::string msg = "Invalid value of normalization incref [" +
                        IString(incref) + "]";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    p_normIncref = incref;
  }
コード例 #5
0
 /**
  * Return a observation index given a serial number index
  *
  * @param serialNumberIndex The index of the serial number to map
  *
  * @return int The observation index mapped to the serial number
  */
 int ObservationNumberList::ObservationNumberMapIndex(int serialNumberIndex) {
   //    if (serialNumberIndex >= 0 && serialNumberIndex < (int) p_indexMap.size()) {
   if(serialNumberIndex >= 0) {
     return p_indexMap.find(serialNumberIndex)->second;
   }
   else {
     QString msg = "Serial Number Index [" + toString(serialNumberIndex) + "] is invalid";
     throw IException(IException::Programmer, msg, _FILEINFO_);
   }
 }
コード例 #6
0
ファイル: ProcessByLine.cpp プロジェクト: corburn/ISIS
  /**
   * Verify input and output cubes and set brick size.
   *
   * @history 4-22-2011 Sharmila Prasad - Ported from StartProcess
   *                             (void funct(Isis::Buffer &inout))
   */
  void ProcessByLine::VerifyCubeInPlace(void){
     // Error checks
     if((InputCubes.size() + OutputCubes.size()) > 1) {
       string m = "You can only specify exactly one input or output cube";
       throw IException(IException::Programmer, m, _FILEINFO_);
     }
     else if((InputCubes.size() + OutputCubes.size()) == 0) {
       string m = "You haven't specified an input or output cube";
       throw IException(IException::Programmer, m, _FILEINFO_);
     }

     // Determine if we have an input or output
     if(InputCubes.size() == 1) {
       SetBrickSize(InputCubes[0]->sampleCount(), 1, 1);
     }
     else {
       SetBrickSize(OutputCubes[0]->sampleCount(), 1, 1);
     }
   }
コード例 #7
0
ファイル: QuickFilter.cpp プロジェクト: corburn/ISIS
  /**
   * This method is used to set the minimum/maximum valid values. Pixels are only
   * considered valid (usable when computing Average and Variance) if they are
   * not special (NULL, LIS, etc) and if they fall within the range of minimum
   * and maximum inclusive. You should only invoke this method once after the
   * object has been constructed. Further invocations will cause unpredictable
   * results. If this method is never called then the defaults are DBL_MIN and
   * DBL_MAX, respectively.
   *
   * @param minimum Minimum valid pixel
   *
   * @param maximum Maximum valid pixel
   *
   * @throws Isis::iException::Programmer
   */
  void QuickFilter::SetMinMax(const double minimum, const double maximum) {
    if(minimum >= maximum) {
      string m = "Minimum must be less than maximum in [QuickFilter::SetMinMax]";
      throw IException(IException::Programmer, m, _FILEINFO_);
    }

    p_minimum = minimum;
    p_maximum = maximum;
    p_lastIndex = -100;
  }
コード例 #8
0
ファイル: ProcessByTile.cpp プロジェクト: corburn/ISIS
  /**
   * This is a helper method for StartProcess() and ProcessCubes().
   */
  void ProcessByTile::SetBrickSizesForProcessCubes() {
    // Make sure we had an image
    if(InputCubes.size() == 0 && OutputCubes.size() == 0) {
      string m = "You have not specified any input or output cubes";
      throw IException(IException::Programmer, m, _FILEINFO_);
    }

    // Make sure all the output images have the same number of bands as
    // the first input/output cube
    for(unsigned int i = 0; i < OutputCubes.size(); i++) {
      if(OutputCubes[i]->bandCount() != InputCubes[0]->bandCount()) {
        string m = "All output cubes must have the same number of bands ";
        m += "as the first input cube or output cube";
        throw IException(IException::Programmer, m, _FILEINFO_);
      }
    }

    ProcessByBrick::SetBrickSize(p_tileSamples, p_tileLines, 1);
  }
コード例 #9
0
ファイル: ControlPointList.cpp プロジェクト: corburn/ISIS
 /**
  * return a list index given a control point id
  *
  * @param ps_cpId The control point id to be searched for
  *
  * @return int The index of the control point id
  */
 int ControlPointList::ControlPointIndex(const QString &psCpId) {
   if(HasControlPoint(psCpId)) {
     return mqCpList.indexOf(QString(psCpId));
   }
   else {
     QString msg = "Requested control point id [" + psCpId + "] ";
     msg += "does not exist in the list";
     throw IException(IException::Programmer, msg, _FILEINFO_);
   }
 }
コード例 #10
0
 /**
  * return an observation number given a filename
  *
  * @param filename The filename to be matched
  *
  * @return QString The observation number corresponding to
  *         the input filename
  */
 QString ObservationNumberList::ObservationNumber(const QString &filename) {
   if(p_fileMap.find(Isis::FileName(filename).expanded()) == p_fileMap.end()) {
     QString msg = "Requested filename [" +
                       Isis::FileName(filename).expanded() + "]";
     msg += "does not exist in the list";
     throw IException(IException::Programmer, msg, _FILEINFO_);
   }
   int index = FileNameIndex(filename);
   return p_pairs[index].observationNumber;
 }
コード例 #11
0
ファイル: TiffImporter.cpp プロジェクト: corburn/ISIS
  /**
   * Construct the importer.
   *
   * @param inputName The name of the input image
   */
  TiffImporter::TiffImporter(FileName inputName) : ImageImporter(inputName) {
    // Open the TIFF image
    m_image = NULL;
    if ((m_image = TIFFOpen(inputName.expanded().toAscii().data(), "r")) == NULL) {
      throw IException(IException::Programmer,
          "Could not open incoming image", _FILEINFO_);
    }

    // Get its constant dimensions.  Note, height seems to get reset to 0 if
    // called before setting width.
    uint32 height;
    TIFFGetField(m_image, TIFFTAG_IMAGELENGTH, &height);
    setLines(height);

    uint32 width;
    TIFFGetField(m_image, TIFFTAG_IMAGEWIDTH, &width);
    setSamples(width);

    TIFFGetField(m_image, TIFFTAG_SAMPLESPERPIXEL, &m_samplesPerPixel);

    // Setup the width and height of the image
    unsigned long imagesize = lines() * samples();
    m_raster = NULL;
    if ((m_raster = (uint32 *) malloc(sizeof(uint32) * imagesize)) == NULL) {
      throw IException(IException::Programmer,
          "Could not allocate enough memory", _FILEINFO_);
    }

    // Read the image into the memory buffer
    if (TIFFReadRGBAImage(m_image, samples(), lines(), m_raster, 0) == 0) {
      throw IException(IException::Programmer,
          "Could not read image", _FILEINFO_);
    }

    // Deal with photometric interpretations
    if (TIFFGetField(m_image, TIFFTAG_PHOTOMETRIC, &m_photo) == 0) {
      throw IException(IException::Programmer,
          "Image has an undefined photometric interpretation", _FILEINFO_);
    }

    setDefaultBands();
  }
コード例 #12
0
ファイル: ControlPointList.cpp プロジェクト: corburn/ISIS
 /**
  * Return a control point id given an index
  *
  * @param piIndex The index of the desired control point id
  *
  * @return QString The control point id returned
  */
 QString ControlPointList::ControlPointId(int piIndex) {
   int size = Size();
   if(piIndex >= 0 && piIndex < size) {
     return (mqCpList.value(piIndex));
   }
   else {
     QString num = toString(piIndex);
     QString msg = "Index [" + num + "] is invalid";
     throw IException(IException::Programmer, msg, _FILEINFO_);
   }
 }
コード例 #13
0
ファイル: QuickFilter.cpp プロジェクト: corburn/ISIS
 /**
  * This method is used to set the minimum number of valid pixels in the boxcar.
  * If the minimum requirement can not be satisfied then the Average and
  * Variance methods will return Isis:NULL8. The default value is zero.
  *
  * @param pixels Number of minimum valid pixels for statistically
  *               computations to occur
  *
  * @throws Isis::iException::Programmer
  */
 void QuickFilter::SetMinimumPixels(const int pixels) {
   if(pixels < 0) {
     string m = "Pixels must be greater than or equal to zero in ";
     m += "[QuickFilter::SetMinimumPixels]";
     throw IException(IException::Programmer, m, _FILEINFO_);
   }
   p_minimumPixels = pixels;
   if(p_minimumPixels > p_width * p_height) {
     p_minimumPixels = p_width * p_height;
   }
 }
コード例 #14
0
ファイル: SmtkMatcher.cpp プロジェクト: corburn/ISIS
 /**
  * @brief Validates the state of the Camera and Gruen algoritm
  *
  * Basically ensures all the pointers are initialized.
  *
  * @author Kris Becker - 5/1/2011
  *
  * @param throwError Throws an exception if user sets this to true.
  *                   Otherwise status can be determined from the return
  *                   value.
  *
  * @return bool  If throwError is not set, this will return status.
  *                 throwError will cause an exception instead if true.
  */
 bool SmtkMatcher::validate(const bool &throwError) const {
   bool isGood(true);
   if (!m_lhCube) isGood = false;
   if (!m_rhCube) isGood = false;
   if (!m_gruen.get()) isGood = false;
   if ((!isGood) && throwError) {
     QString mess = "Images/match algorithm not initialized!";
     throw IException(IException::Programmer, mess, _FILEINFO_);
   }
   return (isGood);
 }
コード例 #15
0
ファイル: ProcessMapMosaic.cpp プロジェクト: corburn/ISIS
  /**
   * Set the output cube to specified file name and specified input images
   * and output attributes and lat,lons
   */
  Isis::Cube *ProcessMapMosaic::SetOutputCube(const QString &inputFile, PvlGroup mapping,
      CubeAttributeOutput &oAtt, const QString &mosaicFile) {
    if (OutputCubes.size() != 0) {
      QString msg = "You can only specify one output cube and projection";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    if (mapping.hasKeyword("UpperLeftCornerX"))
      mapping.deleteKeyword("UpperLeftCornerX");

    if (mapping.hasKeyword("UpperLeftCornerY"))
      mapping.deleteKeyword("UpperLeftCornerY");

    if (p_createMosaic) {
      Pvl newMap;
      newMap.addGroup(mapping);
      int samps, lines, bands;
      delete ProjectionFactory::CreateForCube(newMap, samps, lines, false);

      // Initialize the mosaic
      ProcessByLine p;
      CubeAttributeInput inAtt(inputFile);
      Cube *propCube = p.SetInputCube(inputFile, inAtt);
      bands = propCube->bandCount();

      // If track set, create the origin band
      if (GetTrackFlag()) {
        bands += 1;
      }
      // For average priority, get the new band count
      else if (GetImageOverlay() == AverageImageWithMosaic) {
        bands *= 2;
      }

      p.PropagateHistory(false);
      p.PropagateLabels(false);
      Cube *ocube = p.SetOutputCube(mosaicFile, oAtt, samps, lines, bands);
      p.Progress()->SetText("Initializing mosaic");
      p.ClearInputCubes();

      p.StartProcess(ProcessMapMosaic::FillNull);

      // CreateForCube created some keywords in the mapping group that needs to be added
      ocube->putGroup(newMap.findGroup("Mapping", Pvl::Traverse));
      p.EndProcess();
    }

    Cube *mosaicCube = new Cube();
    AddOutputCube(mosaicCube);
    mosaicCube->open(mosaicFile, "rw");
    mosaicCube->addCachingAlgorithm(new UniqueIOCachingAlgorithm(2));

    return mosaicCube;
  }
コード例 #16
0
ファイル: HrscCamera.cpp プロジェクト: corburn/ISIS
  /**
   * @param filename
   */
  void HrscCamera::ReadLineRates(QString filename) {
    Table timesTable("LineScanTimes", filename);

    if(timesTable.Records() <= 0) {
      QString msg = "Table [LineScanTimes] in [";
      msg += filename + "] must not be empty";
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }

    for(int i = 0; i < timesTable.Records(); i++) {
      p_lineRates.push_back(LineRateChange((int)timesTable[i][2],
                                           (double)timesTable[i][0],
                                           timesTable[i][1]));
    }

    if(p_lineRates.size() <= 0) {
      QString msg = "There is a problem with the data within the Table ";
      msg += "[LineScanTimes] in [" + filename + "]";
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }
  }
コード例 #17
0
ファイル: Latitude.cpp プロジェクト: jlaura/isis3
  /**
   * We're overriding this method in order to do -90/90 degree checking
   *
   * @param angle The numeric value of the angle
   * @param units The units angle is in (radians or degrees typically)
   */
  void Latitude::setAngle(double angle, const Angle::Units &units) {
    // Check for passing 90 degrees if that error checking is on
    if (!IsSpecial(angle) && (m_errors & AllowPastPole) != AllowPastPole) {
      Angle tmpAngle(angle, units);
      if(tmpAngle > Angle(90, Angle::Degrees) ||
         tmpAngle < Angle(-90, Angle::Degrees)) {
        IString msg = "Latitudes past 90 degrees are not valid. The latitude "
            "[" + IString(tmpAngle.degrees()) + " degrees] is not allowed";
        throw IException(IException::Programmer, msg, _FILEINFO_);
      }
    }

    Angle::setAngle(angle, units);
  }
コード例 #18
0
ファイル: Table.cpp プロジェクト: corburn/ISIS
  /**
   * Virtual function to Read the data
   *
   * @param stream InputStream to read data in from
   *
   * @throws Isis::IException::Io - Error reading or preparing to read a record
   */
  void Table::ReadData(std::istream &stream) {
    for (int rec = 0; rec < p_records; rec++) {
      streampos sbyte = (streampos)(p_startByte - 1) +
                        (streampos)(rec * RecordSize());
      stream.seekg(sbyte, std::ios::beg);
      if (!stream.good()) {
        QString msg = "Error preparing to read record [" + toString(rec + 1) +
                     "] from Table [" + p_blobName + "]";
        throw IException(IException::Io, msg, _FILEINFO_);
      }

      char *buf = new char[RecordSize()];
      stream.read(buf, RecordSize());
      if (!stream.good()) {
        QString msg = "Error reading record [" + toString(rec + 1) +
                      "] from Table [" + p_blobName + "]";
        throw IException(IException::Io, msg, _FILEINFO_);
      }

      if (p_swap) p_record.Swap(buf);
      p_recbufs.push_back(buf);
    }
  }
コード例 #19
0
/*------------------------------------------------------------------
 * processResult()
 *    The user controls when dResultBuffer should be processed.
 *-----------------------------------------------------------------*/
IArrestClientMgr & IArrestClientMgr :: processResult ()
{
   IArrest *          arrestWrapper;
   IArrestRecord      arrestRec;
   unsigned short     recOffset, i;
   IString            buffer;

  IFUNCTRACE_DEVELOP();

  if (!dResultBuffer.isWhiteSpace())
  {
   IResultRecord resultRec(dResultBuffer);

   //clear the result list if it's not empty (i.e., if it was set in a previous invocation)
   if (dResultListWrapper->numberOfElements())
      dResultListWrapper->removeAll();

   recOffset = 1;
   for (i=0 ; i < resultRec.numResults(); i++)
   {
      arrestWrapper = new IArrest;

      buffer = resultRec.resultData().subString(
               recOffset,arrestRec.size());
      arrestRec = buffer;

      arrestWrapper->setCharge(arrestRec.charge());
      arrestWrapper->setStatus(arrestRec.status());
      arrestWrapper->setStatusDate(arrestRec.statusDate());

      addResult(arrestWrapper);  //adds arrestWrapper to
                                 //the result list

      recOffset += arrestRec.size();  //get the next arrestRec
   }

   notifyObservers(INotificationEvent(parsedResultId, *this, false));
   if (resultRec.numResults() == 1)
      notifyObservers(INotificationEvent(oneObjectFoundId, *this, false));
   else if (resultRec.numResults() == 0)
   {
      notifyObservers(INotificationEvent(noObjectsFoundId, *this, false));
      throw IException("No aliases exist for the specified suspect."); }
   else
      notifyObservers(INotificationEvent(manyObjectsFoundId, *this, false));
  }

   return *this;
}
コード例 #20
0
ファイル: Hillier.cpp プロジェクト: corburn/ISIS
            /**
             * @brief Initialize class from input PVL and Cube files
             *
             * This method is typically called at class instantiation time,
             * but is reentrant.  It reads the parameter PVL file and
             * extracts Photometric model and Normalization models from it.
             * The cube is needed to match all potential profiles for each
             * band.
             *
             * @author Kris Becker - 2/22/2010
             *
             * @param pvl  Input PVL parameter files
             * @param cube Input cube file to correct
             */
            void Hillier::init ( PvlObject &pvl, Cube &cube ) {
                //  Make it reentrant
                _profiles.clear();
                _bandpho.clear();

                //  Interate over all Photometric groups
                _normProf = DbProfile(pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse));
                _iRef = toDouble(ConfKey(_normProf, "IncRef", toString(30.0)));
                _eRef = toDouble(ConfKey(_normProf, "EmaRef", toString(0.0)));
                _gRef = toDouble(ConfKey(_normProf, "PhaRef", toString(_iRef)));

                PvlObject &phoObj = pvl.findObject("PhotometricModel");
                DbProfile phoProf = DbProfile(phoObj);
                PvlObject::PvlGroupIterator algo = phoObj.beginGroup();
                while (algo != phoObj.endGroup()) {
                    if (algo->name().toLower() == "algorithm") {
                        _profiles.push_back(DbProfile(phoProf, DbProfile(*algo)));
                    }
                    ++algo;
                }

                Pvl *label = cube.label();
                PvlKeyword center = label->findGroup("BandBin", Pvl::Traverse)["Center"];
                QString errs("");
                for (int i = 0; i < cube.bandCount(); i++) {
                    Parameters parms = findParameters(toDouble(center[i]));
                    if (parms.IsValid()) {
                        parms.band = i + 1;
                        //_camera->SetBand(i + 1);
                        parms.phoStd = photometry(parms, _iRef, _eRef, _gRef);
                        _bandpho.push_back(parms);
                    }
                    else { // Appropriate photometric parameters not found
                        ostringstream mess;
                        mess << "Band " << i + 1 << " with wavelength Center = " << center[i]
                                << " does not have PhotometricModel Algorithm group/profile";
                        IException e(IException::User, mess.str(), _FILEINFO_);
                        errs += e.toString() + "\n";
                    }
                }

                // Check for errors and throw them all at the same time
                if (!errs.isEmpty()) {
                    errs += " --> Errors in the input PVL file \"" + pvl.fileName() + "\"";
                    throw IException(IException::User, errs, _FILEINFO_);
                }

                return;
            }
コード例 #21
0
ファイル: FileList.cpp プロジェクト: corburn/ISIS
  /**
   * Writes a list of files to a file.
   *
   * @param list The name of the file to create. The method will overwrite any
   * existing files.
   *
   * @throws Isis::iException::Io File could not be created.
   */
  void FileList::write(FileName outputFileList) {
    // Open the file
    ofstream ostm;
    ostm.open(outputFileList.toString().toAscii().data(), std::ios::out);
    if (!ostm) {
      QString message = Message::FileOpen(outputFileList.toString());
      throw IException(IException::Io, message, _FILEINFO_);
    }

    // Internalize
    write(ostm);

    // Close the file
    ostm.close();
  }
コード例 #22
0
  /**
  * Constructs a LunarAzimuthalEqualArea object
  *
  * @param label This argument must be a Label containing the proper mapping
  *              information as indicated in the Projection class. Additionally,
  *              the LunarAzimuthalEqualArea projection requires the
  *              center longitude to be defined in the keyword CenterLongitude.
  *
  * @throw IException::Unknown - "Invalid label group [Mapping]";
  */
  LunarAzimuthalEqualArea::LunarAzimuthalEqualArea(
    Pvl &label) : TProjection::TProjection(label) {
    try {
      // Try to read the mapping group
      PvlGroup &mapGroup = label.findGroup("Mapping", Pvl::Traverse);

      // Get the max libration
      m_maxLibration = mapGroup["MaximumLibration"];
      m_maxLibration *= PI / 180.0;
    }
    catch(IException &e) {
      QString message = "Invalid label group [Mapping]";
      throw IException(IException::Unknown, message, _FILEINFO_);
    }
  }
コード例 #23
0
ファイル: FileList.cpp プロジェクト: corburn/ISIS
  /**
   * Opens and loads the list of files from a file.
   *
   * @param list Name of the file to open that contains the list of files.
   *
   * @throws Isis::iException::Io - Cannot open file
   */
  void FileList::read(FileName listFile) {
    // Open the file
    ifstream istm;
    istm.open(listFile.toString().toAscii().data(), std::ios::in);
    if(!istm) {
      QString message = Isis::Message::FileOpen(listFile.toString());
      throw IException(IException::Io, message, _FILEINFO_);
    }

    // Internalize
    try {
      read(istm);

      // Close the file
      istm.close();
    }
    catch (IException &e) {
      printf("debugB\n");
      istm.close();
      QString msg = "File [" + listFile.toString() + "] contains no data";
      throw IException(IException::User, msg, _FILEINFO_);
    }

  }
コード例 #24
0
ファイル: SubArea.cpp プロジェクト: corburn/ISIS
  /**
   * Defines the subarea.
   *
   * @param orignl This is the number of lines in the original image.
   *
   * @param origns This is the number of samples in the original image.
   *
   * @param sl This is the line in the original image where the subarea will
   *           start at. This value must be greater than or equal to 1 and
   *           less than or equal to the number of lines in the original
   *           image.
   *
   * @param ss This is the sample in the original image where the subarea
   *           will start at. This value must be greater than or equal to 1
   *           and less than or equal to the number of samples in the
   *           original image.
   *
   * @param el This is the ending line of the subarea to extract from the
   *           original image. This value must be greater than or equal to
   *           sl and less than or equal to the number of lines in the
   *           original image. The actual number of lines that will be in
   *           the subarea will be (el-sl+1)/linc.
   *
   * @param es This is the ending sample of the subarea to extract from the
   *           original image. This value must be greater than or equal to
   *           ss and less than or equal to the number of samples in the
   *           original image. The actual number of samples that will be in
   *           the subarea will be (es-ss+1)/sinc.
   *
   * @param linc This is the line increment that will be used to extract the
   *           subarea from the original image. It must be greater than 0.
   *
   * @param sinc This is the sample increment that will be used to extract
   *           the subarea from the original image. It must be greater than
   *           0.
   *
   */
  void SubArea::SetSubArea(const int orignl, const int origns,
                           const int sl, const int ss, const int el,
                           const int es, const double linc, const double sinc) {

    // Save size of original image file
    p_nl = orignl;
    p_ns = origns;

    // Save the subarea information
    p_sl = sl;
    p_ss = ss;
    p_el = el;
    p_es = es;

    if(p_sl > p_el) {
      string msg = "Invalid start/end line range [sl,el] specified for subarea";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    if(p_ss > p_es) {
      string msg = "Invalid start/end sample range [ss,es] specified for subarea";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    p_linc = linc;
    if(p_linc <= 0.0) {
      string msg = "Invalid line increment [linc] specified for subarea";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    p_sinc = sinc;
    if(p_sinc <= 0.0) {
      string msg = "Invalid sample increment [sinc] specified for subarea";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
  }
コード例 #25
0
ファイル: PolygonSeeder.cpp プロジェクト: corburn/ISIS
  /**
   * Initialize parameters in the PolygonSeeder class using a PVL specification.
   * An example of the PVL required for this is:
   *
   * @code
   * Object = AutoSeed
   *   Group = Algorithm
   *     Name      = Grid
   *     Tolerance = 0.7
   *   EndGroup
   * EndObject
   * @endcode
   *
   * There are many other options that can be set via the pvl and are
   * described in other documentation (see below).
   *
   * @param pvl The pvl object containing the specification
   **/
  void PolygonSeeder::Parse(Pvl &pvl) {

    QString errorSpot;

    try {
      // Get info from Algorithm group
      errorSpot = "Algorithm";
      PvlGroup &algo = pvl.findGroup("PolygonSeederAlgorithm", Pvl::Traverse);

      // algo is such a cool name for a PvlGroup that it begs to be out done
      PvlGroup &invalgo = invalidInput->findGroup("PolygonSeederAlgorithm",
                          Pvl::Traverse);

      // Set the algorithm name
      errorSpot = "Name";
      p_algorithmName = (QString) algo["Name"];

      if(invalgo.hasKeyword("Name"))
        invalgo.deleteKeyword("Name");

      // Set the minimum thickness (Area / max(extent X, extent Y)**2
      errorSpot = "MinimumThickness";
      p_minimumThickness = 0.0;
      if(algo.hasKeyword("MinimumThickness")) {
        p_minimumThickness = (double) algo["MinimumThickness"];
      }

      if(invalgo.hasKeyword("MinimumThickness"))
        invalgo.deleteKeyword("MinimumThickness");

      // Set the minimum area
      errorSpot = "MinimumArea";
      p_minimumArea = 0.0;
      if(algo.hasKeyword("MinimumArea")) {
        p_minimumArea = (double) algo["MinimumArea"];
      }

      if(invalgo.hasKeyword("MinimumArea"))
        invalgo.deleteKeyword("MinimumArea");
    }
    catch(IException &e) {
      QString msg = "Improper format for PolygonSeeder PVL [";
      msg +=  pvl.fileName() + "]. Location [" + errorSpot + "]";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    return;
  }
コード例 #26
0
ファイル: PointPerspective.cpp プロジェクト: jlaura/isis3
  /**
   * Constructs an PointPerspective object
   *
   * @param label This argument must be a Label containing the proper mapping
   *              information as indicated in the Projection class. Additionally,
   *              the point perspective projection requires the center longitude
   *              to be defined in the keyword CenterLongitude.
   *
   * @param allowDefaults If set to false the constructor expects that a keyword
   *                      of CenterLongitude will be in the label. Otherwise it
   *                      will attempt to compute the center longitude using the
   *                      middle of the longitude range specified in the labels.
   *                      Defaults to false.
   *
   * @throws IException::Io
   */
  PointPerspective::PointPerspective(Pvl &label, bool allowDefaults) :
    TProjection::TProjection(label) {
    try {
      // Try to read the mapping group
      PvlGroup &mapGroup = label.findGroup("Mapping", Pvl::Traverse);

      // Compute and write the default center longitude if allowed and
      // necessary
      if ((allowDefaults) && (!mapGroup.hasKeyword("CenterLongitude"))) {
        double lon = (m_minimumLongitude + m_maximumLongitude) / 2.0;
        mapGroup += PvlKeyword("CenterLongitude", toString(lon));
      }

      // Compute and write the default center latitude if allowed and
      // necessary
      if ((allowDefaults) && (!mapGroup.hasKeyword("CenterLatitude"))) {
        double lat = (m_minimumLatitude + m_maximumLatitude) / 2.0;
        mapGroup += PvlKeyword("CenterLatitude", toString(lat));
      }

      // Get the center longitude  & latitude
      m_centerLongitude = mapGroup["CenterLongitude"];
      m_centerLatitude = mapGroup["CenterLatitude"];
      if (IsPlanetocentric()) {
        m_centerLatitude = ToPlanetographic(m_centerLatitude);
      }

      // convert to radians, adjust for longitude direction
      m_centerLongitude *= PI / 180.0;
      m_centerLatitude *= PI / 180.0;
      if (m_longitudeDirection == PositiveWest) m_centerLongitude *= -1.0;

      // Calculate sine & cosine of center latitude
      m_sinph0 = sin(m_centerLatitude);
      m_cosph0 = cos(m_centerLatitude);

      // Get the distance above planet center (the point of perspective from
      // the center of planet), and calculate P
      m_distance = mapGroup["Distance"];
      m_distance *= 1000.;
      m_P = 1.0 + (m_distance / m_equatorialRadius);

    }
    catch(IException &e) {
      QString message = "Invalid label group [Mapping]";
      throw IException(e, IException::Io, message, _FILEINFO_);
    }
  }
コード例 #27
0
 /**
  * Return possible filenames given an observation number
  *
  * @param on  The observation number of the desired filename
  *
  * @return vector<QString> The list of possible filenames
  *         matching the input observation number
  */
 std::vector<QString> ObservationNumberList::PossibleFileNames(const QString &on) {
   std::vector<QString> filenames;
   for(unsigned index = 0; index < p_pairs.size(); index++) {
     if(p_pairs[index].observationNumber == on) {
       filenames.push_back(p_pairs[index].filename);
     }
   }
   if(filenames.size() > 0) {
     return filenames;
   }
   else {
     QString msg = "Requested observation number [" + on + "] ";
     msg += "does not exist in the list";
     throw IException(IException::Programmer, msg, _FILEINFO_);
   }
 }
コード例 #28
0
  /**
    * Create a standard PDS label for type IMAGE using the mrf
    * formatting
    *
    * @author sprasad (2/1/2010)
    */
  Pvl &ProcessExportMiniRFLroPds::StandardPdsLabel(const ProcessExportPds::PdsFileType type) {
    m_label = new Pvl;

    m_formatter = new PvlFormatPds("$lro/translations/mrfExportRoot.typ");
    m_label->setFormat(m_formatter);
    m_label->setTerminator("END");

    if (type == ProcessExportPds::Image) {
      CreateImageLabel();
    }
    else {
      string msg = "Unsupported PDS output type";
      throw IException(IException::User, msg, _FILEINFO_);
    }
    return *m_label;
  }
コード例 #29
0
ファイル: Latitude.cpp プロジェクト: jlaura/isis3
  /**
   * Checks if this latitude value is within the given range.  Defines the
   * range as the change from the minimum latitude to the maximum latitude (an
   * angle), and returns whether the change from the minimum latitude to this
   * latitude is less than or equal to the maximum change allowed (the range).
   *
   * @param min The beginning of the valid latitude range
   * @param max The end of the valid latitude range
   *
   * @return Whether the latitude is in the given range
   */
  bool Latitude::inRange(Latitude min, Latitude max) const {
    // Validity check on the range
    if (min > max) {
      IString msg = "Minimum latitude [" + IString(min.degrees()) +
        "] degrees is greater than maximum latitude [" +
        IString(max.degrees()) + "] degrees";
      throw IException(IException::User, msg, _FILEINFO_);
    }

    // Provide a little wriggle room for precision problems
    Angle epsilon(DBL_EPSILON, Angle::Degrees);
    Latitude adjustedMin = min - epsilon;
    Latitude adjustedMax = max + epsilon;

    // Is this latitude between the min and the max
    return *this >= adjustedMin && *this <= adjustedMax;
  }
コード例 #30
0
ファイル: NonLinearLSQ.cpp プロジェクト: corburn/ISIS
gsl_vector *NonLinearLSQ::NlsqTogsl(const NonLinearLSQ::NLVector &v,
                                    gsl_vector *gv) const {
  if (gv == 0) {
    gv = gsl_vector_alloc(v.dim());
  }
  else if (gv->size != (size_t) v.dim()) {
    ostringstream mess;
    mess << "Size of NL vector (" << v.dim() << ") not same as GSL vector ("
         << gv->size << ")";
    throw IException(IException::Programmer, mess.str(), _FILEINFO_);
  }

  for (int i = 0 ; i < v.dim() ; i++) {
      gsl_vector_set(gv, i, v[i]);
  }
  return (gv);
}