Skip to content

Commit

Permalink
Add lazperf pcpatch
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Jun 14, 2016
1 parent c15d4ef commit b3764bd
Show file tree
Hide file tree
Showing 38 changed files with 1,885 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .install-lazperf.sh
@@ -0,0 +1,4 @@
#!/bin/sh
set -ex
git clone https://github.com/verma/laz-perf.git
cd laz-perf; cmake .; make; sudo make install
10 changes: 9 additions & 1 deletion .travis.yml
Expand Up @@ -3,16 +3,24 @@ language: c
before_install:
- sudo apt-get update
- sudo apt-get install -q postgresql-server-dev-9.3 libcunit1-dev valgrind
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq

install:
- sudo apt-get install -qq g++-4.8
- export CXX="g++-4.8"
- sh .install-lazperf.sh

addons:
postgresql: "9.3" # for "installcheck"

before_script: ./autogen.sh

script:
- ./configure CFLAGS="-Wall -O2 -g"
- ./configure CFLAGS="-Wall -O2 -g" --with-lazperf=/usr/local/
- make
- make check
- valgrind --leak-check=full --error-exitcode=1 lib/cunit/cu_tester
- sudo make install
- make installcheck || { cat pgsql/regression.diffs && false; }
- cd tools/benchmark_compression && sh compression_benchmark.sh
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -102,7 +102,7 @@ include_directories (${ZLIB_INCLUDE_DIR})


#------------------------------------------------------------------------------
# cunit and ght
# cunit, ght and lazperf

if (WITH_TESTS)
find_package (CUnit)
Expand All @@ -114,6 +114,12 @@ if (LIBGHT_FOUND)
set (HAVE_LIBGHT 1)
endif (LIBGHT_FOUND)

find_package (LazPerf)

if (LAZPERF_FOUND)
set (HAVE_LAZPERF 1)
endif (LAZPERF_FOUND)

#------------------------------------------------------------------------------
# use default install location if not specified

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -19,3 +19,6 @@ astyle:
-type f \
-exec astyle --style=ansi --indent=tab --suffix=none {} ';'

