Skip to content

Commit

Permalink
Fixed problems with coarse grid initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarkramer committed Aug 17, 2016
1 parent a92ee21 commit 10335f0
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 220 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ if (BUILD_OSSIM_HDF5_SUPPORT)
else ( HDF5A_FOUND )
message( WARNING "Could not find optional HDF5A package. Excluding native support." )
endif ( HDF5A_FOUND )
endif (BUILD_OSSIM_HDF5_SUPPORT)
else (BUILD_OSSIM_HDF5_SUPPORT)
message( STATUS "Native HDF5 support was not requested. If you want HDF5 support, set the environment BUILD_OSSIM_HDF5_SUPPORT=ON..." )
endif ( BUILD_OSSIM_HDF5_SUPPORT )



#---
# Call the OSSIM macros in OssimUtilities.cmake
Expand Down
2 changes: 2 additions & 0 deletions include/ossim/hdf5/ossimHdf5.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class OSSIMDLLEXPORT ossimHdf5 : public ossimReferenced
const H5::Group* group=0,
bool recursive=false);

ossimByteOrder getByteOrder( const H5::AbstractDs* obj );

private:
ossimFilename m_filename;
H5::H5File* m_h5File;
Expand Down
13 changes: 8 additions & 5 deletions include/ossim/hdf5/ossimHdf5GridModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <ossim/hdf5/ossimHdf5.h>
#include <string>

class ossimHdf5ImageHandler;

/******************************************************************************
*
Expand All @@ -41,20 +42,22 @@ class OSSIM_PLUGINS_DLL ossimHdf5GridModel : public ossimCoarseGridModel
virtual ~ossimHdf5GridModel();

/** Initializes from an open HDF5 file */
bool initialize(ossimRefPtr<ossimHdf5>& hdf5);
bool initialize(ossimHdf5* hdf5, ossimHdf5ImageHandler* handler);

protected:

bool initCoarseGrid(ossimHdf5* hdf5, const char* datasetName, ossimDblGrid& coarseGrid);
bool initCoarseGrid(const char* datasetName, const ossimIrect& validImageRect,
ossimDblGrid& coarseGrid);

bool m_crossesDateline;
bool crossesDateline();

//---
// This polygon differs from base "theBoundGndPolygon" in that if the
// scene crosses the dateline the longitude values are stored between
// 0 and 360 degress as opposed to -180 to 180.
//---
ossimPolygon m_boundGndPolygon;

ossimRefPtr<ossimHdf5> m_hdf5;
ossimRefPtr<ossimHdf5ImageHandler> m_handler;

TYPE_DATA
};
Expand Down
57 changes: 5 additions & 52 deletions include/ossim/hdf5/ossimHdf5ImageHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class OSSIM_PLUGINS_DLL ossimHdf5ImageHandler : public ossimImageHandler
*/
virtual ossim_uint32 getCurrentEntry() const;

ossimRefPtr<ossimHdf5ImageDataset> getCurrentDataset();

/** @return Null pixel value. */
virtual double getNullPixelValue(ossim_uint32 band=0)const;

Expand All @@ -196,70 +198,21 @@ class OSSIM_PLUGINS_DLL ossimHdf5ImageHandler : public ossimImageHandler
*/
virtual void getPropertyNames(std::vector<ossimString>& propertyNames) const;

/** For this class only, add the specified name (can be full HDF path or pathless name only)
* for all renderable datasets to consider. If none are specified, then all multi-dimensional
* datasets (excluding geo sets) are considered renderable.
*/
void addRenderableSetName(const ossimString& name);

/** For use by factory to get listy of registered dataset names for raster data. */
const vector<ossimString>& getRenderableSetNames() const { return m_renderableNames; }

/** The derived class needs to initialize the raster dataset names m_renderableNames in their
* constructor, for this method to work. This should be implemented by the derived HDF5-format
* readers defined in plugins.
* @return true on success, false on error. */
virtual bool open();

protected:

/** @brief Method to get geometry from hdf file. This base class handles the coarse grid
* geometry found in VIIRS as the default scheme. Derived classes need to implement their
* own. */
virtual ossimRefPtr<ossimImageGeometry> getInternalImageGeometry();

