Skip to content

Commit

Permalink
Add icebridge reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
connormanning committed May 4, 2014
1 parent e50aba3 commit 535fbfa
Show file tree
Hide file tree
Showing 18 changed files with 1,237 additions and 18 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Expand Up @@ -538,7 +538,6 @@ if(WITH_CARIS)
endif()


# Points2Grid
# Points2Grid support - optional, default=OFF
option(WITH_P2G "Choose if Points2Grid support should be built" FALSE)
if(WITH_P2G)
Expand All @@ -551,6 +550,23 @@ if(WITH_P2G)
endif()
endif()

# HDF5 support - optional, default=OFF
option(WITH_HDF5 "Choose if HDF5 support should be built" FALSE)
if(WITH_HDF5)
set (HDF5_FIND_COMPONENTS "CXX")
find_package(HDF5 COMPONENTS CXX)
if(HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIR})
add_definitions(-DHAVE_HDF5=1)
set(PDAL_HAVE_HDF5 1)
message(STATUS "Found HDF5")
else()
set(WITH_HDF5 FALSE)
set(PDAL_HAVE_HDF5 0)
message(STATUS "HDF5 not found")
endif()
endif()


if(WITH_FREEGLUT)
find_package(FreeGLUT)
Expand Down
6 changes: 6 additions & 0 deletions include/pdal/Drivers.hpp
Expand Up @@ -47,6 +47,8 @@

#include <pdal/drivers/sbet/Reader.hpp>

#include <pdal/drivers/icebridge/Reader.hpp>

#include <pdal/drivers/pipeline/Reader.hpp>

#ifdef PDAL_HAVE_ORACLE
Expand Down Expand Up @@ -97,6 +99,10 @@
#include <pdal/drivers/p2g/Writer.hpp>
#endif

#ifdef PDAL_HAVE_HDF5
#include <pdal/drivers/icebridge/Reader.hpp>
#endif

#ifdef PDAL_HAVE_SQLITE
#ifndef USE_PDAL_PLUGIN_SQLITE
#include <pdal/drivers/sqlite/Reader.hpp>
Expand Down
128 changes: 128 additions & 0 deletions include/pdal/Hdf5Handler.hpp
@@ -0,0 +1,128 @@
/******************************************************************************
* Copyright (c) 2014, Connor Manning, connor@hobu.co
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
****************************************************************************/

#ifndef INCLUDED_PDAL_HDF5_HANDLER_HPP
#define INCLUDED_PDAL_HDF5_HANDLER_HPP

#include "H5cpp.h"

#include <boost/scoped_ptr.hpp>
#include <boost/cstdint.hpp>

#include <pdal/pdal_error.hpp>

#include <vector> // TODO Forward declare?
#include <string>
#include <map>

namespace pdal
{

namespace hdf5
{
struct Hdf5ColumnData
{
Hdf5ColumnData(const std::string& name, const H5::PredType predType)
: name(name)
, predType(predType)
{ }

const std::string name;
const H5::PredType predType;
};
}

class hdf5_error : public pdal_error
{
public:
hdf5_error(std::string const& msg)
: pdal_error(msg)
{ }
};

class Hdf5Handler
{
public:
Hdf5Handler();
~Hdf5Handler() { }

void initialize(
const std::string& filename,
const std::vector<hdf5::Hdf5ColumnData>& columns);
void close();

boost::uint64_t getNumPoints() const;

void getColumnEntries(
void* data,
const std::string& dataSetName,
boost::uint64_t numEntries,
boost::uint64_t offset) const;

private:
struct ColumnData
{
ColumnData(
H5::PredType predType,
H5::DataSet dataSet,
H5::DataSpace dataSpace)
: predType(predType)
, dataSet(dataSet)
, dataSpace(dataSpace)
{ }

ColumnData(H5::PredType predType)
: predType(predType)
, dataSet()
, dataSpace()
{ }

H5::PredType predType;
H5::DataSet dataSet;
H5::DataSpace dataSpace;
};

unsigned long long getColumnNumEntries(const std::string& dataSetName) const;
const ColumnData& getColumnData(const std::string& dataSetName) const;

boost::scoped_ptr<H5::H5File> m_h5File;
boost::uint64_t m_numPoints;

std::map<std::string, ColumnData> m_columnDataMap;
};

} // namespace pdal

