[Liblas-commits] hg-main-tree: oci::Block copy constructor should actually copy s...

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Mar 18 10:02:17 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/9e61e6cefa23
changeset: 362:9e61e6cefa23
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Mar 18 09:01:46 2011 -0500
description:
oci::Block copy constructor should actually copy something
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/d68bcc7451fb
changeset: 363:d68bcc7451fb
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Mar 18 09:02:12 2011 -0500
description:
merge

diffstat:

 CMakeLists.txt                         |   11 ++
 cmake/modules/FindMrSID.cmake          |   10 +-
 include/libpc/drivers/mrsid/Reader.hpp |   74 +++++++++++++
 src/CMakeLists.txt                     |   22 ++++
 src/Chipper.cpp                        |    8 +-
 src/drivers/mrsid/Reader.cpp           |  175 +++++++++++++++++++++++++++++++++
 6 files changed, 292 insertions(+), 8 deletions(-)

diffs (truncated from 360 to 300 lines):

diff -r a8af49df848a -r d68bcc7451fb CMakeLists.txt
--- a/CMakeLists.txt	Fri Mar 18 08:53:33 2011 -0500
+++ b/CMakeLists.txt	Fri Mar 18 09:02:12 2011 -0500
@@ -332,6 +332,17 @@
     "libPC currently requires a working libLAS installation 1.6.0 or greater")
 endif()
 
+# MrSID/LiDAR support - optiona, default=OFF
+set(WITH_MRSID FALSE CACHE BOOL "Choose if MrSID/LiDAR support should be built")
+
+if(WITH_MRSID)
+    find_package(MrSID)
+    if(MRSID_FOUND)
+        set(CMAKE_REQUIRED_LIBRARIES ${MRSID_LIBRARY})
+        include_directories(${MRSID_INCLUDE_DIR})
+    endif()
+endif()
+
 
 #------------------------------------------------------------------------------
 # installation path settings
diff -r a8af49df848a -r d68bcc7451fb cmake/modules/FindMrSID.cmake
--- a/cmake/modules/FindMrSID.cmake	Fri Mar 18 08:53:33 2011 -0500
+++ b/cmake/modules/FindMrSID.cmake	Fri Mar 18 09:02:12 2011 -0500
@@ -29,17 +29,15 @@
   message(STATUS "Searching for MrSID LiDAR library ${MrSID_FIND_VERSION}+")
 endif()
 
-if(NOT DEFINED ENV{MRSID_HOME})
-  message(FATAL_ERROR "Missing environment variable MRSID_HOME with location of MrSID LiDAR sdk")
+if(NOT MRSID_ROOT)
+  message(FATAL_ERROR "Missing variable MRSID_ROOT with location of MrSID LiDAR sdk")
 endif()
 
