Skip to content

Commit

Permalink
Read dataset and dims from JSON map
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Pals committed Feb 7, 2020
1 parent 63ace00 commit 6f12021
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
17 changes: 6 additions & 11 deletions plugins/hdf/io/Hdf5Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ DimInfo::DimInfo(

void Hdf5Handler::initialize(
const std::string& filename,
const std::string& dimName,
const std::string& datasetName)
const NL::json& map)
{
try
{
Expand All @@ -115,7 +114,9 @@ void Hdf5Handler::initialize(
{
throw error("Could not open HDF5 file '" + filename + "'.");
}

auto pathDimPair = map.begin();
auto datasetName = pathDimPair.key();
auto dimName = pathDimPair.value();
m_dset = m_h5File.get()->openDataSet(datasetName);
m_dspace = m_dset.getSpace();
m_numPoints = m_dspace.getSelectNpoints();
Expand All @@ -139,18 +140,12 @@ void Hdf5Handler::initialize(
}
else if(vauge_type == H5T_INTEGER) {
m_dimInfos.push_back(
DimInfo(
dimName.empty() ? datasetName : dimName,
m_dset.getIntType()
)
DimInfo(dimName, m_dset.getIntType())
);
}
else if(vauge_type == H5T_FLOAT) {
m_dimInfos.push_back(
DimInfo(
dimName.empty() ? datasetName : dimName,
m_dset.getFloatType()
)
DimInfo(dimName, m_dset.getFloatType())
);
} else {
throw error("Unkown type: " + vauge_type);
Expand Down
4 changes: 2 additions & 2 deletions plugins/hdf/io/Hdf5Handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <pdal/Dimension.hpp>
#include <pdal/Log.hpp>
#include "H5Cpp.h"
#include <nlohmann/json.hpp>

#include <memory>
#include <vector>
Expand Down Expand Up @@ -109,8 +110,7 @@ class Hdf5Handler

void initialize(
const std::string& filename,
const std::string& dimName,
const std::string& datasetName);
const NL::json& map);
// const std::vector<hdf5::Hdf5ColumnData>& columns);
void close();

Expand Down
2 changes: 1 addition & 1 deletion plugins/hdf/io/HdfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void addField(PointViewPtr view, hdf5::DimInfo& info, PointId id, void *p) {
void HdfReader::addDimensions(PointLayoutPtr layout)
{
m_hdf5Handler.setLog(log());
m_hdf5Handler.initialize(m_filename, m_dimName, m_datasetName);
m_hdf5Handler.initialize(m_filename, m_pathDimMap);

// layout->registerDims(dimensions());
std::cout << "HdfReader::addDimensions begin" << std::endl;
Expand Down

0 comments on commit 6f12021

Please sign in to comment.