Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CSAR reader contributed by CARIS (not yet working)

  • Loading branch information...
commit 731f687c37623986327f4a8b55416cfa93951a6b 1 parent e72b1bf
@mpgerlek mpgerlek authored
View
16 CMakeLists.txt
@@ -413,6 +413,22 @@ if(WITH_MRSID)
endif()
endif()
+
+# CARIS/BDB support - optional, default=OFF
+set(WITH_CARIS FALSE CACHE BOOL "Choose if CARIS/BDB support should be built")
+if(WITH_CARIS)
+ set(CARIS_FOUND 1)
+# set(MRSID_ROOT "/Users/hobu/installs/mrsid/Lidar_DSDK" CACHE STRING "Root directory of MrSID install")
+# find_package(MrSID)
+# if(MRSID_FOUND)
+# set(CMAKE_REQUIRED_LIBRARIES ${MRSID_LIBRARY})
+# include_directories(${MRSID_INCLUDE_DIR})
+# add_definitions(-DHAVE_MRSID=1)
+ set(PDAL_HAVE_CARIS 1)
+# endif()
+endif()
+
+
# Points2Grid
# Points2Grid support - optional, default=OFF
set(WITH_P2G FALSE CACHE BOOL "Choose if Points2Grid support should be built")
View
6 config.bat
@@ -25,6 +25,11 @@ rem set PDAL_EMBED_BOOST=OFF
rem set BOOST_DIR=c:\utils\boost_1_49_0
set BOOST_DIR=%PDAL_DIR%\boost
+:: CARIS
+set CARIS_ENABLED=ON
+set CARIS_INCLUDE_DIR=%CARIS_DIR%\include
+set CARIS_LIBRARY=%CARIS_DIR%\caris.lib
+
:: GDAL
set GDAL_ENABLED=ON
set GDAL_INCLUDE_DIR=%OSGEO4W_DIR%\apps\gdal-dev\include
@@ -83,6 +88,7 @@ if %USERDOMAIN% == PDC set FREEGLUT_ENABLED=ON
rem if EXIST CMakeCache.txt del CMakeCache.txt
cmake -G %GENERATOR% ^
+ -DWITH_CARIS=%CARIS_ENABLED% ^
-DWITH_GDAL=%GDAL_ENABLED% ^
-DWITH_GEOTIFF=%GEOTIFF_ENABLED% ^
-DWITH_ORACLE=%ORACLE_ENABLED% ^
View
73 include/pdal/drivers/caris/CloudIterator.hpp
@@ -0,0 +1,73 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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_DRIVERS_CSAR_CLOUDITERATOR_HPP
+#define INCLUDED_DRIVERS_CSAR_CLOUDITERATOR_HPP
+
+#include "config.h"
+#include "caris/caris_pc_wrapper.h"
+#include "CloudReader.hpp"
+
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# pragma warning(disable : DISABLED_3RDPARTY_WARNINGS)
+#endif
+
+#include <pdal/ReaderIterator.hpp>
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+namespace csar {
+
+//! Sequential iterator for CloudReader
+class CloudIterator : public pdal::ReaderSequentialIterator
+{
+public:
+ CloudIterator(
+ CloudReader const& in_reader,
+ pdal::PointBuffer & in_buffer);
+ virtual ~CloudIterator();
+
+protected:
+ virtual boost::uint32_t readBufferImpl(pdal::PointBuffer& io_buffer);
+ virtual boost::uint64_t skipImpl(boost::uint64_t in_pointNum);
+ virtual bool atEndImpl() const;
+
+private:
+ void throwIfItrError() const;
+
+private:
+ caris_itr * m_itr;
+ std::map<pdal::dimension::id, CloudReader::DimInfo> m_dimInfo;
+ int32_t m_currentOffset;
+};
+
+} // namespace
+
+#endif
View
122 include/pdal/drivers/caris/CloudReader.hpp
@@ -0,0 +1,122 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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_DRIVERS_CSAR_CLOUDREADER_HPP
+#define INCLUDED_DRIVERS_CSAR_CLOUDREADER_HPP
+
+#include "config.h"
+
+#include "caris/caris_pc_wrapper.h"
+
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# pragma warning(disable : DISABLED_3RDPARTY_WARNINGS)
+#endif
+
+#include <pdal/StageBase.hpp>
+#include <pdal/Stage.hpp>
+#include <pdal/Reader.hpp>
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+namespace csar {
+
+//! Base Reader implementaion of CARIS Clouds
+class CloudReader : public pdal::Reader
+{
+public:
+
+ explicit CloudReader(const pdal::Options& options);
+ virtual ~CloudReader();
+
+
+ virtual void initialize();
+
+ virtual bool supportsIterator(pdal::StageIteratorType in_type) const;
+
+ virtual pdal::StageSequentialIterator* createSequentialIterator(pdal::PointBuffer& in_buffer) const;
+
+ //! Info for mapping between pdal and caris dimensions
+ struct DimInfo
+ {
+ DimInfo()
+ : dimIndex(), tupleIndex(), dimension()
+ {}
+ DimInfo(int in_dimIndex, int in_tupleIndex, caris_dimension const* in_dimension)
+ : dimIndex(in_dimIndex), tupleIndex(in_tupleIndex), dimension(in_dimension)
+ {}
+
+ //! index of the dimension in the related caris_cloud
+ int dimIndex;
+ //! the tuple index of the caris_dimension to be mapped to pdal
+ int tupleIndex;
+ //! related dimension
+ caris_dimension const* dimension;
+ };
+
+ std::map<pdal::dimension::id, DimInfo> const& getDimInfo() const;
+ caris_cloud * getCarisCloud() const;
+
+protected:
+ virtual std::string getURI() const = 0;
+
+private:
+ caris_cloud * m_cloud;
+ std::map<pdal::dimension::id, DimInfo> m_dimInfo;
+};
+
+//************************************************************************
+//! info for mapping from pdal to caris dimensions
+/*!
+\return
+ \li info for mapping from pdal to caris dimensions
+*/
+//************************************************************************
+inline
+std::map<pdal::dimension::id, CloudReader::DimInfo> const& CloudReader::getDimInfo() const
+{
+ return m_dimInfo;
+}
+
+//************************************************************************
+//! get underlying caris_cloud
+/*!
+\return
+ \li underlying caris_cloud
+*/
+//************************************************************************
+inline
+caris_cloud * CloudReader::getCarisCloud() const
+{
+ return m_cloud;
+}
+
+} // namespace
+
+#endif
View
1  pdal_defines.h.in
@@ -24,6 +24,7 @@
/*
* availability of 3rd-party libraries
*/
+#cmakedefine PDAL_HAVE_CARIS
#cmakedefine PDAL_HAVE_GEOS
#cmakedefine PDAL_HAVE_GDAL
#cmakedefine PDAL_HAVE_FLANN
View
31 src/CMakeLists.txt
@@ -190,6 +190,35 @@ endif()
#
+# drivers/caris
+#
+set(PDAL_CARIS_PATH drivers/caris)
+set(PDAL_CARIS_HEADERS ${PDAL_HEADERS_DIR}/${PDAL_CARIS_PATH})
+set(PDAL_CARIS_SRC ${PROJECT_SOURCE_DIR}/src/${PDAL_CARIS_PATH})
+
+set(PDAL_DRIVERS_CARIS_HPP
+ ${PDAL_CARIS_HEADERS}/CloudReader.hpp
+ ${PDAL_CARIS_HEADERS}/CloudIterator.hpp
+ ${PDAL_CARIS_SRC}/Utils.hpp
+ ${PDAL_CARIS_SRC}/config.h
+ ${PDAL_CARIS_SRC}/caris/caris_pc_wrapper.h
+)
+
+set (PDAL_DRIVERS_CARIS_CPP
+ ${PDAL_CARIS_SRC}/CloudReader.cpp
+ ${PDAL_CARIS_SRC}/CloudIterator.cpp
+ ${PDAL_CARIS_SRC}/pdal_csar.cpp
+ ${PDAL_CARIS_SRC}/Utils.cpp
+ ${PDAL_CARIS_SRC}/caris/caris_pc_wrapper.c
+)
+
+if (CARIS_FOUND)
+ list (APPEND PDAL_CPP ${PDAL_DRIVERS_CARIS_CPP} )
+ list (APPEND PDAL_HPP ${PDAL_DRIVERS_CARIS_HPP} )
+endif()
+
+
+#
# drivers/oci
#
@@ -470,6 +499,7 @@ source_group("CMake Files" FILES CMakeLists.txt)
source_group("Header Files" FILES ${PDAL_BASE_HPP})
source_group("Header Files\\config" FILES ${PDAL_CONFIG_HPP})
source_group("Header Files\\drivers\\faux" FILES ${PDAL_DRIVERS_FAUX_HPP})
+source_group("Header Files\\drivers\\caris" FILES ${PDAL_DRIVERS_CARIS_HPP})
source_group("Header Files\\drivers\\las" FILES ${PDAL_DRIVERS_LAS_HPP})
source_group("Header Files\\drivers\\nitf" FILES ${PDAL_DRIVERS_NITF_HPP})
source_group("Header Files\\drivers\\oci" FILES ${PDAL_DRIVERS_OCI_HPP})
@@ -483,6 +513,7 @@ source_group("Header Files\\plang" FILES ${PDAL_PLANG_HPP})
source_group("Source Files" FILES ${PDAL_BASE_CPP})
source_group("Source Files\\config" FILES ${PDAL_CONFIG_CPP})
source_group("Source Files\\drivers\\faux" FILES ${PDAL_DRIVERS_FAUX_CPP})
+source_group("Source Files\\drivers\\caris" FILES ${PDAL_DRIVERS_CARIS_CPP})
source_group("Source Files\\drivers\\las" FILES ${PDAL_DRIVERS_LAS_CPP})
source_group("Source Files\\drivers\\nitf" FILES ${PDAL_DRIVERS_NITF_CPP})
source_group("Source Files\\drivers\\oci" FILES ${PDAL_DRIVERS_OCI_CPP})
View
4 src/drivers/CMakeLists.txt
@@ -11,6 +11,10 @@ add_subdirectory(faux)
add_subdirectory(las)
add_subdirectory(liblas)
+if(CARIS_FOUND)
+ add_subdirectory(caris)
+endif()
+
if(MRSID_FOUND)
add_subdirectory(mrsid)
endif()
View
233 src/drivers/caris/CloudIterator.cpp
@@ -0,0 +1,233 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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.
+ ************************************************************************/
+
+#include <pdal/drivers/caris/CloudIterator.hpp>
+
+#include "Utils.hpp"
+
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# pragma warning(disable : DISABLED_3RDPARTY_WARNINGS)
+#endif
+
+#include <pdal/PointBuffer.hpp>
+#include <pdal/Dimension.hpp>
+#include <pdal/Schema.hpp>
+#include <pdal/Reader.hpp>
+
+#include <boost/foreach.hpp>
+#include <boost/uuid/uuid_io.hpp>
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+# pragma warning(disable : 4503)
+#endif
+
+namespace csar {
+
+using namespace csar::utils;
+
+namespace
+{
+ //************************************************************************
+ //! copy banded data to a pdal::PointBuffer
+ /*!
+ \param in_srcBuffer
+ \li source buffer
+ \param in_srcOffset
+ \li index of the first element to copy in \e in_srcBuffer
+ \param in_elementCount
+ \li number of elements to copy
+ \param in_dimInfo
+ \li description of source dimension
+ \param io_buffer
+ \li buffer to copy to
+ \param in_pdalDim
+ \li dimension to copy to
+ \return
+ \li size (bytes) of an element of type \e in_type
+ */
+ //************************************************************************
+ void copyToPointBuffer(
+ void const* in_srcBuffer, size_t in_srcOffset, size_t in_elementCount,
+ CloudReader::DimInfo in_dimInfo,
+ pdal::PointBuffer& io_buffer, pdal::Dimension const& in_pdalDim)
+ {
+ assert( carisTypeToInterpretation(caris_type(in_dimInfo.dimension->type))
+ == in_pdalDim.getInterpretation() );
+ assert( carisTypeToSize(caris_type(in_dimInfo.dimension->type))
+ == in_pdalDim.getByteSize() );
+
+ const size_t elementSize = in_pdalDim.getByteSize();
+ const size_t srcStride = in_dimInfo.dimension->tuple_length * elementSize;
+ uint8_t const* src = static_cast<uint8_t const*>(in_srcBuffer)
+ + in_srcOffset * srcStride
+ + elementSize * in_dimInfo.tupleIndex;
+
+ const size_t dstStride = io_buffer.getSchema().getByteSize();
+ uint8_t * dst = io_buffer.getData(0) + in_pdalDim.getByteOffset();
+
+ for(size_t i = 0;
+ i < in_elementCount;
+ ++i, src += srcStride, dst += dstStride)
+ {
+ ::memcpy(dst, src, elementSize);
+ }
+ }
+}
+
+//************************************************************************
+//! constructor
+/*!
+\param in_reader
+ \li CloudReader to iterate
+\param in_buffer
+ \li ?
+*/
+//************************************************************************
+CloudIterator::CloudIterator(
+ CloudReader const& in_reader,
+ pdal::PointBuffer & in_buffer)
+ : ReaderSequentialIterator(in_reader, in_buffer)
+ , m_itr(NULL)
+ , m_dimInfo(in_reader.getDimInfo())
+ , m_currentOffset(0)
+{
+ m_itr = caris_cloud_create_itr(in_reader.getCarisCloud());
+
+ throwIfItrError();
+}
+
+//************************************************************************
+//! destructor
+//************************************************************************
+CloudIterator::~CloudIterator()
+{
+ if(m_itr)
+ caris_itr_release(m_itr);
+}
+
+//! \copydoc pdal::ReaderSequentialIterator::readBufferImpl
+boost::uint32_t CloudIterator::readBufferImpl(
+ pdal::PointBuffer& io_buffer
+ )
+{
+ assert(m_itr);
+
+ if(atEndImpl())
+ {
+ io_buffer.setNumPoints(0);
+ return 0;
+ }
+
+ const int32_t numPoints = caris_itr_num_points(m_itr);
+ assert(numPoints > m_currentOffset);
+ const uint32_t remaining = numPoints - m_currentOffset;
+ const uint32_t toProcess = std::min(remaining, io_buffer.getCapacity());
+
+ io_buffer.setNumPoints(toProcess);
+
+ pdal::Schema const& schema = io_buffer.getSchema();
+
+ BOOST_FOREACH(pdal::Dimension const& pdalDim, schema.getDimensions().get<pdal::schema::index>())
+ {
+ boost::optional<CloudReader::DimInfo const&> dimInfo
+ = getOptionalCRef(m_dimInfo, pdalDim.getUUID());
+
+ if(!dimInfo)
+ {
+ // unknown dimension, possibly from a filter
+ continue;
+ }
+
+ int32_t numDimElements = 0;
+ void const* dimElements = caris_itr_read(m_itr, dimInfo->dimIndex, &numDimElements);
+
+ throwIfItrError();
+
+ assert(numDimElements == numPoints);
+ copyToPointBuffer(
+ dimElements, m_currentOffset, toProcess, *dimInfo,
+ io_buffer, pdalDim);
+ }
+
+ m_currentOffset += toProcess;
+ if(m_currentOffset == numPoints)
+ {
+ m_currentOffset = 0;
+ caris_itr_next(m_itr);
+ }
+
+ throwIfItrError();
+
+ return toProcess;
+}
+
+//! \copydoc pdal::ReaderSequentialIterator::skipImpl
+boost::uint64_t CloudIterator::skipImpl(boost::uint64_t in_pointNum)
+{
+ uint64_t nextOffset = m_currentOffset + in_pointNum;
+
+ while(!caris_itr_done(m_itr))
+ {
+ const int32_t numPoints = caris_itr_num_points(m_itr);
+
+ if(nextOffset < numPoints)
+ {
+ m_currentOffset = static_cast<int32_t>(nextOffset);
+ break;
+ }
+
+ nextOffset -= numPoints;
+ caris_itr_next(m_itr);
+ }
+
+ throwIfItrError();
+
+ return in_pointNum - (nextOffset - m_currentOffset);
+}
+
+//! \copydoc pdal::ReaderSequentialIterator::atEndImpl
+bool CloudIterator::atEndImpl() const
+{
+ return caris_itr_done(m_itr) != 0;
+}
+
+//************************************************************************
+//! throw a pdal::pdal_error if an error has occured in the wrapped caris_itr
+//************************************************************************
+void CloudIterator::throwIfItrError() const
+{
+ if(int status = caris_itr_status(m_itr))
+ {
+ std::string msg = caris_status_message(status, getStage().isDebug());
+ throw pdal::pdal_error(msg);
+ }
+}
+
+} // namespace
View
215 src/drivers/caris/CloudReader.cpp
@@ -0,0 +1,215 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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.
+ ************************************************************************/
+#include <pdal/drivers/caris/CloudReader.hpp>
+#include <pdal/drivers/caris/CloudIterator.hpp>
+
+#include "Utils.hpp"
+
+
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# pragma warning(disable : DISABLED_3RDPARTY_WARNINGS)
+#endif
+
+#include <pdal/Dimension.hpp>
+#include <pdal/Schema.hpp>
+#include <ogr_spatialref.h>
+#include <boost/foreach.hpp>
+#include <boost/uuid/uuid_io.hpp>
+#include <boost/uuid/string_generator.hpp>
+#include <boost/uuid/name_generator.hpp>
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+
+// decorated name length exceeded, name was truncated
+# pragma warning(disable : 4503)
+#endif
+
+namespace csar {
+
+using namespace csar::utils;
+
+namespace {
+
+
+ //************************************************************************
+ //! callback for logging messages
+ /*!
+ \param in_reader
+ \li CloudReader* to log to
+ \param in_message
+ \li message to log
+ */
+ //************************************************************************
+ void logCallback(void* in_reader, const char* in_message)
+ {
+ CloudReader * reader = (CloudReader *)in_reader;
+ if(reader)
+ {
+ reader->log()->get(pdal::logINFO) << in_message << std::flush;
+ }
+ }
+
+}
+
+//************************************************************************
+//! constructor
+/*!
+\param options
+ \li Reader options
+*/
+//************************************************************************
+CloudReader::CloudReader(
+ const pdal::Options& options)
+ : pdal::Reader(options)
+{
+}
+
+//************************************************************************
+//! destructor
+//************************************************************************
+CloudReader::~CloudReader()
+{
+ if(m_cloud)
+ caris_cloud_release(m_cloud);
+}
+
+//! \copydoc pdal::Reader::initialize
+void CloudReader::initialize()
+{
+ pdal::Reader::initialize();
+
+ int status = caris_cloud_open(getURI().c_str(), &m_cloud, &logCallback, this);
+ if(status)
+ {
+ std::string msg = caris_status_message(status, isDebug());
+ throw pdal::pdal_error(msg);
+ }
+
+ assert(m_cloud);
+
+ // bounds
+ {
+ double minMaxXYZ[2][3];
+ caris_cloud_extents(m_cloud,
+ &minMaxXYZ[0][0], &minMaxXYZ[0][1], &minMaxXYZ[0][2],
+ &minMaxXYZ[1][0], &minMaxXYZ[1][1], &minMaxXYZ[1][2]);
+
+ setBounds( pdal::Bounds<double>(
+ minMaxXYZ[0][0], minMaxXYZ[0][1], minMaxXYZ[0][2],
+ minMaxXYZ[1][0], minMaxXYZ[1][1], minMaxXYZ[1][2]
+ ) );
+ }
+
+ setNumPoints(caris_cloud_num_points(m_cloud));
+
+ if(const char* wktSR = caris_cloud_spatial_reference(m_cloud))
+ {
+ setSpatialReference(pdal::SpatialReference(wktSR));
+ }
+
+ // Dimensions
+ pdal::Schema & schema = getSchemaRef();
+
+ // generate dimension UUIDs such that they are unique to the driver, but
+ // consistent accoss loads
+ boost::uuids::name_generator uuidGen(
+ boost::uuids::string_generator()(
+ "{5C668903-34CF-40d3-92C3-B8D9AB070902}") );
+
+ int numDims = 0;
+ caris_dimension const* dimArray = NULL;
+ caris_cloud_dimensions(m_cloud, &dimArray, &numDims);
+
+ // caris_dimesions may contain a tuple of numeric elements which need
+ // to be mapped to multiple pdal dimenions
+ for(int dimIndex = 0; dimIndex < numDims; ++dimIndex)
+ {
+ caris_dimension const& carisDim = dimArray[dimIndex];
+
+ for(int tupleIndex = 0; tupleIndex < carisDim.tuple_length; ++tupleIndex)
+ {
+ std::string name;
+
+ if(carisDim.tuple_length == 1)
+ {
+ name = carisDim.name;
+ }
+ else
+ {
+ if( dimIndex == 0
+ && carisDim.type == CARIS_TYPE_FLOAT64
+ && carisDim.tuple_length == 3)
+ {
+ // position is always the first dim, name them X,Y,Z
+ char const* xyzStr[] = {"X", "Y", "Z"};
+ name = xyzStr[tupleIndex];
+ }
+ else
+ {
+ name = std::string(carisDim.name)
+ + "." + boost::lexical_cast<std::string>(tupleIndex);
+ }
+ }
+
+ pdal::Dimension pdalDim(
+ name,
+ carisTypeToInterpretation(caris_type(carisDim.type)),
+ carisTypeToSize(caris_type(carisDim.type)) );
+ pdalDim.setUUID( uuidGen(name) );
+ pdalDim.setNamespace( getName() );
+ m_dimInfo[pdalDim.getUUID()] = DimInfo(dimIndex, tupleIndex, &carisDim);
+ schema.appendDimension(pdalDim);
+ }
+ }
+
+ if(caris_cloud_status(m_cloud))
+ {
+ std::string msg = caris_status_message(caris_cloud_status(m_cloud), isDebug());
+ throw pdal::pdal_error(msg);
+ }
+}
+
+
+//! \copydoc pdal::Reader::supportsIterator
+bool CloudReader::supportsIterator(pdal::StageIteratorType in_type) const
+{
+ return in_type == pdal::StageIterator_Sequential;
+}
+
+//! \copydoc pdal::Reader::createSequentialIterator
+pdal::StageSequentialIterator* CloudReader::createSequentialIterator(
+ pdal::PointBuffer& in_buffer) const
+{
+ assert(m_cloud);
+
+ return new CloudIterator(*this, in_buffer);
+}
+
+} // namespace
View
173 src/drivers/caris/Utils.cpp
@@ -0,0 +1,173 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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.
+ ************************************************************************/
+
+#include "Utils.hpp"
+
+#include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
+#include "boost_range_algorithm_count.hpp"
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
+
+namespace csar {
+namespace utils {
+
+//************************************************************************
+//! convert a caris_type to a pdal::dimension::Interpretation
+/*!
+\param in_type
+ \li caris_type to convert
+\return
+ \li pdal::dimension::Interpretation of \e in_type
+*/
+//************************************************************************
+pdal::dimension::Interpretation carisTypeToInterpretation(caris_type in_type)
+{
+ using namespace pdal::dimension;
+
+ switch(in_type)
+ {
+ case CARIS_TYPE_FLOAT32:
+ case CARIS_TYPE_FLOAT64:
+ return Float;
+ case CARIS_TYPE_INT8:
+ return SignedByte; // or SignedInteger
+ case CARIS_TYPE_INT16:
+ case CARIS_TYPE_INT32:
+ case CARIS_TYPE_INT64:
+ return SignedInteger;
+ case CARIS_TYPE_UINT8:
+ return UnsignedByte; // or UnsignedInteger
+ case CARIS_TYPE_UINT16:
+ case CARIS_TYPE_UINT32:
+ case CARIS_TYPE_UINT64:
+ return UnsignedInteger;
+ default:
+ assert(false && "Invalid caris_type");
+ return Undefined;
+ }
+}
+
+//************************************************************************
+//! get the size of a caris_type
+/*!
+\param in_type
+ \li caris_type to convert
+\return
+ \li number of bytes of an element of type \e in_type
+*/
+//************************************************************************
+pdal::dimension::size_type carisTypeToSize(caris_type in_type)
+{
+ using namespace pdal::dimension;
+
+ switch(in_type)
+ {
+ case CARIS_TYPE_INT8:
+ case CARIS_TYPE_UINT8:
+ return 1;
+ case CARIS_TYPE_INT16:
+ case CARIS_TYPE_UINT16:
+ return 2;
+ case CARIS_TYPE_FLOAT32:
+ case CARIS_TYPE_INT32:
+ case CARIS_TYPE_UINT32:
+ return 4;
+ case CARIS_TYPE_FLOAT64:
+ case CARIS_TYPE_INT64:
+ case CARIS_TYPE_UINT64:
+ return 8;
+ default:
+ assert(false && "Invalid caris_type");
+ return 0;
+ }
+}
+
+//************************************************************************
+//! convert a filesystem path to a URI
+/*!
+\param in_path
+ \li filesystem path
+\return
+ \li Absolute URI to \e in_path in utf-8
+*/
+//************************************************************************
+std::string systemPathToURI(std::string const& in_path)
+{
+ boost::filesystem::path fsPath = boost::filesystem::absolute(in_path);
+ std::string path = fsPath.string(boost::filesystem::detail::utf8_codecvt_facet());
+
+#ifdef WIN32
+ // convert /'s and add inital /
+ path = "/" + path;
+ boost::replace_all(path, "\\", "/");
+#endif
+
+ const char validChars[] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "-._~"
+ "!$&'()*+,;=:@/";
+
+ std::string uri = "file://";
+
+ BOOST_FOREACH(char c, path)
+ {
+ if(boost::range::count(validChars, c))
+ {
+ uri += c;
+ }
+ else
+ {
+ // percent encode
+ struct {
+ char operator()(uint8_t in_v)
+ {
+ return (in_v < 10)
+ ? (in_v + '0')
+ : (in_v - 10 + 'A');
+ }
+ } toHexChar;
+
+ char hexStr[4] = {
+ '%',
+ toHexChar((c & 0xf0) >> 4),
+ toHexChar( c & 0x0f),
+ '\0'
+ };
+
+ uri += hexStr;
+ }
+ }
+
+ return uri;
+}
+
+}
+}
View
75 src/drivers/caris/Utils.hpp
@@ -0,0 +1,75 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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_DRIVERS_CSAR_UTILS_HPP
+#define INCLUDED_DRIVERS_CSAR_UTILS_HPP
+
+#include "config.h"
+#include "caris/caris_pc_wrapper.h"
+
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# pragma warning(disable : DISABLED_3RDPARTY_WARNINGS)
+#endif
+
+#include <map>
+#include <boost/optional.hpp>
+#include <pdal/dimension.hpp>
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+namespace csar {
+namespace utils {
+
+pdal::dimension::Interpretation carisTypeToInterpretation(caris_type in_type);
+pdal::dimension::size_type carisTypeToSize(caris_type in_type);
+std::string systemPathToURI(std::string const& in_path);
+
+/// Lookup an item in a std::map
+///
+/// @tparam T,U map template paramaters, implied
+/// @param in_map map to check
+/// @param in_key key to lookup
+/// @return An optional reference to the value of \e in_key
+/// none if \e in_key doesn't exist in \e in_map
+template<typename T, typename U>
+boost::optional<U const&> getOptionalCRef(
+ std::map<T, U> const& in_map,
+ T const& in_key)
+{
+ typename std::map<T, U>::const_iterator itr = in_map.find(in_key);
+ if(itr != in_map.end())
+ return itr->second;
+ else
+ return boost::none;
+}
+
+}} // namespace
+
+#endif
View
50 src/drivers/caris/boost_range_algorithm_count.hpp
@@ -0,0 +1,50 @@
+// Copyright Neil Groves 2009. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <algorithm>
+
+namespace pdalboost{} namespace boost = pdalboost; namespace pdalboost{
+
+ namespace range
+ {
+
+/// \brief template function count
+///
+/// range-based version of the count std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+template< class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
+count(SinglePassRange& rng, const Value& val)
+{
+ BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+ return std::count(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange const>::type
+count(const SinglePassRange& rng, const Value& val)
+{
+ BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+ return std::count(boost::begin(rng), boost::end(rng), val);
+}
+
+ } // namespace range
+ using range::count;
+} // namespace boost
+
+#endif // include guard
View
89 src/drivers/caris/caris/caris_pc_wrapper.c
@@ -0,0 +1,89 @@
+/******************************************************************************
+* Copyright (c) 2011, OneOcean (mpg@1ocean.com)
+*
+* 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.
+****************************************************************************/
+
+#include "caris_pc_wrapper.h"
+
+#pragma warning(disable: 4100) // unrefeences formal parameter
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************
+ * misc functions
+ ************************************************************************/
+
+int caris_init(size_t in_cache_bytes, char const* in_support_dir) { return 0; }
+char const* caris_status_message(int in_status, int in_verbose) { return 0; }
+
+
+/************************************************************************
+ * caris_cloud functions
+ ************************************************************************/
+
+int caris_cloud_open(
+ const char* in_uri,
+ caris_cloud** out_cloud,
+ caris_log_func in_log_callback,
+ void* in_log_callback_user_data) { return 0; }
+int caris_cloud_release(caris_cloud* in_cloud) { return 0; }
+int64_t caris_cloud_num_points(caris_cloud* in_cloud) { return 0; }
+void caris_cloud_dimensions(caris_cloud* in_cloud,
+ caris_dimension const** out_dimensions,
+ int * out_num_dimensions) { return; }
+void caris_cloud_extents(caris_cloud* in_cloud,
+ double* out_min_x, double* out_min_y, double* out_min_z,
+ double* out_max_x, double* out_max_y, double* out_max_z) { return; }
+char const* caris_cloud_spatial_reference(caris_cloud* in_cloud) { return 0; }
+int caris_cloud_status(caris_cloud* in_cloud) { return 0; }
+caris_itr* caris_cloud_create_itr(caris_cloud* in_cloud) { return 0; }
+
+
+/************************************************************************
+ * caris_itr functions
+ ************************************************************************/
+
+void caris_itr_release(caris_itr* in_itr) { return; }
+void caris_itr_next(caris_itr* in_itr) { return; }
+int caris_itr_done(caris_itr* in_itr) { return 0; }
+int32_t caris_itr_num_points(caris_itr* in_itr) { return 0; }
+void const* caris_itr_read(caris_itr* in_itr,
+ int in_dimension_index, int32_t * out_num_points) { return 0; }
+int caris_itr_status(caris_itr* in_itr) { return 0; }
+
+
+
+#ifdef __cplusplus
+}
+#endif
View
327 src/drivers/caris/caris/caris_pc_wrapper.h
@@ -0,0 +1,327 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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 CARIS_CARIS_H
+#define CARIS_CARIS_H
+
+/* stdint.h is missing from msvc < v10/2010 */
+#if defined(_MSC_VER) && _MSC_VER < 1600
+ typedef signed __int8 int8_t;
+ typedef unsigned __int8 uint8_t;
+ typedef signed __int16 int16_t;
+ typedef unsigned __int16 uint16_t;
+ typedef signed __int32 int32_t;
+ typedef unsigned __int32 uint32_t;
+ typedef signed __int64 int64_t;
+ typedef unsigned __int64 uint64_t;
+#else
+ #include <stdint.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************
+ * constants
+ ************************************************************************/
+
+#define CARIS_VERSION_MAJOR 0
+#define CARIS_VERSION_MINOR 1
+#define CARIS_VERSION_PATCH 0
+
+/*! \brief enum of numeric pod types */
+enum caris_type
+{
+ CARIS_TYPE_FLOAT32 = 0,
+ CARIS_TYPE_FLOAT64 = 1,
+ CARIS_TYPE_INT8 = 2,
+ CARIS_TYPE_UINT8 = 3,
+ CARIS_TYPE_INT16 = 4,
+ CARIS_TYPE_UINT16 = 5,
+ CARIS_TYPE_INT32 = 6,
+ CARIS_TYPE_UINT32 = 7,
+ CARIS_TYPE_INT64 = 8,
+ CARIS_TYPE_UINT64 = 9
+};
+
+
+/************************************************************************
+ * Types
+ ************************************************************************/
+
+/*! \brief Opaque type for accessing Caris cloud data
+ Similar to pdal::Reader */
+typedef struct caris_cloud caris_cloud;
+
+/*! \brief Opaque type for iterating Caris cloud data in blocks
+ Similar to pdal::SequentialIterator */
+typedef struct caris_itr caris_itr;
+
+typedef void(*caris_log_func)(void* in_user_data, char const* in_message);
+
+/*! \brief Details of dimension from a caris_cloud */
+typedef struct caris_dimension
+{
+ int type; /*!< type of stored data (caris_type) */
+ int tuple_length; /*!< number of \e type entries per field */
+ int reserved0;
+ int reserved1;
+ int reserved2;
+ int reserved3;
+ char* name; /*!< name of the dimension */
+ void* reserved4;
+ void* reserved5;
+ void* reserved6;
+ void* reserved7;
+ void* reserved8;
+} caris_dimension;
+
+/************************************************************************
+ * misc functions
+ ************************************************************************/
+
+int caris_init(size_t in_cache_bytes, char const* in_support_dir);
+char const* caris_status_message(int in_status, int in_verbose);
+
+
+/************************************************************************
+ * caris_cloud functions
+ ************************************************************************/
+
+int caris_cloud_open(
+ const char* in_uri,
+ caris_cloud** out_cloud,
+ caris_log_func in_log_callback,
+ void* in_log_callback_user_data);
+int caris_cloud_release(caris_cloud* in_cloud);
+int64_t caris_cloud_num_points(caris_cloud* in_cloud);
+void caris_cloud_dimensions(caris_cloud* in_cloud,
+ caris_dimension const** out_dimensions,
+ int * out_num_dimensions);
+void caris_cloud_extents(caris_cloud* in_cloud,
+ double* out_min_x, double* out_min_y, double* out_min_z,
+ double* out_max_x, double* out_max_y, double* out_max_z);
+char const* caris_cloud_spatial_reference(caris_cloud* in_cloud);
+int caris_cloud_status(caris_cloud* in_cloud);
+caris_itr* caris_cloud_create_itr(caris_cloud* in_cloud);
+
+
+/************************************************************************
+ * caris_itr functions
+ ************************************************************************/
+
+void caris_itr_release(caris_itr* in_itr);
+void caris_itr_next(caris_itr* in_itr);
+int caris_itr_done(caris_itr* in_itr);
+int32_t caris_itr_num_points(caris_itr* in_itr);
+void const* caris_itr_read(caris_itr* in_itr,
+ int in_dimension_index, int32_t * out_num_points);
+int caris_itr_status(caris_itr* in_itr);
+
+
+/************************************************************************
+ * doxygen
+ ************************************************************************/
+
+/*! \name General functions
+@{
+
+ \fn int caris_init(size_t, char const*);
+ \brief initialize the CARIS environment
+
+ This should be called before using any other functions
+
+ \param in_cache_bytes
+ \li cache size in bytes
+ \param in_support_dir
+ \li directory with CARIS support files
+ \return
+ \li 0 if the method succeeded, error code if it failed.
+
+ \fn char const* caris_status_message(int in_status, int in_verbose)
+ \brief initialize the CARIS environment
+
+ \param in_status
+ \li error code
+ \param in_verbose
+ \li set to true to include debug information
+ \return
+ \li a message for the given error code
+ \li valid until the next call to caris_status_message
+ \li never null
+*/
+/*! @} */
+
+
+/*! \name caris_cloud functions
+ @{
+
+ \fn int caris_cloud_open(
+ const char* in_uri,
+ caris_cloud** out_cloud,
+ caris_log_func in_log_callback,
+ void* in_log_callback_user_data);
+ \brief open a caris_cloud
+
+ \param in_uri
+ \li URI of the cloud to open
+ \param out_cloud
+ \li set to new caris_cloud pointer
+ \param in_log_callback
+ \li optional callback for traking open progress
+ \param in_log_callback_user_data
+ \li parameter to be passed to in_log_callback
+ \return
+ \li 0 if the method succeeded, error code if it failed.
+
+ \fn int caris_cloud_release(caris_cloud* in_cloud)
+ \brief release the resourses owned by a caris_cloud
+
+ \param in_cloud
+ \li cloud to close
+ \return
+ \li 0 if the method succeeded, error code if it failed.
+
+ \fn int64_t caris_cloud_num_points(caris_cloud* in_cloud);
+ \brief get the number of points
+ \param in_cloud
+ \li related caris_cloud
+ \return
+ \li the number of points in \e in_cloud
+ \li 0 on failure, error available via caris_cloud_status()
+
+
+ \fn void caris_cloud_dimensions(caris_cloud* in_cloud,
+ caris_dimension const** out_dimensions,
+ int * out_num_dimensions);
+ \brief get the dimensions
+ \param in_cloud
+ \li related caris_cloud
+ \param out_dimensions
+ \li set to a pointer to an array of caris_dimension
+ \param out_num_dimensions
+ \li set to the number of elements in \e out_dimensions
+
+ \fn void caris_cloud_extents(caris_cloud* in_cloud,
+ double* out_min_x, double* out_min_y, double* out_min_z,
+ double* out_max_x, double* out_max_y, double* out_max_z);
+ \brief get the extents (bound)
+ \param in_cloud
+ \li related caris_cloud
+ \param out_min_x, out_min_y, out_min_z, out_max_x, out_max_y, out_max_z
+ \li set the xyz extents of \e in_cloud
+
+ \fn char const* caris_cloud_spatial_reference(caris_cloud* in_cloud);
+ \brief get the spatial reference as a wkt string
+ \param in_cloud
+ \li related caris_cloud
+ \return
+ \li spatial reference as a wkt string
+ \li NULL if the spatial reference could not be converted to WKT
+
+ \fn int caris_cloud_status(caris_cloud* in_cloud);
+ \brief get the status
+ \param in_cloud
+ \li related caris_cloud
+ \return
+ \li 0 if the method succeeded, error code if it failed.
+ \li additionaly details available by passing this status to caris_status_message()
+
+ \fn caris_itr* caris_cloud_create_itr(caris_cloud* in_cloud)
+ \brief create a new caris_itr
+ \param in_cloud
+ \li related caris_cloud
+ \li must remain valid until the iterater is released
+ \return
+ \li a new caris_itr
+ \li must be released with caris_itr_release()
+ \li NULL on error, status available via caris_cloud_status()
+
+*/
+/*! @} */
+
+
+/*! \name caris_itr functions
+ @{
+
+ \fn void caris_itr_release(caris_itr* in_itr)
+ \brief release the resourses owned by a caris_itr
+ \param in_itr
+ \li iterator to release
+
+ \fn void caris_itr_next(caris_itr* in_itr)
+ \brief advance the iterator to the next block of data
+ May invalidate any pointers returned by caris_itr_read
+ \sa caris_itr_done()
+ \param in_itr
+ \li related caris_itr
+
+ \fn int caris_itr_done(caris_itr* in_itr);
+ \brief check if iteration is complete
+ \param in_itr
+ \li related caris_itr
+ \return
+ \li true if iteration is complete
+ \li false if the current block is valid
+
+ \fn int32_t caris_itr_num_points(caris_itr* in_itr);
+ \brief get the number of points in the current block
+ \param in_itr
+ \li related caris_itr
+ \return
+ \li number of points in the current block
+ \li 0 on error
+
+ \fn void const* caris_itr_read(caris_itr* in_itr,
+ int in_dimension_index, int32_t * out_num_points);
+ \brief read data from the current block
+ \param in_itr
+ \li related caris_itr
+ \param in_dimension_index
+ \li dimension index (array index of the dimension returned by caris_cloud_dimensions())
+ \param out_num_points
+ \li set to the number of points read
+ \return
+ \li pointer to data from the current block for dimension \e in_dimension_index
+ \li NULL on error, status available via caris_itr_status()
+
+ \fn int caris_itr_status(caris_itr* in_itr);
+ \brief get the status
+ \param in_itr
+ \li related caris_itr
+ \return
+ \li 0 if the method succeeded, error code if it failed.
+ \li additionaly details available by passing this status to caris_status_message()
+
+*/
+/*! @} */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
View
54 src/drivers/caris/config.h
@@ -0,0 +1,54 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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_DRIVERS_CSAR_CONFIG_HPP
+#define INCLUDED_DRIVERS_CSAR_CONFIG_HPP
+
+#ifdef _MSC_VER
+
+// disable msvc's "secure" and "deperated" warnings
+# ifndef _CRT_SECURE_NO_WARNINGS
+# define _CRT_SECURE_NO_WARNINGS
+# endif
+# ifndef _CRT_SECURE_NO_DEPRECATE
+# define _CRT_SECURE_NO_DEPRECATE
+# endif
+# ifndef _AFX_SECURE_NO_WARNINGS
+# define _AFX_SECURE_NO_WARNINGS
+# endif
+# ifndef _ATL_SECURE_NO_WARNINGS
+# define _ATL_SECURE_NO_WARNINGS
+# endif
+# ifndef _SCL_SECURE_NO_WARNINGS
+# define _SCL_SECURE_NO_WARNINGS
+# endif
+
+ //! Warnings to disable when including 3rd party headers
+# define DISABLED_3RDPARTY_WARNINGS 4244 4251 4267 4345 4503 4510 4512 4610 4701 4702
+#endif
+
+#endif
View
6 src/drivers/caris/linkline.cpp
@@ -0,0 +1,6 @@
+
+
+
+#pragma comment(lib, "pdal.lib")
+#pragma comment(lib, "gdal_i.lib")
+#pragma comment(lib, "caris_pc_wrapper.lib")
View
186 src/drivers/caris/pdal_csar.cpp
@@ -0,0 +1,186 @@
+/************************************************************************
+ * Copyright (c) 2012, CARIS
+ * 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 CARIS 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.
+ ************************************************************************/
+
+#include <pdal/drivers/caris/CloudReader.hpp>
+
+#include "Utils.hpp"
+
+#ifdef _MSC_VER
+# pragma warning(push, 3)
+# pragma warning(disable : DISABLED_3RDPARTY_WARNINGS)
+#endif
+
+#include <pdal/StageFactory.hpp>
+
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
+
+#ifdef _MSC_VER
+# define NOMINMAX
+# define WIN32_LEAN_AND_MEAN
+# include <Windows.h>
+# include <tchar.h>
+#endif
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+// decorated name length exceeded, name was truncated
+# pragma warning(disable : 4503)
+#endif
+
+namespace
+{
+ //! CARIS CSAR file Point Cloud Reader
+ class FileCloudReader : public csar::CloudReader
+ {
+
+ public:
+ SET_STAGE_NAME("drivers.csar.reader", "CARIS CSAR file Point Cloud Reader")
+
+ static pdal::Reader* create(const pdal::Options& in_opts)
+ {
+ return new FileCloudReader(in_opts);
+ }
+
+ virtual const pdal::Options getDefaultOptions() const
+ {
+ pdal::Options options;
+ options.add("filename", "", "file to read from");
+ return options;
+ }
+
+ protected:
+ virtual std::string getURI() const
+ {
+ return csar::utils::systemPathToURI(m_filename);
+ }
+
+ private:
+ explicit FileCloudReader(const pdal::Options& options)
+ : CloudReader(options)
+ , m_filename(options.getValueOrThrow<std::string>("filename"))
+ {
+ }
+
+ private:
+ std::string m_filename;
+ };
+
+ //! CARIS Database Point Cloud Reader
+ class DBCloudReader : public csar::CloudReader
+ {
+
+ public:
+ SET_STAGE_NAME("drivers.csardb.reader", "CARIS Database Point Cloud Reader")
+
+ static pdal::Reader* create(const pdal::Options& in_opts)
+ {
+ return new DBCloudReader(in_opts);
+ }
+
+ virtual const pdal::Options getDefaultOptions() const
+ {
+ pdal::Options options;
+ options.add("connection", "", "Database connection string formated as: "
+ "username/password@hostname%dbname%boid");
+ return options;
+ }
+
+ protected:
+ virtual std::string getURI() const
+ {
+ return "csardb:" + m_connectionString;
+ }
+
+ private:
+ explicit DBCloudReader(const pdal::Options& options)
+ : CloudReader(options)
+ , m_connectionString(options.getValueOrThrow<std::string>("connection"))
+ {
+ }
+
+ std::string m_connectionString;
+ };
+
+ //************************************************************************
+ //! get the path to the support file folder
+ //************************************************************************
+ std::string
+ getSupportPath()
+ {
+ #ifdef _MSC_VER
+ WCHAR moduleName[BUFSIZ] = L"";
+ ::GetModuleFileNameW(::GetModuleHandleW(L"libpdal_plugin_reader_csar"), moduleName, BUFSIZ-1);
+ boost::filesystem::path appDir = boost::filesystem::path(moduleName);
+ appDir.remove_filename();
+ appDir /= "support";
+ return appDir.string(boost::filesystem::detail::utf8_codecvt_facet());
+ #else
+ return "/usr/share/caris/support/";
+ #endif
+ }
+
+
+} // namespace
+
+extern "C"
+void PDALRegister_reader_csar(void* in_factoryPtr)
+{
+ try
+ {
+ static bool initialized = false;
+ if(!initialized)
+ {
+ initialized = true;
+
+ // no point caching read-only sequential access
+ const size_t cache_bytes = 0;
+ int rc = caris_init(cache_bytes, getSupportPath().c_str());
+ if(rc)
+ {
+ std::cerr
+ << FileCloudReader::s_getName()
+ << ": initialization failed: "
+ << caris_status_message(rc, false)
+ << std::endl;
+ }
+ }
+
+ pdal::StageFactory& factory = *(pdal::StageFactory*)in_factoryPtr;
+ factory.registerReader(FileCloudReader::s_getName(), &FileCloudReader::create);
+ factory.registerReader(DBCloudReader::s_getName(), &DBCloudReader::create);
+ }
+ catch(std::exception const& e)
+ {
+ std::cerr
+ << FileCloudReader::s_getName()
+ << ": initialization failed: "
+ << e.what()
+ << std::endl;
+ }
+}
View
2  src/drivers/caris/pdal_csar.def
@@ -0,0 +1,2 @@
+EXPORTS
+ PDALRegister_reader_csar
View
1  test/unit/CMakeLists.txt
@@ -19,6 +19,7 @@ SET(PDAL_UNITTEST_TEST_SRC
drivers/bpf/BPFTest.cpp
filters/ByteSwapFilterTest.cpp
filters/CacheFilterTest.cpp
+ drivers/caris/CarisReaderTest.cpp
filters/ChipperTest.cpp
filters/ColorFilterTest.cpp
filters/ColorizationFilterTest.cpp
View
70 test/unit/drivers/caris/CarisReaderTest.cpp
@@ -0,0 +1,70 @@
+/******************************************************************************
+* Copyright (c) 2012, Michael P. Gerlek (mpg@flaxen.com)
+*
+* 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 Consulting LLC 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.
+****************************************************************************/
+
+#include <boost/test/unit_test.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/uuid/uuid_io.hpp>
+
+#include <pdal/PointBuffer.hpp>
+
+#include <pdal/drivers/nitf/Reader.hpp>
+#include <pdal/drivers/las/Reader.hpp>
+#include <pdal/filters/Chipper.hpp>
+#include <pdal/drivers/pipeline/Reader.hpp>
+
+#include "Support.hpp"
+
+#include <iostream>
+
+#ifdef PDAL_COMPILER_GCC
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#pragma GCC diagnostic ignored "-Wsign-compare"
+#endif
+
+#include <boost/property_tree/xml_parser.hpp>
+
+using namespace pdal;
+
+BOOST_AUTO_TEST_SUITE(CarisReaderTest)
+
+BOOST_AUTO_TEST_CASE(test_one)
+{
+
+ return;
+}
+
+
+
+BOOST_AUTO_TEST_SUITE_END()
Please sign in to comment.
Something went wrong with that request. Please try again.