#endif // INCLUDED_PDAL_HDF5_HANDLER_HPP

27 changes: 24 additions & 3 deletions include/pdal/PointBuffer.hpp
Expand Up @@ -218,6 +218,28 @@ class PDAL_DLL PointBuffer
template<class T>
void setField(Dimension const& dim, boost::uint32_t pointIndex, T value);

/*! set the value for a given :cpp:class:`pdal::Dimension` dim
at the given point index, inferring the size of the value from
the byteSize of the dimension.
\param dim The dimension to select.
\param pointIndex The point index of the PointBuffer to select.
\param value The value to set, which must have a width of at least
dim.byteSize().
\verbatim embed:rst
.. warning::
This operation performs a memcpy from input parameter 'value'
of length dim.getByteSize(), so 'value' must be guaranteed by
the caller to be at least as long as the dimension's byte size.
This operation will hammer the contents of the pdal::Dimension
with the contents of parameter 'value', so their underlying
types should be ensured to match via an accurate schema.
\endverbatim
*/
void setRawField(Dimension const& dim,
boost::uint32_t pointIndex,
const void* value);

/*! bulk copy all the fields from the given point into this object
\param destPointIndex the destination point index to copy the data from
srcPointBuffer at srcPointIndex.
Expand Down Expand Up @@ -471,9 +493,8 @@ inline void PointBuffer::setField(pdal::Dimension const& dim,

if (dim.getPosition() == -1)
{
throw buffer_error("This dimension has no identified position "
"in a schema. Use the setRawField method to access an "
"arbitrary byte position.");
throw buffer_error(
"This dimension has no identified position in a schema.");
}

pointbuffer::PointBufferByteSize point_start_byte_position(0);
Expand Down
32 changes: 20 additions & 12 deletions include/pdal/Schema.hpp
Expand Up @@ -78,18 +78,26 @@ struct position {};
struct index {};
struct uid {};

typedef boost::multi_index::multi_index_container<
Dimension,
boost::multi_index::indexed_by<
// sort by Dimension::operator<
boost::multi_index::ordered_non_unique<boost::multi_index::tag<position>, boost::multi_index::identity<Dimension> >,

// Random access
boost::multi_index::random_access<boost::multi_index::tag<index> >,
// sort by less<string> on GetName
boost::multi_index::hashed_non_unique<boost::multi_index::tag<name>, boost::multi_index::const_mem_fun<Dimension,std::string const&,&Dimension::getName> >,
boost::multi_index::hashed_non_unique<boost::multi_index::tag<uid>, boost::multi_index::const_mem_fun<Dimension,dimension::id const&,&Dimension::getUUID> >
>
typedef boost::multi_index::multi_index_container
<
Dimension,
boost::multi_index::indexed_by
<
// sort by Dimension::operator<
boost::multi_index::ordered_non_unique<boost::multi_index::tag<position>,
boost::multi_index::identity<Dimension> >,

// Random access
boost::multi_index::random_access<boost::multi_index::tag<index> >,

// sort by less<string> on GetName
boost::multi_index::hashed_non_unique<boost::multi_index::tag<name>,
boost::multi_index::const_mem_fun<Dimension,std::string const&,&Dimension::getName> >,

// sort by less on UUID
boost::multi_index::hashed_non_unique<boost::multi_index::tag<uid>,
boost::multi_index::const_mem_fun<Dimension,dimension::id const&,&Dimension::getUUID> >
>
> Map;

typedef Map::index<name>::type index_by_name;
Expand Down

0 comments on commit 535fbfa

Please sign in to comment.