53 #ifdef OSSIM_ID_ENABLED 54 static const char OSSIM_ID[] =
"$Id$";
57 static ossimTrace traceDebug(
"ossimH5Reader:debug");
59 static const std::string LAYER_KW =
"layer";
76 <<
"ossimH5Reader::ossimH5Reader entered..." << std::endl;
77 #ifdef OSSIM_ID_ENABLED 79 <<
"OSSIM_ID: " << OSSIM_ID << endl;
177 vector<char> dataBuffer(clipRectSizeInBytes);
196 if ( float_buffer[i] <= -999.0 ) float_buffer[i] = NP;
201 result->
loadBand((
void*)&dataBuffer.front(), clipRect, band);
231 const char* prefix)
const 249 static const char MODULE[] =
"ossimH5Reader::open";
254 << MODULE <<
" entered..." 284 H5::FileAccPropList access_plist = H5::FileAccPropList::DEFAULT;
288 std::vector<std::string> names;
296 << MODULE <<
" DEBUG\nDataset names:\n";
300 <<
"dataset[" << i <<
"]: " << names[i] <<
"\n";
322 catch(
const H5::FileIException& error )
331 catch(
const H5::DataSetIException& error )
340 catch(
const H5::DataSpaceIException& error )
349 catch(
const H5::DataTypeIException& error )
374 std::vector<std::string>::const_iterator i = names.begin();
375 while ( i != names.end() )
379 H5::DataSet dataset =
m_h5File->openDataSet( *i );
382 H5T_class_t type_class = dataset.getTypeClass();
383 if ( ( type_class == H5T_INTEGER ) || ( type_class == H5T_FLOAT ) )
386 std::vector<ossim_uint32> extents;
388 if ( extents.size() >= 2 )
390 if ( ( extents[0] > 1 ) && ( extents[1] > 1 ) )
407 std::vector<ossimH5ImageDataset>::const_iterator i =
m_entries.begin();
410 std::cout << (*i) << endl;
541 entryNames.push_back(
m_entries[i].getName());
548 entryList.resize( SIZE );
663 H5::DataSet latDataSet =
m_h5File->openDataSet( latName );
664 H5::DataSet lonDataSet =
m_h5File->openDataSet( lonName );
675 if ( proj.
valid() == false )
699 H5::DataSet& latDataSet,
700 H5::DataSet& lonDataSet,
709 if ( model->setGridNodes( &latDataSet,
721 <<
"ossimH5Reader::processCoarseGridProjection caught exception\n" 722 << e.
what() << std::endl;
730 std::string& latName,
731 std::string& lonName )
const 741 std::vector<std::string> datasetNames;
744 if ( datasetNames.size() )
746 std::vector<std::string>::const_iterator i = datasetNames.begin();
747 while ( i != datasetNames.end() )
754 else if ( os.
contains(
"Longitude" ) )
759 if ( latName.size() && lonName.size() )
775 H5::DataSet& latDataSet,
776 H5::DataSet& lonDataSet )
const 788 latDataSet = h5File->openDataSet( latName );
789 lonDataSet = h5File->openDataSet( lonName );
794 std::string group =
"/";
795 std::string key =
"N_GEO_Ref";
802 latLonFile = latLonFile.
dirCat( f );
804 if ( latLonFile.
exists() )
806 if ( H5::H5File::isHdf5( latLonFile.
string() ) )
808 H5::H5File* h5File =
new H5::H5File();
810 H5::FileAccPropList access_plist = H5::FileAccPropList::DEFAULT;
811 h5File->openFile( latLonFile.
string(), H5F_ACC_RDONLY, access_plist );
817 latDataSet = h5File->openDataSet( latName );
818 lonDataSet = h5File->openDataSet( lonName );
838 const std::string GROUP =
"/";
839 const std::string KEY =
"Mission_Name";
844 if ( value ==
"NPP" )
873 if ( property.
valid() )
878 property->valueToString(s);
898 if ( name.
string() == LAYER_KW )
927 std::string group =
"/";
928 std::string key =
"CountryCodes";
933 key =
"country_code";
934 kwl->
addPair( prefix, key, value );
938 key =
"Mission_Name";
942 kwl->
addPair( prefix, key, value );
950 group =
"/Data_Products/VIIRS-DNB-SDR";
951 key =
"Instrument_Short_Name";
955 kwl->
addPair( prefix, key, value );
963 group =
"Data_Products/VIIRS-DNB-SDR/VIIRS-DNB-SDR_Aggr";
964 key =
"AggregateBeginningDate";
968 key =
"AggregateBeginningTime";
972 if ( (value.size() >= 8) && ( time.size() >= 6 ) )
974 std::string dateTime =
976 +
ossimString(value.begin() + 4, value.begin() + 6) +
"-" 977 +
ossimString(value.begin() + 6, value.begin() + 8) +
"T" 978 +
ossimString(time.begin(), time.begin() + 2) +
":" 979 +
ossimString(time.begin() + 2, time.begin() + 4) +
":" 981 key =
"acquisition_date";
982 kwl->
addPair( prefix, key, dateTime );
virtual void loadBand(const void *src, const ossimIrect &src_rect, ossim_uint32 band)
void clear()
Erases the entire container.
virtual bool isSourceEnabled() const
virtual ossimString getLongName() const
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
virtual ossimString getShortName() const
virtual ossim_uint32 getNumberOfBands() const
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
Represents serializable keyword/value map.
ossimFilename expand() const
Method to do file name expansion.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
bool contains(char aChar) const
void addImageDatasetEntries(const std::vector< std::string > &names)
Adds image datasets from list of names.
ossimScalarType getScalarType(const H5::DataSet *dataset)
void allocate()
Allocates the tile.
virtual double getNullPixelValue(ossim_uint32 band=0) const
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
virtual ossimDataObjectStatus getDataObjectStatus() const
static ossimH5Options * instance()
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual bool extendGeometry(ossimImageHandler *handler) const
void ref() const
increment the reference count by one, indicating that this object has another pointer which is refere...
virtual void initialize()
Initialize the data buffer.
ossimH5ImageHandler()
default constructor
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
bool completely_within(const ossimIrect &rect) const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
static ossimImageDataFactory * instance()
virtual ossimDataObjectStatus validate() const
virtual void addMetadata(ossimKeywordlist *kwl, const std::string &prefix) const
Adds metadata to keyword list.
virtual const char * what() const
Returns the error message.
bool getDatasetAttributeValue(H5::H5File *file, const std::string &objectName, const std::string &key, std::string &value)
Gets string value for attribute key.
std::string::size_type size() const
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
unsigned int ossim_uint32
bool isNppMission(H5::H5File *h5File) const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Returns a pointer to a tile given an origin representing the upper left corner of the tile to grab fr...
virtual ossimIrect getImageRectangle() const
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
virtual void getEntryNames(std::vector< ossimString > &entryNames) const
Get the name of entry as a string.
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Get propterty names.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
bool getLatLonDatasets(H5::H5File *h5File, H5::DataSet &latDataSet, H5::DataSet &lonDataSet) const
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
ossimIrect clipToRect(const ossimIrect &rect) const
virtual ossimIrect getImageRectangle(ossim_uint32 reduced_res_level=0) const
Returns the zero based image rectangle for the reduced resolution data set (rrds) passed in...
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
ossimRefPtr< ossimImageData > m_tile
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level=0) const
Returns the number of samples in the image.
ossim_uint32 m_currentEntry
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
void unref() const
decrement the reference count by one, indicating that a pointer to this object is referencing it...
virtual ~ossimH5ImageHandler()
virtual destructor
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Get propterty method.
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual void close()
Close method.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level=0) const
Returns the number of lines in the image.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void makeBlank()
Initializes data to null pixel values.
bool isOpen() const
Derived classes must implement this method to be concrete.
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void completeOpen()
Will complete the opening process.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Set propterty method.
ossimRefPtr< ossimImageHandler > theOverview
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
bool getGroupAttributeValue(H5::H5File *file, const std::string &group, const std::string &key, std::string &value)
Gets string value for attribute key.
ossimRefPtr< ossimProjection > getBilinearProjection(H5::DataSet &latDataSet, H5::DataSet &lonDataSet, const ossimIrect &validRect)
Gets bilinear projection from Latitude, Longitude layer.
ossimRefPtr< ossimProjection > m_projection
ossimRefPtr< ossimProjection > processCoarseGridProjection(H5::DataSet &latDataSet, H5::DataSet &lonDataSet, const ossimIrect &validRect) const
Gets projection from Latitude, Longitude, Height datasets if present.
void getExtents(const H5::DataSet *dataset, std::vector< ossim_uint32 > &extents)
ossim_uint32 area() const
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry()
Method to get geometry from hdf file.
ossimFilename dirCat(const ossimFilename &file) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool isDatasetRenderable(const std::string &datasetName) const
ossimFilename theOverviewFile
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
bool getLatLonDatasetNames(H5::H5File *h5File, std::string &latName, std::string &lonName) const
Get dataset names for Latiitude and Longitude datasets.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual bool open()
open method.
virtual ossimString getClassName() const
#define RTTI_DEF1(cls, name, b1)
Class encapsulates a HDF5 Data set that can be loaded as an image.
bool initialize(const H5::DataSet &dataset, const std::string &datasetName)
Opens datasetName and initializes all data members on success.
virtual ossim_uint32 getNumberOfEntries() const
void getDatasetNames(H5::H5File *file, std::vector< std::string > &names)
virtual ossim_uint32 getCurrentEntry() const
std::vector< ossimH5ImageDataset > m_entries
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
ossimFilename path() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
const ossimString & getName() const
const std::string & string() const
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.