maintainer-clean:
rm -f config.log config.mk config.status lib/pc_config.h configure
rm -rf autom4te.cache build
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -16,6 +16,7 @@ A PostgreSQL extension for storing point cloud (LIDAR) data.
- LibXML2 development packages must be installed, usually "libxml2-dev" or "libxml2-devel".
- CUnit packages must be installed, or [source built and installed](http://sourceforge.net/projects/cunit/ "CUnit").
- [Optional] GHT library may be installed for GHT compression support, [built from source](http://github.com/pramsey/libght/ "LibGHT")
- [Optional] LAZPERF library may be installed for LAZ compression support, [built from source](http://github.com/hobu/laz-perf "LAZPERF")

Tests can be disabled by passing ``WITH_TESTS=FALSE`` to cmake, e.g. ``cmake .. -DWITH_TESTS=FALSE``.
This removes the CUnit dependency.
Expand Down Expand Up @@ -439,6 +440,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc
> Allowed global compression schemes are:
> - auto -- determined by pcid
> - ght -- no compression config supported
> - laz -- no compression config supported
> - dimensional
> configuration is a comma-separated list of per-dimension
> compressions from this list:
Expand Down Expand Up @@ -506,6 +508,7 @@ There are currently three supported compressions:
- **None**, which stores points and patches as byte arrays using the type and formats described in the schema document.
- **Dimensional**, which stores points the same as 'none' but stores patches as collections of dimensional data arrays, with an "appropriate" compression applied. Dimensional compression makes the most sense for smaller patch sizes, since small patches will tend to have more homogeneous dimensions.
- **GHT** or "GeoHash Tree", which stores the points in a tree where each node stores the common values shared by all nodes below. For larger patch sizes, GHT should provide effective compression and performance for patch-wise operations. You must build Pointcloud with libght support to make use of the GHT compression.
- **LAZ** or "LASZip". You must build Pointcloud with LAZPERF support to make use of the LAZ compression.

If no compression is declared in `<pc:metadata>`, then a compression of "none" is assumed.

Expand Down Expand Up @@ -630,6 +633,17 @@ Where simple compression schemes fail, general purpose compression is applied to

GHT patches are much like dimensional patches, except their internal structure is more opaque. Use LibGHT to read the GHT data buffer out into a GHT tree in memory.

### Patch Binary (LAZ) ####

byte: endianness (1 = NDR, 0 = XDR)
uint32: pcid (key to POINTCLOUD_SCHEMAS)
uint32: 3 = LAZ compression
uint32: npoints
uint32: LAZ data size
data[]: LAZ data

LAZ patches are much like GHT patches. Use LAZPERF library to read the LAZ data buffer out into a LAZ buffer.

## Loading Data ##

The examples above show how to form patches from array of doubles, and well-known binary. You can write your own loader, using the uncompressed WKB format, or more simply you can load existing LIDAR files using the [PDAL](http://pointcloud.org "PDAL") processing and format conversion library.
Expand Down
16 changes: 16 additions & 0 deletions cmake/modules/FindLazPerf.cmake
@@ -0,0 +1,16 @@
# Find the LazPerf headers
#
# LAZPERF_INCLUDE_DIRS - The LazPerf include directory (directory where laz-perf/las.hpp was found)
# LAZPERF_FOUND - True if LazPerf found in system


FIND_PATH(LAZPERF_INCLUDE_DIR NAMES laz-perf/las.hpp)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LazPerf DEFAULT_MSG LAZPERF_INCLUDE_DIR)

IF(LAZPERF_FOUND)
SET(LAZPERF_INCLUDE_DIRS ${LAZPERF_INCLUDE_DIR})
ENDIF(LAZPERF_FOUND)

MARK_AS_ADVANCED(CLEAR LAZPERF_INCLUDE_DIR)
4 changes: 3 additions & 1 deletion config.mk.in
@@ -1,5 +1,6 @@
CC = @CC@
CFLAGS = @CFLAGS@
CXXFLAGS = -fPIC -std=c++0x

XML2_CPPFLAGS = @XML2_CPPFLAGS@
XML2_LDFLAGS = @XML2_LDFLAGS@
Expand All @@ -16,4 +17,5 @@ GHT_LDFLAGS = @GHT_LDFLAGS@
PG_CONFIG = @PG_CONFIG@
PGXS = @PGXS@

LIB_A = libpc.a
LIB_A = libpc.a
LIB_A_LAZPERF = liblazperf.a
40 changes: 40 additions & 0 deletions configure.ac
Expand Up @@ -12,6 +12,7 @@ dnl ***********************************************************************/
AC_INIT()
AC_CONFIG_MACRO_DIR([macros])
AC_CONFIG_HEADERS([lib/pc_config.h])
AC_LANG([C++])

dnl
dnl Compilers
Expand Down Expand Up @@ -325,6 +326,44 @@ fi
AC_SUBST([GHT_LDFLAGS])
AC_SUBST([GHT_CPPFLAGS])

dnl ===========================================================================
dnl Detect LazPerf
dnl ===========================================================================

AC_ARG_WITH([lazperf],
[AS_HELP_STRING([--with-lazperf=DIR], [specify the base lazperf installation directory])],
[LAZPERFDIR="$withval"], [LAZPERFDIR=""])

if test "x$LAZPERFDIR" = "xyes"; then
AC_MSG_ERROR([you must specify a parameter to --with-lazperf, e.g. --with-lazperf=/opt/local])
fi

if test "x$LAZPERFDIR" = "x"; then
AC_CHECK_HEADER([las.hpp],
[FOUND_LAZPERF="YES"],
[FOUND_LAZPERF="NO"])
elif test "x$GHTDIR" != "xno"; then
LAZPERF_CPPFLAGS="-I${LAZPERFDIR}/include/"

CFLAGS="$LAZPERF_CPPFLAGS"
CPPFLAGS="$LAZPERF_CPPFLAGS -std=c++0x"

AC_CHECK_HEADER([laz-perf/las.hpp],
[FOUND_LAZPERF="YES"],
[FOUND_LAZPERF="NO"])
fi

if test "x$FOUND_LAZPERF" = "xYES"; then
AC_DEFINE([HAVE_LAZPERF])
LAZPERF_STATUS="enabled"
if test $LAZPERFDIR; then
LAZPERF_STATUS="$LAZPERFDIR/include/laz-perf"
fi
else
LAZPERF_STATUS="disabled"
fi

AC_SUBST([LAZPERF_STATUS])

dnl ===========================================================================
dnl Figure out where this script is running
Expand Down Expand Up @@ -357,5 +396,6 @@ AC_MSG_RESULT([ PostgreSQL version: ${PGSQL_FULL_VERSION}])
AC_MSG_RESULT([ Libxml2 config: ${XML2CONFIG}])
AC_MSG_RESULT([ Libxml2 version: ${LIBXML2_VERSION}])
AC_MSG_RESULT([ LibGHT status: ${GHT_STATUS}])
AC_MSG_RESULT([ LazPerf status: ${LAZPERF_STATUS}])
AC_MSG_RESULT([ CUnit status: ${CUNIT_STATUS}])
AC_MSG_RESULT()
17 changes: 17 additions & 0 deletions lib/CMakeLists.txt
Expand Up @@ -9,6 +9,7 @@ set ( PC_SOURCES
pc_patch.c
pc_patch_dimensional.c
pc_patch_ght.c
pc_patch_lazperf.c
pc_patch_uncompressed.c
pc_point.c
pc_pointlist.c
Expand All @@ -18,6 +19,10 @@ set ( PC_SOURCES
pc_val.c
)

set ( LAZPERF_SOURCES
lazperf_adapter.cpp
)

set ( PC_HEADERS
hashtable.h
stringbuffer.h
Expand All @@ -27,6 +32,7 @@ set ( PC_HEADERS
)

add_library (libpc-static STATIC ${PC_SOURCES} ${PC_HEADERS})
add_library (liblazperf-static STATIC ${LAZPERF_SOURCES})

set_target_properties (libpc-static
PROPERTIES
Expand All @@ -36,12 +42,23 @@ set_target_properties (libpc-static
COMPILE_FLAGS -fPIC
)

set_target_properties (liblazperf-static
PROPERTIES
OUTPUT_NAME "lazperf"
PREFIX "lib"
CLEAN_DIRECT_OUTPUT 1
COMPILE_FLAGS "-fPIC -std=c++0x"
)

target_link_libraries (libpc-static xml2)
target_link_libraries (libpc-static z)
target_link_libraries (libpc-static m)
if (LIBGHT_FOUND)
target_link_libraries (libpc-static ght)
endif (LIBGHT_FOUND)
if (LAZPERF_FOUND)
target_link_libraries (libpc-static liblazperf-static)
endif (LAZPERF_FOUND)

if (WITH_TESTS)
add_subdirectory (cunit)
Expand Down
13 changes: 10 additions & 3 deletions lib/Makefile
Expand Up @@ -21,16 +21,23 @@ OBJS = \
pc_util.o \
pc_val.o \
stringbuffer.o \
hashtable.o
hashtable.o \
pc_patch_lazperf.o

all: $(LIB_A)
OBJS_LAZPERF = \
lazperf_adapter.o

all: $(LIB_A) $(LIB_A_LAZPERF)
$(MAKE) -C cunit $@

$(LIB_A): $(OBJS)
ar rs $@ $^

$(LIB_A_LAZPERF): $(OBJS_LAZPERF)
ar rs $@ $^

clean:
@rm -f $(OBJS) $(LIB_A)
@rm -f $(OBJS) $(LIB_A) $(OBJS_LAZPERF) $(LIB_A_LAZPERF)
$(MAKE) -C cunit $@

install:
Expand Down
1 change: 1 addition & 0 deletions lib/cunit/CMakeLists.txt
Expand Up @@ -8,6 +8,7 @@ set (PC_TEST_SOURCES
cu_pc_bytes.c
cu_pc_schema.c
cu_pc_patch.c
cu_pc_patch_lazperf.c
cu_tester.c
)

Expand Down
10 changes: 7 additions & 3 deletions lib/cunit/Makefile
Expand Up @@ -13,7 +13,8 @@ OBJS = \
cu_pc_schema.o \
cu_pc_point.o \
cu_pc_patch.o \
cu_pc_patch_ght.o
cu_pc_patch_ght.o \
cu_pc_patch_lazperf.o

ifeq ($(CUNIT_LDFLAGS),)
# No cunit? Emit message and continue
Expand All @@ -37,12 +38,15 @@ check: $(EXE)
endif

# Build the main unit test executable
$(EXE): $(OBJS) ../$(LIB_A)
$(CC) -o $@ $^ $(LDFLAGS) -lm
$(EXE): $(OBJS) ../$(LIB_A) ../$(LIB_A_LAZPERF)
$(CC) -o $@ $^ $(LDFLAGS) -lm -lstdc++

../$(LIB_A):
$(MAKE) -C .. $(LIB_A)

../$(LIB_A_LAZPERF):
$(MAKE) -C .. $(LIB_A_LAZPERF)

# Clean target
clean:
@rm -f $(OBJS)
Expand Down

0 comments on commit b3764bd

Please sign in to comment.