vector<string> LandsatEtmPlusImporter::getBandFilenames(std::string strInHeaderFileName, LandsatEtmPlusImporter::BandSetType bandSet) const
{
   vector<string> bandFilenames;
   if (strInHeaderFileName.empty())
   {
      return bandFilenames;
   }
   FactoryResource<Filename> headerFileName;
   VERIFYRV(headerFileName.get() != NULL, bandFilenames);
   headerFileName->setFullPathAndName(strInHeaderFileName);
   string bandFilePath = headerFileName->getPath();
   
   // get the requested band filenames
   FactoryResource<FileFinder> fileFinder;
   if (bandSet == PANCHROMATIC)
   {
      if (!fileFinder->findFile(bandFilePath, mFieldHPN[FILENAME_1]))
      {
         return vector<string>();
      }
      fileFinder->findNextFile();
      string path;
      fileFinder->getFullPath(path);
      bandFilenames += path;
   }
   else
   {
      vector<string> fileNames;
      fileNames += mFieldHRF[FILENAME_1],
                   mFieldHRF[FILENAME_2],
                   mFieldHRF[FILENAME_3],
                   mFieldHRF[FILENAME_4],
                   mFieldHRF[FILENAME_5],
                   ((bandSet == LOW_GAIN) ? mFieldHTM[FILENAME_1] : mFieldHTM[FILENAME_2]),
                   mFieldHRF[FILENAME_6];
      for (vector<string>::const_iterator fileName = fileNames.begin(); fileName != fileNames.end(); ++fileName)
      {
         if (!fileFinder->findFile(bandFilePath, *fileName))
         {
            return vector<string>();
         }
         fileFinder->findNextFile();
         string path;
         fileFinder->getFullPath(path);
         bandFilenames += path;
      }
   }
   return bandFilenames;
}
Beispiel #2
0
bool SkinsPlugIn::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   MenuBar* pMenu = Service<DesktopServices>()->getMainMenuBar();
   QAction* pBefore = pMenu->getMenuItem("&View/&Status Bar");
   mpSkinsMenu = pMenu->addMenu("&View/S&kins", pBefore);
   mpSkinsMenu->setStatusTip("Change the current application skin.");
   VERIFY(mpSkinsMenu);
   VERIFY(connect(mpSkinsMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeSkin(QAction*))));
   
   QActionGroup* pActionGroup = new QActionGroup(mpSkinsMenu);
   pActionGroup->setExclusive(true);
   
   // Add default menu entries
   mpDefaultAction = mpSkinsMenu->addAction("Default");
   mpDefaultAction->setCheckable(true);
   pActionGroup->addAction(mpDefaultAction);

   // Scan the skins directory
   const Filename* pPath = ConfigurationSettings::getSettingSupportFilesPath();
   FactoryResource<FileFinder> pFinder;
   VERIFY(pPath && pFinder.get());
   pFinder->findFile(pPath->getFullPathAndName() + "/Skins", "*.css", true);
   while (pFinder->findNextFile())
   {
      std::string title;
      pFinder->getFileTitle(title);
      QAction* pAction = mpSkinsMenu->addAction(QString::fromStdString(title));
      pAction->setCheckable(true);
      pActionGroup->addAction(pAction);
   }
   pFinder->findFile(pPath->getFullPathAndName() + "/Skins", "*.rcc", true);
   while (pFinder->findNextFile())
   {
      std::string fullPath;
      std::string fileTitle;
      pFinder->getFullPath(fullPath);
      pFinder->getFileTitle(fileTitle);
      QString path = QString::fromStdString(fullPath);
      QString root = "/" + QString::fromStdString(fileTitle);
      if (QResource::registerResource(path, root))
      {
         mRegisteredResources[root] = path;
      }
   }
   mDefaultStyleSheet = qApp->styleSheet();
   mpDefaultAction->setChecked(true);
   return true;
}
Beispiel #3
0
 int setRasterLayerColormapName(Layer* pLayer, const char* pName)
 {
    RasterLayer* pRaster = dynamic_cast<RasterLayer*>(pLayer);
    if (pRaster == NULL)
    {
       setLastError(SIMPLE_BAD_PARAMS);
       return 1;
    }
    std::string name(pName);
    ColorMap map;
    if (!map.loadFromFile(name))
    {
       // see if name is a colormap name
       const Filename* pSupportFiles = Service<ConfigurationSettings>()->getSettingSupportFilesPath();
       if (pSupportFiles == NULL)
       {
          setLastError(SIMPLE_OTHER_FAILURE);
          return 1;
       }
       std::string mapDir = pSupportFiles->getFullPathAndName() + SLASH + "ColorTables" + SLASH;
       if (!map.loadFromFile(mapDir + name) && !map.loadFromFile(mapDir + name + ".clu")
        && !map.loadFromFile(mapDir + name + ".cgr"))
       {
          // scan all the default files and check for a valid name
          bool located = false;
          FactoryResource<FileFinder> pFinder;
          pFinder->findFile(mapDir, "*.c??");
          while (pFinder->findNextFile())
          {
             std::string filePath;
             pFinder->getFullPath(filePath);
             if (map.loadFromFile(filePath) && map.getName() == name)
             {
                located = true;
                break;
             }
          }
          if (!located)
          {
             setLastError(SIMPLE_NOT_FOUND);
             return 1;
          }
       }
    }
    pRaster->setColorMap(map);
    setLastError(SIMPLE_NO_ERROR);
    return 0;
 }
