39 static const int GRID_SAMPLING_INTERVAL = 32;
86 imageRect.lr(), imageRect.ll(),
107 xmsg <<
"ossimHdf5GridModel:"<<__LINE__
108 <<
" ERROR: Could not find dataset \""<<datasetName<<
"\" in file.";
113 DataSpace dataSpace = dataset->getSpace();
114 const ossim_int32 DIM_COUNT = dataSpace.getSimpleExtentNdims();
115 if ( DIM_COUNT != 2 )
119 std::vector<hsize_t> dimsOut(DIM_COUNT);
120 dataSpace.getSimpleExtentDims( &dimsOut.front(), 0 );
125 ossimDpt dspacing (GRID_SAMPLING_INTERVAL, GRID_SAMPLING_INTERVAL);
132 ossimIpt gridSize (gridCols, gridRows);
137 coarseGrid.
initialize(gridSize, gridOrigin, dspacing);
139 std::vector<hsize_t> inputCount(DIM_COUNT);
140 std::vector<hsize_t> inputOffset(DIM_COUNT);
149 std::vector<hsize_t> outputCount(OUT_DIM_COUNT);
155 std::vector<hsize_t> outputOffset(OUT_DIM_COUNT);
166 bool needSwap =
false;
169 DataType dataType = dataset->getDataType();
172 DataSpace bufferDataSpace( OUT_DIM_COUNT, &outputCount.front());
173 bufferDataSpace.selectHyperslab( H5S_SELECT_SET,
174 &outputCount.front(),
175 &outputOffset.front() );
186 y_img =
y*GRID_SAMPLING_INTERVAL;
189 inputOffset[0] = y_img;
190 dataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() );
193 dataset->read( &(values.front()), dataType, bufferDataSpace, dataSpace );
202 x_img =
x*GRID_SAMPLING_INTERVAL;
208 xmsg <<
"ossimHdf5GridModel:"<<__LINE__<<
" encountered nans!";
218 val = val2 + spacing;
221 cout <<
"val1: " << val1 <<
" val2 " << val2<<endl;;
228 cout <<
"x,y,x_img,y_img,val:" <<
x <<
"," <<
y <<
","<< x_img <<
"," << y_img <<
"," 242 val = val2 + spacing;
246 hsize_t x_img =
x*GRID_SPACING;
247 cout <<
"val1: " << val1 <<
" val2 " << val2
248 <<
"\nx,y,x_img,y_img,val:" <<
x <<
"," <<
y <<
"," 249 << x_img <<
"," << y_img <<
"," << val << endl;
263 DataSpace dataSpace = dataset->getSpace();
264 if (dataSpace.getSimpleExtentNdims() != 2)
266 xmsg <<
"ossimHdf5GridModel:"<<__LINE__<<
" ERROR: lat/lon grid dataspace rank != 2.";
271 hsize_t datExtents[2];
272 dataSpace.getSimpleExtentDims(datExtents);
273 if ((datExtents[0] < 2) || (datExtents[1] < 2))
275 xmsg <<
"ossimHdf5GridModel:"<<__LINE__<<
" ERROR: lat/lon grid size is < 2.";
282 ossimDpt cgSpacing(GRID_SAMPLING_INTERVAL, GRID_SAMPLING_INTERVAL);
286 hsize_t offset[2] = { 0, 0 };
287 dataSpace.selectHyperslab( H5S_SELECT_SET, datExtents, offset );
291 DataSpace bufSpace(2, bufExtents);
292 DataType dataType = dataset->getDataType();
293 string cname = dataType.fromClass();
295 if (dataType.getClass() != H5T_FLOAT)
297 xmsg <<
"ossimHdf5GridModel:"<<__LINE__<<
" ERROR: lat/lon grid datatype must be float.";
304 AtomType* atomType =
dynamic_cast<AtomType*
>(&dataType);
308 H5T_order_t h5order = atomType->getOrder();
318 for ( ; (
y<cgGridSize.y) && (v<
theImageSize.
v); ++
y, v+=GRID_SAMPLING_INTERVAL )
321 dataSpace.selectHyperslab( H5S_SELECT_SET, bufExtents, offset);
322 dataset->read( buffer, dataType, bufSpace, dataSpace );
324 endian->
swap( buffer, bufExtents[0] );
327 for (
x=0, u=0; (
x<cgGridSize.x)&&(u<
theImageSize.
u); ++
x, u+=GRID_SAMPLING_INTERVAL)
330 cout<<datasetName<<
" ("<<
x<<
", "<<
y<<
"): "<<buffer[u]<<endl;
335 xmsg <<
"ossimHdf5GridModel:"<<__LINE__<<
" ERROR: encountered nans in lat/lon grid.";
342 if (
x < cgGridSize.x)
347 if (
y < cgGridSize.y)
349 for (
x=0;
x<cgGridSize.x; ++
x)
367 bool found179 =
false;
368 bool found181 =
false;
390 if ( longitude == 179 )
398 if ( longitude == 178 )
402 else if ( longitude == -179 )
412 if ( longitude == -179 )
420 if ( longitude == -178 )
424 else if ( longitude == 179 )
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
RTTI_DEF1(ossimHdf5GridModel, "ossimHdf5GridModel", ossimCoarseGridModel)
Represents serializable keyword/value map.
ossimDblGrid theDlatDhGrid
double nan()
Method to return ieee floating point double precision NAN.
const ossimIpt & size() const
void setDomainType(DomainType dt)
void setNullValue(double value)
void initialize(const ossimIpt &size, const ossimDpt &origin, const ossimDpt &spacing, double null_value=OSSIM_DEFAULT_NULL_PIX_DOUBLE)
OSSIM_DLL ossimByteOrder byteOrder()
ossimString m_projDataPath
static const char * TYPE_KW
bool initialize(ossimHdf5 *hdf5, const ossimString &projDataPath="")
Initializes from an open HDF5 file.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static ossimByteOrder getByteOrder(const H5::AbstractDs *obj)
static ossimScalarType getScalarType(const H5::DataSet &dataset)
H5::Group * findGroupByName(const std::string &group_name, const H5::Group *parent_group=0, bool recursive=false) const
Finds a group by name.
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
double getNode(const ossimIpt &p) const
bool theHeightEnabledFlag
ossimRefPtr< ossimProjection > theSeedFunction
Used as an initial guess for iterative solutions and a guess for points outside the support bounds...
Low-level OSSIM interface to HDF5 libraries.
bool initCoarseGrid(const char *datasetName, ossimDblGrid &coarseGrid)
H5::DataSet * findDatasetByName(const std::string &dataset_name, const H5::Group *group=0, bool recursive=false) const
Finds a dataset by name.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Fulfills ossimObject base-class pure virtuals.
const ossimDpt & origin() const
virtual ~ossimHdf5GridModel()
virtual destructor
ossimDblGrid theDlonDhGrid
void initializeModelParams(ossimIrect irect)
Initializes base class data members after grids have been assigned.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix) const
Makes sure that the "type" keyword entry reflects the base class, not this one.
ossimRefPtr< ossimHdf5 > m_hdf5
ossimHdf5GridModel()
default constructor.
void setNode(const ossimIpt &p, const double &value)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const ossimDpt & spacing() const
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.