bool ossimPlanetOssimImage::loadFile(const std::string& inputFile,
                                   ossimPlanetImage& image)
{
   if(theHandler.valid())
   {
      theHandler->close();
      if(!theHandler->open(ossimFilename(inputFile)))
      {
         theHandler = 0;
      }
   }
   ossimRefPtr<ossimImageData> data;
   if(!theHandler.valid())
   {
       theHandler = ossimImageHandlerRegistry::instance()->open(ossimFilename(inputFile.c_str()));
   }
   if(theHandler.valid())
   {
      data = theHandler->getTile(theHandler->getBoundingRect());
      if(data.valid())
      {
         image.fromOssimImage(data);
         return true;
      }
   }

   return false;
}
osg::ref_ptr<ossimPlanetSrtmElevationDatabase::SrtmInfo> ossimPlanetSrtmElevationDatabase::getInfo(const std::string& srtmName)
{
   SrtmFilePointerList::iterator iter = theFilePointers.find(srtmName);

   if(iter != theFilePointers.end())
   {
      iter->second->theTimeStamp = osg::Timer::instance()->tick();

      return iter->second;
   }
   osg::ref_ptr<SrtmInfo> info     = new SrtmInfo;
   
   ossimFilename srtmFile = ossimFilename(theLocation).dirCat(ossimFilename(srtmName));
   ossimSrtmSupportData supportData;
   if(supportData.setFilename(srtmFile))
   {
      info->theMinLat = std::floor(supportData.getSouthwestLatitude());
      info->theMinLon = std::floor(supportData.getSouthwestLongitude());
      info->theMaxLat = info->theMinLat + 1.0;
      info->theMaxLon = info->theMinLon + 1.0;
   }
   else
   {
      return 0;
   }
   
   info->theTimeStamp  = osg::Timer::instance()->tick();
   info->theFilename   = srtmFile.string();
   info->theSrtmHandler = new ossimSrtmHandler();
   info->theSrtmHandler->open(srtmFile);
   theFilePointers.insert(std::make_pair(srtmName, info));
   shrinkFilePointers();

   return info;
}
osg::ref_ptr<ossimPlanetDtedElevationDatabase::DtedInfo> ossimPlanetDtedElevationDatabase::getInfo(const std::string& name)
{
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theDtedInfoMutex);
   DtedFilePointerList::iterator iter = theFilePointers.find(name);

   if(iter != theFilePointers.end())
   {
      iter->second->theTimeStamp = osg::Timer::instance()->tick();

      return iter->second;
   }
   osg::ref_ptr<DtedInfo> info     = new DtedInfo;
   
   ossimFilename dtedFile = ossimFilename(theLocation).dirCat(ossimFilename(name));

   ifstream in;

   in.open(dtedFile.c_str(), std::ios::binary|std::ios::in);

   if(in.fail()) return 0;

   ossimDtedVol vol(in);
   ossimDtedHdr hdr(in);
   ossimDtedUhl uhl(in);

   in.close();
   
   if((uhl.getErrorStatus() == ossimErrorCodes::OSSIM_ERROR))
   {
      return 0;
   }
   info->theNumLonLines  = uhl.numLonLines();
   info->theNumLatPoints = uhl.numLatPoints();
   info->theLatSpacing   = uhl.latInterval();
   info->theLonSpacing   = uhl.lonInterval();
   info->theMinLat = uhl.latOrigin();
   info->theMinLon = uhl.lonOrigin();
   info->theMaxLat = info->theMinLat + info->theLatSpacing*(info->theNumLatPoints-1);
   info->theMaxLon = info->theMinLon + info->theLonSpacing*(info->theNumLonLines-1);
   info->theTimeStamp  = osg::Timer::instance()->tick();
   info->theFilename   = dtedFile;
   info->theHandler = new ossimDtedHandler(dtedFile, false);
   //info->theHandler->setMemoryMapFlag(false);
   theFilePointers.insert(std::make_pair(name, info));
   shrinkFilePointers();
   
   return info;
   
}
Esempio n. 4
0
bool pyossimtest::SingleImageChain::setHistogram(const std::string& his)
{
   bool result = false;
   if ( isOpen() )
   {
      ossimRefPtr<ossimHistogramRemapper> hr = m_img->getHistogramRemapper();
      if ( hr.valid() == false )
      {
         //---
         // If the chain is not created check for the need for a band selector as
         // it should be in front of the histogram in the chain in case bands are
         // filtered out.
         //---
         const ossim_uint32 IMG_BANDS = getNumberOfBands();
         if ( IMG_BANDS > 1 )
         {
            ossimRefPtr<ossimBandSelector> bs = m_img->getBandSelector();
            if ( bs.valid() == false )
            {
               m_img->addBandSelector();
            }
         }
         m_img->addHistogramRemapper();
         hr = m_img->getHistogramRemapper();
      }
      if ( hr.valid() )
      {
         result = hr->openHistogram( ossimFilename(his) );
      }
   }
   return result;
}
ossimFilename ossimLandsatTileSource::getBandFilename(ossim_uint32 idx)const
{
   ossim_uint32 maxIdx = getNumberOfInputBands();

   if(!theFfHdr||(idx > maxIdx))
   {
      return "";
   }

   ossimFilename path = getFilename().path();
   ossimString filename = theFfHdr->getBandFilename(idx);
   filename = filename.trim();
   ossimFilename file = path.dirCat(filename);

   if (file.exists())
   {
      return file;
   }

   // Try downcased name.
   file = path.dirCat(filename.downcase());
   if (file.exists())
   {
      return file;
   }
   
   // Try upcase name.
   file = path.dirCat(filename.upcase());
   if (file.exists())
   {
      return file;
   }
   
   return ossimFilename();
}
Esempio n. 6
0
bool oms::ImageModel::setModelFromFile(const std::string& file,
                                       unsigned int entry)
{
   bool result = false;
   thePrivateData->theImageHandler = ossimImageHandlerRegistry::instance()->open(ossimFilename(file));
   if(thePrivateData->theImageHandler.valid())
   {
      if(thePrivateData->theImageHandler->setCurrentEntry(entry))
      {
         ossimKeywordlist kwl;
         thePrivateData->theImageGeometry = thePrivateData->theImageHandler->getImageGeometry();
         thePrivateData->theBoundingRect = thePrivateData->theImageHandler->getBoundingRect();
         
         if(thePrivateData->theImageGeometry.valid()&&
            thePrivateData->theImageGeometry->getProjection())
         {
            result = false;
         }
      }
   }
   if(!result)
   {
      thePrivateData->theImageHandler  = 0;
      thePrivateData->theImageGeometry = 0;
   }
   return result;
}
Esempio n. 7
0
bool ossimVpfLibrary::openLibrary(ossimVpfDatabase* database,
                                  const ossimString& name,
                                  const ossimFilename& libraryPath)
{
   bool returnCode = true;

   theNumberOfCoverages = 0;
   theLibraryName = "";
   theLibraryNameFullPath = "";
   
   
   theLibraryName         = name;
   theLibraryNameFullPath =  libraryPath;
   theDatabase            = database;
   
   if(!ossimFilename(theLibraryNameFullPath).exists())
   {
      returnCode = false;
   }
   if(returnCode)
   {
      setCoverageNames();
      
      ossimVpfTable table;
      
      theNumberOfCoverages = (ossim_uint32)theCoverageNames.size();
      returnCode = (theNumberOfCoverages> 0);
   }
   
   return returnCode;
}
Esempio n. 8
0
//*****************************************************************************
//  METHOD: ossimSensorModelFactory::create(kwl, prefix)
//*****************************************************************************
ossimProjection* ossimSensorModelFactory::createProjection(const ossimKeywordlist &keywordList,
                                                           const char *prefix) const
{
   ossimRefPtr<ossimProjection> result;

   //
   // Permit specification of geometry file name in lieu of type:
   //
   const char*  value = keywordList.find(prefix, ossimKeywordNames::GEOM_FILE_KW);
   if (value)
   {
      result = createProjection(ossimFilename(value), 0);
   }
   //
   // Search for occurence of "type" keyword:
   //
   else
   {
      value = keywordList.find(prefix, ossimKeywordNames::TYPE_KW);
      if(value)
      {
         result = createProjection(ossimString(value));
         if(result.valid())
         {
            if(!result->loadState(keywordList, prefix))
            {
               result = 0;
            }
        }
      }
   }
   
   return result.release();
}
Esempio n. 9
0
void ExportImageDialog::fileTypeActivated(int idx)
{
    if(idx == 0)
    {
        m_writer = 0;
        populatePropertyView();
        m_fileButton->setEnabled(false);
    }
    else
    {
        ossimFilename oldFilename = m_writer.valid()?m_writer->getFilename():ossimFilename();
        ossimRefPtr<ossimObject> obj = ossimObjectFactoryRegistry::instance()->createObject(ossimString(m_fileTypes->itemText(idx).toStdString()));
        m_writer = dynamic_cast<ossimImageFileWriter*> (obj.get());
        if(m_writer.valid())
        {
            m_fileButton->setEnabled(true);
            ossimString ext = m_writer->getExtension();
            if(!oldFilename.empty())
            {
                oldFilename.setExtension(ext);
            }
            m_writer->setFilename(oldFilename);
        }
        populatePropertyView();
    }
}
Esempio n. 10
0
void oms::SingleImageChain::setHistogramFile(const std::string& file)
{
   if(theHistogramRemapper)
   {
      theHistogramRemapper->setEnableFlag(true);
      theHistogramRemapper->openHistogram(ossimFilename(file));
   }
}
Esempio n. 11
0
bool ossimVpfDatabase::openDatabase(const ossimFilename& filename)
{
   bool result = true;

   ossimFilename tempFilename = filename;

   tempFilename.convertBackToForwardSlashes();

   // we should have two table to look at for the database.
   // 1) database header (dht) 2) and the Library attribute (lat)
   theDatabaseHeaderTable   = ossimFilename(tempFilename.path()).dirCat("/dht");
   theLibraryAttributeTable = ossimFilename(tempFilename.path()).dirCat("/lat");

   if(theDatabaseHeaderTable.exists() &&
      theLibraryAttributeTable.exists())
   {
      ossimVpfTable table;
      // now lets see if they are valid tables
      result = table.openTable(theDatabaseHeaderTable);
      
      if(result&&
         !ossimVpfDatabaseHeaderTableValidator().isValid(table))
      {
         result =  false;
      }
      
      result = table.openTable(theLibraryAttributeTable);
      if((result) &&!ossimVpfLibraryAttributeTableValidator().isValid(table))
      {
         result = false;
      }
   }
   else
   {
      result = false;
   }

   if(result)
   {
      theOpenedFlag = true;
      initializeLibraryList();
   }
   
   return result;
}
Esempio n. 12
0
bool oms::ImageStager::open(const std::string& filename)
{
   thePrivateData->theFilename = ossimFilename(filename);
   thePrivateData->theHandler = 0;
   thePrivateData->theEntryId = -1;
   
   thePrivateData->setDefaults();
   return thePrivateData->theHandler.valid();
}
bool ossimGeneralRasterElevationDatabase::open(const ossimString& connectionString)
{
   bool result = false;
   ossimFilename file = ossimFilename(connectionString);
   m_connectionString = connectionString;
   result = openGeneralRasterDirectory(file);
   
   return result;
}
bool ossimDtedElevationDatabase::open(const ossimString& connectionString)
{
   bool result = false;
   ossimFilename file = ossimFilename(connectionString);
   
   result = openDtedDirectory(file);

   return result;
}
Esempio n. 15
0
void oms::SingleImageChain::setHistogramFileAndMode(const std::string& file, const std::string& mode)
{
   if(theHistogramRemapper&&ossimFilename(file).exists())
   {
      setHistogramFile(file);
      setHistogramStretchMode(mode);
      ossimRefreshEvent evt(theHistogramRemapper);
      theHistogramRemapper->propagateEventToOutputs(evt);
   }
}
bool ossimImageSourceHistogramFilter::loadState(const ossimKeywordlist& kwl,
                                                const char* prefix)
{
   const char* proprietaryName = kwl.find(prefix, PROPRIETARY_FILENAME_KW);
   const char* ossimName       = kwl.find(prefix, HISTOGRAM_FILENAME_KW);
   bool result = true;
   ossimFilename file;

   if(proprietaryName)
   {
       theFilename = ossimFilename(proprietaryName);
   }
   else if(ossimName)
   {
      if(!theHistogram)
      {
         theHistogram = new ossimMultiResLevelHistogram;
      }
      theFilename = ossimFilename(ossimName);
      
   }

   if(theFilename.exists()&&(theFilename!=""))
   {
      if(!theHistogram)
      {
         theHistogram = new ossimMultiResLevelHistogram;
      }
      result = theHistogram->importHistogram(theFilename);
   }
   if(theHistogram.valid())
   {
      theHistogram->setBinCount(0, 0);
   }
   
   result =  ossimImageSourceFilter::loadState(kwl, prefix);

   setNumberOfInputs(2);
   theInputListIsFixedFlag = true;
   
   return result;
}
Esempio n. 17
0
bool ossimNitfInfo::open(std::shared_ptr<ossim::istream>& str,
                         const std::string& connectionString)
{
   bool result = false;
   if ( str )
   {
      m_nitfFile = std::make_shared<ossimNitfFile>();
      result = m_nitfFile->parseStream(ossimFilename(connectionString), *str);
   }
   return result;
}
bool ossimGeneralRasterWriter::loadState(const ossimKeywordlist& kwl,
                                         const char* prefix)
{
   const char* value;
   
   value = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
   if(value)
   {
      setFilename(ossimFilename(value));
   }
   
   value = kwl.find(prefix, ossimKeywordNames::INPUT_RR_LEVEL_KW);
   if(value)
   {
      theRlevel = atoi(value);
   }

   if(ossimImageFileWriter::loadState(kwl, prefix))
   {
      if( (theOutputImageType!="general_raster_bip")      &&
          (theOutputImageType!="general_raster_bil")      &&
          (theOutputImageType!="general_raster_bsq")      &&
          (theOutputImageType!="general_raster_bip_envi") &&
          (theOutputImageType!="general_raster_bil_envi") &&
          (theOutputImageType!="general_raster_bsq_envi")
         )
      {
         theOutputImageType = "general_raster_bsq";
      }
   }
   else
   {
      return false;
   }
   const char* outputByteOrder = kwl.find(prefix, ossimKeywordNames::BYTE_ORDER_KW);
   theOutputByteOrder = ossimEndian().getSystemEndianType();
   if(outputByteOrder)
   {
      ossimString byteOrder = outputByteOrder;
      byteOrder = byteOrder.downcase();
      if(byteOrder.contains("little"))
      {
         theOutputByteOrder = OSSIM_LITTLE_ENDIAN;
      }
      else if(byteOrder.contains("big"))
      {
         theOutputByteOrder = OSSIM_BIG_ENDIAN;
      }
   }
   
   return true;
}
Esempio n. 19
0
bool oms::Video::open(const std::string& file)
{
   close();
   ossimRefPtr<ossimPredatorVideo> video = new ossimPredatorVideo;
	
   if(video->open(ossimFilename(file)))
   {
      theVideoInfo->theInputFile = file;
      theVideoInfo->theSource = video.get();
   }
	
   return theVideoInfo->theSource.valid();
}
Esempio n. 20
0
bool pyossimtest::SingleImageChain::open(const std::string& file, pyossimtest_int32 entry)
{
   bool result = false;
   if ( m_img->open(ossimFilename(file)) )
   {
      ossimRefPtr<ossimImageHandler> ih = m_img->getImageHandler();
      if ( ih.valid() )
      {
         result = ih->setCurrentEntry( static_cast<ossim_uint32>(entry) );
      }
   }
   return result;
}
bool ossimDtedElevationDatabase::loadState(const ossimKeywordlist& kwl, const char* prefix )
{
   bool result = ossimElevationCellDatabase::loadState(kwl, prefix);
   if(result)
   {
      if(!m_connectionString.empty()&&ossimFilename(m_connectionString).exists())
      {
         // Look for "extension" keyword.
         std::string pref = (prefix?prefix:"");
         std::string key = "extension";
         ossimString val = ossimPreferences::instance()->preferencesKWL().findKey( pref, key );
         if ( val.size() )
         {
            m_extension = val;
         }
         else if ( traceDebug() )
         {
            ossimNotify(ossimNotifyLevel_DEBUG)
               << "ossimDtedElevationDatabase::loadState: NOTICE"
               << "Key lookup for \"extension\" failed!\n"
               << "Can be set in ossim preferences.  Example:\n"
               << "elevation_manager.elevation_source0.extension: .dt2";
         }

         key = "upcase";
         val = ossimPreferences::instance()->preferencesKWL().findKey( pref, key );
         if ( val.size() )
         {
            m_upcase = val.toBool();
         }
         else if ( traceDebug() )
         {
            ossimNotify(ossimNotifyLevel_DEBUG)
               << "ossimDtedElevationDatabase::loadState: NOTICE"
               << "Key lookup for \"upcase\" failed!\n"
               << "Can be set in ossim preferences.  Example:\n"
               << "elevation_manager.elevation_source0.upcase: false";
         }
         

         result = open(m_connectionString);
      }
      else
      {
         // can't open the connection because it does not exists or empty
         result = false;
      }
   }
   
   return result;
}
Esempio n. 22
0
const ossimPluginLibrary* ossimSharedPluginRegistry::getPlugin(const ossimFilename& filename)const
{
   ossim_uint32 idx = 0;
   ossimFilename fileOnly = filename.file();
   for(idx = 0; idx < theLibraryList.size();++idx)
   {
      if(fileOnly == ossimFilename(theLibraryList[idx]->getName()).file())
      {
         return theLibraryList[idx].get();
      }
   }
   
   return 0;
}
Esempio n. 23
0
void ossimIndexToRgbLutFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(property.valid())
   {
      ossimString value = property->valueToString();
      value = value.trim();

      if(property->getName() == "LUT file")
      {
         setLut(ossimFilename(property->valueToString()));
      }
      else
      {
         ossimImageSourceFilter::setProperty(property);
      }
   }
}
static void setDescription(ossimString& description)
{
   std::string pError;
   ossimFilename pluginDir = ossimCsmSupport::instance()->csmPluginDirectory();
   
   if (!pluginDir.empty()) 
   {
      if(*(pluginDir.begin()+(pluginDir.size()-1)) != pluginDir.getPathSeparator())
      {
         pluginDir = ossimFilename(pluginDir + pluginDir.getPathSeparator());
      }
   }
   std::vector<string> pluginNames;
   if(!pluginDir.empty()&&pluginDir.exists())
   {
      pluginNames = CSMSensorModelLoader::getAvailablePluginNames(pluginDir.c_str(), pError );
   }

   std::ostringstream out;
   out  << "Community Sensor Model Plugin\n" << "\nAvailable plugins are: \n\n";
      	 
   if(!pError.empty())
   {
      out << "ERROR loading! Result = " << pError << "\n";
      description = out.str();
      return;
   }
   if(pluginNames.empty())
   {
      out << "No CSM plugins available.  Please make sure your ossim preference variable csm_plugin_path\n"
          << " is set or an environment variable CSM_PLUGIN_PATH is set\n";
   }
   ossim_uint32 idx = 0;
   for(idx = 0; idx < pluginNames.size(); ++idx)
   {
      out << "\t" << pluginNames[idx] << " , supported models:\n";
      std::vector<string> sensorModelNames = CSMSensorModelLoader::getAvailableSensorModelNames( pluginDir, pluginNames[idx].c_str(),  pError );    
      ossim_uint32 idx2=0;
      for(idx2 = 0; idx2 < sensorModelNames.size(); ++idx2)
      { 
         out << "\t\t" << sensorModelNames[idx2] << "\n";
      }       
   }
   description = out.str();
}
Esempio n. 25
0
std::string oms::Mosaic::addInputFile(const std::string& filename,
                                      const std::string& entryId)
{
    std::string id = "";
    ossimRefPtr<MosaicImageChain> chain = new MosaicImageChain();
    chain->theHandler = ossimImageHandlerRegistry::instance()->open(ossimFilename(filename));
    if(chain->theHandler.valid())
    {
        if(!entryId.empty())
        {
            chain->theHandler->setCurrentEntry(ossimString(entryId).toUInt32());
        }
        thePrivateData->theImageChainList.push_back(chain.get());
        id = filename+":"+entryId;
        thePrivateData->theIndexMapping.insert(std::make_pair(id, chain));
    }
    return id;
}
bool ossimDtedElevationDatabase::loadState(const ossimKeywordlist& kwl, const char* prefix )
{
   bool result = ossimElevationDatabase::loadState(kwl, prefix);
   if(result)
   {
      if(!m_connectionString.empty()&&ossimFilename(m_connectionString).exists())
      {
         result = open(m_connectionString);
      }
      else
      {
         // can't open the connection because it does not exists or empty
         result = false;
      }
   }
   
   return result;
}
Esempio n. 27
0
void ossimNBandToIndexFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(property->getName() == ossimKeywordNames::FILENAME_KW)
   {
      ossimKeywordlist kwl;
      if(kwl.addFile(ossimFilename(property->valueToString())))
      {
         theLut = new ossimNBandLutDataObject;
         theLut->loadState(kwl);
      }
   }
   else if(property->getName() == KEEP_QUANTIZED_VALUE_FLAG_KW)
   {
      theKeepQuantizedValueFlag = property->valueToString().toBool();
   }
   else
   {
      ossimImageSourceFilter::setProperty(property);
   }
}
Esempio n. 28
0
bool ossimSharedPluginRegistry::isLoaded(const ossimFilename& filename) const
   
