[Liblas-commits] hg: this code is iffy
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Jan 4 14:54:48 EST 2011
details: http://hg.liblas.orghg/rev/53e6b2859572
changeset: 2679:53e6b2859572
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jan 04 11:52:43 2011 -0800
description:
this code is iffy
Subject: hg: first pass at unit tests (#ifdef'd out, as not currently passing)
details: http://hg.liblas.orghg/rev/76d5e6269690
changeset: 2680:76d5e6269690
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jan 04 11:53:40 2011 -0800
description:
first pass at unit tests (#ifdef'd out, as not currently passing)
Subject: hg: pull-merge
details: http://hg.liblas.orghg/rev/b2b4ee72c615
changeset: 2681:b2b4ee72c615
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jan 04 11:54:33 2011 -0800
description:
pull-merge
diffstat:
CMakeLists.txt | 2 +-
apps/las2txt.cpp | 4 +-
cmake/modules/BuildOSGeo4W.cmake | 2 -
cmake/modules/FindLASzip.cmake | 11 +-
src/CMakeLists.txt | 6 +-
src/detail/writer/zipwriter.cpp | 18 +-
test/data/1.2-with-color.laz | 0
test/unit/CMakeLists.txt | 2 +
test/unit/common.cpp | 95 ++++++++++++++++++
test/unit/common.hpp | 8 +
test/unit/zipreader_test.cpp | 154 ++++++++++++++++++++++++++++++
test/unit/zipwriter_test.cpp | 198 +++++++++++++++++++++++++++++++++++++++
12 files changed, 482 insertions(+), 18 deletions(-)
diffs (truncated from 630 to 300 lines):
diff -r b8ede5465c2b -r b2b4ee72c615 CMakeLists.txt
--- a/CMakeLists.txt Tue Jan 04 08:05:32 2011 -0800
+++ b/CMakeLists.txt Tue Jan 04 11:54:33 2011 -0800
@@ -141,7 +141,7 @@
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ${LIBLAS_COMMON_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBLAS_COMMON_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
endif()
diff -r b8ede5465c2b -r b2b4ee72c615 apps/las2txt.cpp
--- a/apps/las2txt.cpp Tue Jan 04 08:05:32 2011 -0800
+++ b/apps/las2txt.cpp Tue Jan 04 11:54:33 2011 -0800
@@ -213,7 +213,7 @@
break;
/* the classification */
case 'c':
- output << p.GetClassification().GetClass();
+ output << static_cast<boost::uint32_t>(p.GetClassification().GetClass());
break;
/* the classification name */
case 'C':
@@ -275,7 +275,7 @@
std::string GetHeader(liblas::Reader& reader)
{
- boost::ignore_unused_variable_warning(reader);
+ boost::ignore_unused_variable_warning(reader);
std::ostringstream oss;
diff -r b8ede5465c2b -r b2b4ee72c615 cmake/modules/BuildOSGeo4W.cmake
--- a/cmake/modules/BuildOSGeo4W.cmake Tue Jan 04 08:05:32 2011 -0800
+++ b/cmake/modules/BuildOSGeo4W.cmake Tue Jan 04 11:54:33 2011 -0800
@@ -44,9 +44,7 @@
COMMAND ${CMAKE_COMMAND} -E echo "Building OSGeo4W install directories")
foreach(utility ${LIBLAS_UTILITIES})
- MESSAGE("Adding dependency for $utility")
add_dependencies( make_osgeo4w_directories ${utility} )
-
endforeach()
diff -r b8ede5465c2b -r b2b4ee72c615 cmake/modules/FindLASzip.cmake
--- a/cmake/modules/FindLASzip.cmake Tue Jan 04 08:05:32 2011 -0800
+++ b/cmake/modules/FindLASzip.cmake Tue Jan 04 11:54:33 2011 -0800
@@ -26,7 +26,7 @@
ENDIF()
IF(WIN32)
- SET(OSGEO4W_IMPORT_LIBRARY laszip_i)
+ SET(OSGEO4W_IMPORT_LIBRARY laszip)
IF(DEFINED ENV{OSGEO4W_ROOT})
SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT})
MESSAGE(STATUS "Trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}")
@@ -35,11 +35,15 @@
MESSAGE(STATUS "Trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}")
ENDIF()
ENDIF()
-
+
+
FIND_PATH(LASZIP_INCLUDE_DIR
laszip.hpp
PATH_PREFIXES laszip
PATHS
+ /usr/include
+ /usr/local/include
+ /tmp/lasjunk/include
${OSGEO4W_ROOT_DIR}/include)
SET(LASZIP_NAMES ${OSGEO4W_IMPORT_LIBRARY} laszip)
@@ -47,6 +51,9 @@
FIND_LIBRARY(LASZIP_LIBRARY
NAMES ${LASZIP_NAMES}
PATHS
+ /usr/lib
+ /usr/local/lib
+ /tmp/lasjunk/lib
${OSGEO4W_ROOT_DIR}/lib)
IF(LASZIP_FOUND)
diff -r b8ede5465c2b -r b2b4ee72c615 src/CMakeLists.txt
--- a/src/CMakeLists.txt Tue Jan 04 08:05:32 2011 -0800
+++ b/src/CMakeLists.txt Tue Jan 04 11:54:33 2011 -0800
@@ -208,9 +208,9 @@
# This hack is required to correctly link static into shared library.
# Such practice is not recommended as not portable, instead each library,
# static and shared should be built from sources separately.
-if(UNIX)
- add_definitions("-fPIC")
-endif()
+#if(UNIX)
+# add_definitions("-fPIC")
+#endif()
if(WIN32)
add_definitions("-DLAS_DLL_EXPORT=1")
diff -r b8ede5465c2b -r b2b4ee72c615 src/detail/writer/zipwriter.cpp
--- a/src/detail/writer/zipwriter.cpp Tue Jan 04 08:05:32 2011 -0800
+++ b/src/detail/writer/zipwriter.cpp Tue Jan 04 11:54:33 2011 -0800
@@ -123,6 +123,8 @@
if (!ok)
throw liblas_error("Error writing compressed point data");
+ /*++m_pointCount;*/
+
return;
}
@@ -130,14 +132,14 @@
{
// Try to update the point count on our way out, but we don't really
// care if we weren't able to write it.
- //try
- //{
- // UpdatePointCount(0);
- //
- //} catch (std::runtime_error const&)
- //{
- //
- //}
+ /*try
+ {
+ UpdatePointCount(0);
+
+ } catch (std::runtime_error const&)
+ {
+
+ }*/
delete m_zipper;
delete m_zipPoint;
diff -r b8ede5465c2b -r b2b4ee72c615 test/data/1.2-with-color.laz
Binary file test/data/1.2-with-color.laz has changed
diff -r b8ede5465c2b -r b2b4ee72c615 test/unit/CMakeLists.txt
--- a/test/unit/CMakeLists.txt Tue Jan 04 08:05:32 2011 -0800
+++ b/test/unit/CMakeLists.txt Tue Jan 04 11:54:33 2011 -0800
@@ -20,6 +20,8 @@
transform_test.cpp
variablerecord_test.cpp
writer_test.cpp
+ zipreader_test.cpp
+ zipwriter_test.cpp
liblas_test_suite.cpp)
INCLUDE_DIRECTORIES(
diff -r b8ede5465c2b -r b2b4ee72c615 test/unit/common.cpp
--- a/test/unit/common.cpp Tue Jan 04 08:05:32 2011 -0800
+++ b/test/unit/common.cpp Tue Jan 04 11:54:33 2011 -0800
@@ -202,4 +202,99 @@
ensure_distance(p.GetTime(), double(414093.84360000002), 0.0001);
}
+void test_file_12Color_point0(liblas::Point const& p)
+{
+ ensure_distance(p.GetX(), double(637012.240000), 0.0001);
+ ensure_distance(p.GetY(), double(849028.310000), 0.0001);
+ ensure_distance(p.GetZ(), double(431.660000), 0.0001);
+ ensure_distance(p.GetTime(), double(245380.782550), 0.0001);
+
+ ensure_equals(p.GetReturnNumber(), 1);
+ ensure_equals(p.GetNumberOfReturns(), 1);
+ ensure_equals(p.GetFlightLineEdge(), 0);
+ ensure_equals(p.GetIntensity(), 143);
+ ensure_equals(p.GetScanDirection(), 1);
+ ensure_equals(p.GetScanAngleRank(), -9);
+
+ ensure_equals(p.GetClassification().GetClass(), 1);
+ ensure_equals(p.GetClassification().IsWithheld(), false);
+ ensure_equals(p.GetClassification().IsKeyPoint(), false);
+ ensure_equals(p.GetClassification().IsSynthetic(), false);
+
+ ensure_equals(p.GetColor().GetRed(), 68);
+ ensure_equals(p.GetColor().GetGreen(), 77);
+ ensure_equals(p.GetColor().GetBlue(), 88);
}
+
+void test_file_12Color_point1(liblas::Point const& p)
+{
+ ensure_distance(p.GetX(), double(636896.330000), 0.0001);
+ ensure_distance(p.GetY(), double(849087.700000), 0.0001);
+ ensure_distance(p.GetZ(), double(446.390000), 0.0001);
+ ensure_distance(p.GetTime(), double(245381.452799), 0.0001);
+
+ ensure_equals(p.GetReturnNumber(), 1);
+ ensure_equals(p.GetNumberOfReturns(), 2);
+ ensure_equals(p.GetFlightLineEdge(), 0);
+ ensure_equals(p.GetIntensity(), 18);
+ ensure_equals(p.GetScanDirection(), 1);
+ ensure_equals(p.GetScanAngleRank(), -11);
+
+ ensure_equals(p.GetClassification().GetClass(), 1);
+ ensure_equals(p.GetClassification().IsWithheld(), false);
+ ensure_equals(p.GetClassification().IsKeyPoint(), false);
+ ensure_equals(p.GetClassification().IsSynthetic(), false);
+
+ ensure_equals(p.GetColor().GetRed(), 54);
+ ensure_equals(p.GetColor().GetGreen(), 66);
+ ensure_equals(p.GetColor().GetBlue(), 68);
+}
+
+void test_file_12Color_point2(liblas::Point const& p)
+{
+ ensure_distance(p.GetX(), double(636784.740000), 0.0001);
+ ensure_distance(p.GetY(), double(849106.660000), 0.0001);
+ ensure_distance(p.GetZ(), double(426.710000), 0.0001);
+ ensure_distance(p.GetTime(), double(245382.135950), 0.0001);
+
+ ensure_equals(p.GetReturnNumber(), 1);
+ ensure_equals(p.GetNumberOfReturns(), 1);
+ ensure_equals(p.GetFlightLineEdge(), 0);
+ ensure_equals(p.GetIntensity(), 118);
+ ensure_equals(p.GetScanDirection(), 0);
+ ensure_equals(p.GetScanAngleRank(), -10);
+
+ ensure_equals(p.GetClassification().GetClass(), 1);
+ ensure_equals(p.GetClassification().IsWithheld(), false);
+ ensure_equals(p.GetClassification().IsKeyPoint(), false);
+ ensure_equals(p.GetClassification().IsSynthetic(), false);
+
+ ensure_equals(p.GetColor().GetRed(), 112);
+ ensure_equals(p.GetColor().GetGreen(), 97);
+ ensure_equals(p.GetColor().GetBlue(), 114);
+}
+
+void test_laszip_vlr(liblas::Header const& header)
+{
+ bool found_vlr = false;
+
+ std::vector<liblas::VariableRecord> const& vlrs = header.GetVLRs();
+ std::vector<liblas::VariableRecord>::const_iterator it;
+ for (it = vlrs.begin(); it != vlrs.end(); ++it)
+ {
+ liblas::VariableRecord const& vlr = *it;
+ if (vlr.GetUserId(false).compare("laszip encoded") == 0)
+ {
+ ensure_equals(found_vlr, false); // make sure we only find one
+ found_vlr = true;
+
+ ensure_equals(vlr.GetRecordId(), 22204);
+ ensure_equals(vlr.GetRecordLength(), 52);
+ }
+ }
+
+ ensure_equals(found_vlr, true); // make sure we found exactly one
+
+ return;
+}
+}
diff -r b8ede5465c2b -r b2b4ee72c615 test/unit/common.hpp
--- a/test/unit/common.hpp Tue Jan 04 08:05:32 2011 -0800
+++ b/test/unit/common.hpp Tue Jan 04 11:54:33 2011 -0800
@@ -87,5 +87,13 @@
// Test of 4th point record in trunk/test/data/TO_core_last_clip.las file
void test_file10_point4(liblas::Point const& p);
+// Test of 1st, 2nd, 3rd point record in trunk/test/data/1.2-with-color.laz file
+void test_file_12Color_point0(liblas::Point const& p);
+void test_file_12Color_point1(liblas::Point const& p);
+void test_file_12Color_point2(liblas::Point const& p);
+
+// make sure we have a valid laszip VLR block
+void test_laszip_vlr(liblas::Header const& header);
+
} // namespace tut
diff -r b8ede5465c2b -r b2b4ee72c615 test/unit/zipreader_test.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/unit/zipreader_test.cpp Tue Jan 04 11:54:33 2011 -0800
@@ -0,0 +1,154 @@
+//
+// (C) Copyright 2010 Michael P. Gerlek (mpg at flaxen.com)
+// Distributed under the BSD License
+// (See accompanying file LICENSE.txt or copy at
+// http://www.opensource.org/licenses/bsd-license.php)
+//
+
+#ifdef HAVE_LASZIPxxx
+
+#include <liblas/liblas.hpp>
+#include <liblas/variablerecord.hpp>
+#include <tut/tut.hpp>
+#include <fstream>
+#include <string>
+#include "liblas_test.hpp"
+#include "common.hpp"
+
+namespace tut
+{
+ struct zipreader_data
+ {
+ std::string file_las;
+ std::string file_laz;
+
+ zipreader_data() :
+ file_las(g_test_data_path + "//1.2-with-color.las"),
More information about the Liblas-commits
mailing list