bool LandsatEtmPlusImporter::readHeader(const string& strInFstHeaderFileName)
{
   if (strInFstHeaderFileName.empty())
   {
      return false;
   }

   //The HTM header file contains information for Band 6 Channel 1 and 2. 
   //This set extracts the info needed to process HTM(band 6) header
   mFieldHTM.clear();
   string baseFileName = strInFstHeaderFileName.substr(0, strInFstHeaderFileName.length() - 7);
   FactoryResource<Filename> filename;
   filename->setFullPathAndName(baseFileName);
   FactoryResource<FileFinder> fileFinder;
   string htmFileName = filename->getFileName() + "HTM.FST";
   if (fileFinder->findFile(filename->getPath(), htmFileName))
   {
      fileFinder->findNextFile();
      fileFinder->getFullPath(htmFileName);
   }

   LargeFileResource htmFile;
   if (htmFile.open(htmFileName, O_RDONLY, S_IREAD))
   {
      //process HTM header
      vector<char> buf(5120);
      size_t count = static_cast<size_t>(htmFile.read(&buf.front(), 5120));
      VERIFY(htmFile.eof());
      string htmHeaderFull(&buf.front(), count);
      vector<string> htmHeaderLines = StringUtilities::split(htmHeaderFull, '\n');

      if (!parseHeader(htmHeaderLines, mFieldHTM)) //parse band 6 header
      {
         mFieldHTM.clear();
      }
   }
   htmFile.close();

   // The HRF Header file contains the parameters for Bands 1-5 and 7.  
   mFieldHRF.clear();
   string hrfFileName = filename->getFileName() + "HRF.FST";
   if (fileFinder->findFile(filename->getPath(), hrfFileName))
   {
      fileFinder->findNextFile();
      fileFinder->getFullPath(hrfFileName);
   }

   LargeFileResource hrfFile;
   if (hrfFile.open(hrfFileName, O_RDONLY, S_IREAD))
   {
      //process HRF header
      vector<char> buf(5120);
      size_t count = static_cast<size_t>(hrfFile.read(&buf.front(), 5120));
      VERIFY(hrfFile.eof());
      string hrfHeaderFull(&buf.front(), count);
      vector<string> hrfHeaderLines = StringUtilities::split(hrfHeaderFull, '\n');

      if (!parseHeader(hrfHeaderLines, mFieldHRF)) //parse bands 1-5 and 7 header
      {
         mFieldHRF.clear();
      }
   }
   hrfFile.close();

   // The HPN Header file contains the parameters for Band 8.
   mFieldHPN.clear();
   string hpnFileName = filename->getFileName() + "HPN.FST";
   if (fileFinder->findFile(filename->getPath(), hpnFileName))
   {
      fileFinder->findNextFile();
      fileFinder->getFullPath(hpnFileName);
   }

   LargeFileResource hpnFile;
   if (hpnFile.open(hpnFileName, O_RDONLY, S_IREAD))
   {
      //process HPN header
      vector<char> buf(5120);
      size_t count = static_cast<size_t>(hpnFile.read(&buf.front(), 5120));
      VERIFY(hpnFile.eof());
      string hpnHeaderFull(&buf.front(), count);
      vector<string> hpnHeaderLines = StringUtilities::split(hpnHeaderFull, '\n');

      if (!parseHeader(hpnHeaderLines, mFieldHPN)) //parse band 8 header
      {
         mFieldHPN.clear();
      }
   }
   hpnFile.close();

   return (!mFieldHRF.empty() || !mFieldHTM.empty() || !mFieldHPN.empty());
}