{
   ossimFilename fileOnly = filename.file();
   bool result = false;
   ossim_uint32 count = getNumberOfPlugins();
   for (ossim_uint32 i = 0; i < count; ++i)
   {
      const ossimPluginLibrary* pi = getPlugin(i);
      if (pi)
      {
         if (fileOnly == ossimFilename(pi->getName()).file())
         {
            result = true;
            break;
         }
      }
   }
   return result;
}
Esempio n. 29
0
void ossimjni::Info::getImageInfo( const std::string& file,
                                   bool dumpFlag,
                                   bool dnoFlag,
                                   bool imageGeomFlag,
                                   bool imageInfoFlag,
                                   bool metaDataFlag,
                                   bool paletteFlag,
                                   ossimjni::Keywordlist* kwl) const
{
   if ( kwl )
   {
      m_info->getImageInfo(ossimFilename(file),
                           dumpFlag,
                           dnoFlag,
                           imageGeomFlag,
                           imageInfoFlag,
                           metaDataFlag,
                           paletteFlag,
                           *(kwl->getKeywordlist()) );
   }
}
Esempio n. 30
0
bool ossimRpcModel::setupOptimizer(const ossimString& init_file)
{
    ossimKeywordlist kwl;

    if(kwl.addFile(ossimFilename(init_file)))
    {
        return loadState(kwl);
    }
    else
    {
        ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()->createProjection(init_file);
        if(proj.valid())
        {
            kwl.clear();
            proj->saveState(kwl);

            return loadState(kwl);
        }
    }

    return false;
}