-set(MRSID_HOME $ENV{MRSID_HOME})
-
 find_path(MRSID_INCLUDE_DIR
           lidar/Base.h
           PATHS
-            ${MRSID_HOME}/include
-            ${MRSID_HOME}/Lidar_DSDK/include
+            ${MRSID_ROOT}/include
+            ${MRSID_ROOT}/Lidar_DSDK/include
           NO_DEFAULT_PATH)
 
 find_library(MRSID_LIBRARY
diff -r a8af49df848a -r d68bcc7451fb include/libpc/drivers/mrsid/Reader.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/drivers/mrsid/Reader.hpp	Fri Mar 18 09:02:12 2011 -0500
@@ -0,0 +1,74 @@
+/******************************************************************************
+* Copyright (c) 2011, Kirk McKelvey <kirkoman at gmail.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.
+****************************************************************************/
+
+#ifndef INCLUDED_DRIVERS_MRSID_READER_HPP
+#define INCLUDED_DRIVERS_MRSID_READER_HPP
+
+#include <string>
+#include <libpc/Stage.hpp>
+#include "lidar/MG4PointReader.h"
+
+namespace LizardTech
+{
+class MG4PointReader;
+}
+
+namespace libpc
+{
+namespace drivers
+{
+namespace mrsid
+{
+
+class LIBPC_DLL Reader : public libpc::Stage
+{
+public:
+    Reader(const char *);
+
+    const std::string& getName() const;
+
+protected:
+    boost::uint32_t readBuffer(PointData&);
+
+private:
+    Reader& operator=(const Reader&); // not implemented
+    Reader(const Reader&); // not implemented
+    LizardTech::MG4PointReader *m_reader;
+};
+
+}
+}
+} // end namespaces
+
+#endif // INCLUDED_DRIVERS_MRSID_READER_HPP
diff -r a8af49df848a -r d68bcc7451fb src/CMakeLists.txt
--- a/src/CMakeLists.txt	Fri Mar 18 08:53:33 2011 -0500
+++ b/src/CMakeLists.txt	Fri Mar 18 09:02:12 2011 -0500
@@ -191,6 +191,27 @@
 endif()
 
 #
+# drivers/mrsid
+#
+if (MRSID_FOUND)
+set(LIBPC_DRIVERS_MRSID_HPP
+  ${LIBPC_HEADERS_DIR}/drivers/mrsid/Reader.hpp
+)
+
+set (LIBPC_DRIVERS_MRSID_CPP 
+  ./drivers/mrsid/Reader.cpp
+)
+   
+FOREACH(file ${LIBPC_DRIVERS_MRSID_HPP})
+        SET(LIBPC_HPP "${LIBPC_HPP};${file}" CACHE INTERNAL "source files for drivers/mrsid")
+ENDFOREACH(file)
+
+FOREACH(file ${LIBPC_DRIVERS_MRSID_CPP})
+        SET(LIBPC_CPP "${LIBPC_CPP};${file}" CACHE INTERNAL "source files for drivers/mrsid")
+ENDFOREACH(file)
+endif()
+
+#
 # filters
 #
 
@@ -290,6 +311,7 @@
   ${LIBLAS_LIBRARY}
   ${TIFF_LIBRARY}
   ${ORACLE_LIBRARY}
+  ${MRSID_LIBRARY}
   ${GEOTIFF_LIBRARY}
   ${GDAL_LIBRARY}
   ${LASZIP_LIBRARY}
diff -r a8af49df848a -r d68bcc7451fb src/Chipper.cpp
--- a/src/Chipper.cpp	Fri Mar 18 08:53:33 2011 -0500
+++ b/src/Chipper.cpp	Fri Mar 18 09:02:12 2011 -0500
@@ -84,8 +84,12 @@
 {
     
 }
-Block::Block(Block const& block)
- : PointData(block.getSchema(), block.getCapacity())
+Block::Block(Block const& other)
+ : PointData(other)
+ , m_list_p(other.m_list_p)
+ , m_left(other.m_left)
+ , m_right(other.m_right)
+ , m_bounds(other.m_bounds)
 {
     
 }
diff -r a8af49df848a -r d68bcc7451fb src/drivers/mrsid/Reader.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/drivers/mrsid/Reader.cpp	Fri Mar 18 09:02:12 2011 -0500
@@ -0,0 +1,175 @@
+/******************************************************************************
+* Copyright (c) 2011, Kirk McKelvey <kirkoman at gmail.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 <libpc/drivers/mrsid/Reader.hpp>
+#include <libpc/exceptions.hpp>
+#include "lidar/MG4PointReader.h"
+
+namespace libpc
+{
+namespace drivers
+{
+namespace mrsid
+{
+
+LT_USE_LIDAR_NAMESPACE
+
+static libpc::Dimension::Field FieldEnumOf(const char *);
+static libpc::Dimension::DataType TypeEnumOf(LizardTech::DataType);
+
+Reader::Reader(const char * filepath)
+    : libpc::Stage(), m_reader(NULL)
+{
+    try
+    {
+        // open a MG4 file
+        m_reader = MG4PointReader::create();
+        m_reader->init(filepath);
+    }
+    catch(...)
+    {
+        RELEASE(m_reader);
+        throw;
+    }
+
+    Header* header = new Header;
+    Schema& schema = header->getSchema();
+
+    header->setNumPoints(m_reader->getNumPoints());
+    Bounds<double> bounds(m_reader->getBounds().x.min, m_reader->getBounds().y.min, m_reader->getBounds().z.min,
+                          m_reader->getBounds().x.max, m_reader->getBounds().y.max, m_reader->getBounds().z.max);
+
+    header->setBounds(bounds);
+
+    size_t numChannels = m_reader->getNumChannels();
+    const PointInfo &pointInfo = m_reader->getPointInfo();
+    for(size_t i = 0; i < numChannels; i += 1)
+        schema.addDimension(Dimension(FieldEnumOf(pointInfo.getChannel(i).getName()), TypeEnumOf(pointInfo.getChannel(i).getDataType())));
+
+    setHeader(header);
+
+    return;
+}
+
+libpc::Dimension::Field
+FieldEnumOf(const char * fieldname)
+{
+    if (!strcmp(CHANNEL_NAME_X, fieldname))
+        return Dimension::Field_X;
+    if (!strcmp(CHANNEL_NAME_Y, fieldname))
+        return Dimension::Field_Y;
+    if (!strcmp(CHANNEL_NAME_Y, fieldname))
+        return Dimension::Field_Z;
+    if (!strcmp(CHANNEL_NAME_Intensity, fieldname))
+        return Dimension::Field_Intensity;
+    if (!strcmp(CHANNEL_NAME_ReturnNum, fieldname))
+        return Dimension::Field_ReturnNumber;
+    if (!strcmp(CHANNEL_NAME_NumReturns, fieldname))
+        return Dimension::Field_NumberOfReturns;
+    if (!strcmp(CHANNEL_NAME_ScanDir, fieldname))
+        return Dimension::Field_ScanDirectionFlag;
+    if (!strcmp(CHANNEL_NAME_EdgeFlightLine, fieldname))
+        return Dimension::Field_EdgeOfFlightLine;
+    if (!strcmp(CHANNEL_NAME_ClassId, fieldname))
+        return Dimension::Field_Classification;
+    if (!strcmp(CHANNEL_NAME_ScanAngle, fieldname))
+        return Dimension::Field_ScanAngleRank;
+    if (!strcmp(CHANNEL_NAME_UserData, fieldname))
+        return Dimension::Field_UserData;
+    if (!strcmp(CHANNEL_NAME_SourceId, fieldname))
+        return Dimension::Field_PointSourceId;
+    if (!strcmp(CHANNEL_NAME_GPSTime, fieldname))
+        return Dimension::Field_Time;
+    if (!strcmp(CHANNEL_NAME_Red, fieldname))
+        return Dimension::Field_Red;


More information about the Liblas-commits mailing list