/**
* @brief Gets projection from Latitude, Longitude, Height datasets if
* present.
*
* @param latDataSet H5::DataSet& to layer,
* e.g. /All_Data/VIIRS-DNB-GEO_All/Latitude
* @param lonDataSet H5::DataSet& to layer,
* e.g. /All_Data/VIIRS-DNB-GEO_All/Longitude
*/
ossimRefPtr<ossimProjection> processCoarseGridProjection(
H5::DataSet& latDataSet,
H5::DataSet& lonDataSet,
const ossimIrect& validRect ) const;

/**
* @brief Get dataset names for Latiitude and Longitude datasets.
* @param h5File Pointer to file.
* @param latName Initializes by this.
* @param lonName Initializes by this.
* @return true on sucess, false on error.
*/
bool getLatLonDatasetNames( H5::H5File* h5File,
std::string& latName,
std::string& lonName ) const;
/**
* @param Initializes lat and lon data sets.
* @param h5File Pointer to file.
* @param latDataSet Initialized by this.
* @param lonDataSet Initialized by this.
*/
bool getLatLonDatasets( H5::H5File* h5File,
H5::DataSet& latDataSet,
H5::DataSet& lonDataSet ) const;

bool getDataSetRect( std::string& name, std::string& lonName ) const;
const std::vector<ossimString>& getRenderableSetNames() { return m_renderableNames; }

protected:
/** @brief Allocates the tile. */
void allocate();

std::vector<ossimString> m_renderableNames;
ossimRefPtr<ossimHdf5> m_hdf5;
std::vector<ossimHdf5ImageDataset> m_entries;
std::vector<ossimRefPtr<ossimHdf5ImageDataset>> m_entries;
ossim_uint32 m_currentEntry;
ossimRefPtr<ossimImageData> m_tile;
OpenThreads::Mutex m_mutex;
Expand Down
41 changes: 37 additions & 4 deletions src/hdf5/ossimHdf5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// $Id

#include <ossim/hdf5/ossimHdf5.h>
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimNotify.h>
#include <string>

Expand Down Expand Up @@ -110,8 +112,6 @@ bool ossimHdf5::getRoot(Group& root) const
bool ossimHdf5::getChildGroups(H5::Group group, vector<Group>& groupList,
bool recursive) const
{
// TODO *** NOTE: This is failing when recursive = true ***

if (!m_h5File)
return false;

Expand All @@ -125,9 +125,7 @@ bool ossimHdf5::getChildGroups(H5::Group group, vector<Group>& groupList,
if (h5type == H5G_GROUP)
{
string name = group.getObjnameByIdx(i);
cout<<"name = <"<<name<<">"<<endl; //TODO: REMOVE
groupList.push_back(group.openGroup(name));

if (recursive)
success = getChildGroups(groupList.back(), groupList, true);
}
Expand Down Expand Up @@ -284,3 +282,38 @@ H5::DataSet* ossimHdf5::findDatasetByName(const char* name, const H5::Group* gro
return named_dataset;
}

ossimByteOrder ossimHdf5::getByteOrder( const H5::AbstractDs* obj )
{
ossimByteOrder byteOrder = ossim::byteOrder();
if ( obj )
{
// Get the class of the datatype that is used by the dataset.
H5T_class_t typeClass = obj->getTypeClass();

H5T_order_t order = H5T_ORDER_NONE;

if ( typeClass == H5T_INTEGER )
{
H5::IntType intype = obj->getIntType();
order = intype.getOrder();
}
else if ( typeClass == H5T_FLOAT )
{
H5::FloatType floatType = obj->getFloatType();
order = floatType.getOrder();
}

if ( order == H5T_ORDER_LE )
{
byteOrder = OSSIM_LITTLE_ENDIAN;
}
else if ( order == H5T_ORDER_BE )
{
byteOrder = OSSIM_BIG_ENDIAN;
}
}
return byteOrder;
}



Loading

0 comments on commit 10335f0

Please sign in to comment.