From a28ba81bdf1bf97fec9c957342a02dce9678679b Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Thu, 4 Jul 2013 09:46:19 -0700 Subject: [PATCH 1/8] Add patch for mingw and windows vsnprintf --- lib/stringbuffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/stringbuffer.c b/lib/stringbuffer.c index 1571974..1ae3278 100644 --- a/lib/stringbuffer.c +++ b/lib/stringbuffer.c @@ -206,7 +206,15 @@ stringbuffer_avprintf(stringbuffer_t *s, const char *fmt, va_list ap) /* Propogate errors up */ if ( len < 0 ) + { +#if defined(__MINGW64_VERSION_MAJOR) + /* Assume windows flaky vsnprintf that returns -1 if */ + /* initial buffer too small and add more space */ + len = _vscprintf(fmt, ap2); +#else return len; +#endif + } /* We didn't have enough space! */ /* Either Unix vsnprint returned write length larger than our buffer */ From d08829cc92c012fb1b116000d5e9282e28b26e3f Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 16 Jul 2013 13:22:22 -0700 Subject: [PATCH 2/8] Add link to mailing list --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 92d20b3..a4bb4cc 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A PostgreSQL extension for storing point cloud (LIDAR) data. +- Mailing list: http://lists.osgeo.org/mailman/listinfo/pgpointcloud/ + ## Build/Install ## From 3a9ffeca7f1a5011aeee5f266fe5b50701d51d0a Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 16 Jul 2013 15:51:46 -0500 Subject: [PATCH 3/8] set the cache to filter the whole file in a single block --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a4bb4cc..7145f82 100644 --- a/README.md +++ b/README.md @@ -598,8 +598,8 @@ Here is a simple example pipeline that reads a LAS file and writes into a Postgr - - + + From 97bd62d18cd1801335cc6a58a5ad3940ec1629ba Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 27 Aug 2013 10:14:36 -0700 Subject: [PATCH 4/8] Fix configuration for cases where pg_config not on path. Also quiet some linux warnings --- config.mk.in | 1 + configure.ac | 41 +++++++++++++++++++++-------------------- lib/pc_api_internal.h | 3 ++- lib/pc_config.h.in | 3 ++- lib/pc_dimstats.c | 3 ++- lib/pc_patch_ght.c | 3 ++- lib/pc_util.c | 3 ++- lib/stringbuffer.h | 3 ++- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/config.mk.in b/config.mk.in index ff8574e..d02483a 100644 --- a/config.mk.in +++ b/config.mk.in @@ -13,6 +13,7 @@ CUNIT_LDFLAGS = @CUNIT_LDFLAGS@ GHT_CPPFLAGS = @GHT_CPPFLAGS@ GHT_LDFLAGS = @GHT_LDFLAGS@ +PG_CONFIG = @PG_CONFIG@ PGXS = @PGXS@ LIB_A = libpc.a \ No newline at end of file diff --git a/configure.ac b/configure.ac index 8f94767..cc41dab 100644 --- a/configure.ac +++ b/configure.ac @@ -81,25 +81,25 @@ dnl =========================================================================== AC_ARG_WITH([pgconfig], [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])], - [PGCONFIG="$withval"], [PGCONFIG=""]) + [PG_CONFIG="$withval"], [PG_CONFIG=""]) -if test "x$PGCONFIG" = "x"; then - dnl PGCONFIG was not specified, so search within the current path - AC_PATH_PROG([PGCONFIG], [pg_config]) +if test "x$PG_CONFIG" = "x"; then + dnl PG_CONFIG was not specified, so search within the current path + AC_PATH_PROG([PG_CONFIG], [pg_config]) dnl If we couldn't find pg_config, display an error - if test "x$PGCONFIG" = "x"; then + if test "x$PG_CONFIG" = "x"; then AC_MSG_ERROR([could not find pg_config within the current path. You may need to try re-running configure with a --with-pgconfig parameter.]) fi else - dnl PGCONFIG was specified; display a message to the user - if test "x$PGCONFIG" = "xyes"; then + dnl PG_CONFIG was specified; display a message to the user + if test "x$PG_CONFIG" = "xyes"; then AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config]) else - if test -f $PGCONFIG; then - AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG]) + if test -f $PG_CONFIG; then + AC_MSG_RESULT([Using user-specified pg_config file: $PG_CONFIG]) else - AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist]) + AC_MSG_ERROR([the user-specified pg_config file $PG_CONFIG does not exist]) fi fi fi @@ -112,24 +112,25 @@ dnl packages, but don't install the Makefile it points to unless dnl the postgresql-server-dev packages are installed :) dnl =========================================================================== -PGXS=`$PGCONFIG --pgxs` +PGXS=`$PG_CONFIG --pgxs` if test ! -f $PGXS; then AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.]) fi +AC_SUBST([PG_CONFIG]) AC_SUBST([PGXS]) dnl Extract the version information from pg_config dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give dnl the final version. This is to guard against user error... -PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'` -PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'` -PGSQL_FULL_VERSION=`$PGCONFIG --version` +PGSQL_MAJOR_VERSION=`$PG_CONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'` +PGSQL_MINOR_VERSION=`$PG_CONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'` +PGSQL_FULL_VERSION=`$PG_CONFIG --version` PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION" -PGSQL_PKGLIBDIR=`$PGCONFIG --pkglibdir` -PGSQL_LIBDIR=`$PGCONFIG --libdir` -PGSQL_SHAREDIR=`$PGCONFIG --sharedir` +PGSQL_PKGLIBDIR=`$PG_CONFIG --pkglibdir` +PGSQL_LIBDIR=`$PG_CONFIG --libdir` +PGSQL_SHAREDIR=`$PG_CONFIG --sharedir` AC_MSG_RESULT([checking PostgreSQL version... $PGSQL_FULL_VERSION]) dnl Ensure that we are using PostgreSQL >= 9.0 @@ -138,8 +139,8 @@ if test ! "$PGSQL_MAJOR_VERSION" -ge 9; then fi dnl Extract the linker and include flags for the frontend (for programs that use libpq) -PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`" -lpq" -PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir` +PGSQL_FE_LDFLAGS=-L`$PG_CONFIG --libdir`" -lpq" +PGSQL_FE_CPPFLAGS=-I`$PG_CONFIG --includedir` AC_SUBST([PGSQL_FE_LDFLAGS]) AC_SUBST([PGSQL_FE_CPPFLAGS]) @@ -292,7 +293,7 @@ AC_MSG_RESULT([ -------------- Compiler Info ------------- ]) AC_MSG_RESULT([ C compiler: ${CC} ${CFLAGS}]) AC_MSG_RESULT() AC_MSG_RESULT([ -------------- Dependencies -------------- ]) -AC_MSG_RESULT([ PostgreSQL config: ${PGCONFIG}]) +AC_MSG_RESULT([ PostgreSQL config: ${PG_CONFIG}]) AC_MSG_RESULT([ PostgreSQL version: ${PGSQL_FULL_VERSION}]) AC_MSG_RESULT([ Libxml2 config: ${XML2CONFIG}]) AC_MSG_RESULT([ Libxml2 version: ${LIBXML2_VERSION}]) diff --git a/lib/pc_api_internal.h b/lib/pc_api_internal.h index 1992017..26d41cc 100644 --- a/lib/pc_api_internal.h +++ b/lib/pc_api_internal.h @@ -280,4 +280,5 @@ void pc_bitmap_filter(PCBITMAP *map, PC_FILTERTYPE filter, int i, double d, doub -#endif /* _PC_API_INTERNAL_H */ \ No newline at end of file +#endif /* _PC_API_INTERNAL_H */ + diff --git a/lib/pc_config.h.in b/lib/pc_config.h.in index 8ad8ee4..7985e81 100644 --- a/lib/pc_config.h.in +++ b/lib/pc_config.h.in @@ -1,2 +1,3 @@ -#undef HAVE_LIBGHT \ No newline at end of file +#undef HAVE_LIBGHT + diff --git a/lib/pc_dimstats.c b/lib/pc_dimstats.c index 0de919c..53d232c 100644 --- a/lib/pc_dimstats.c +++ b/lib/pc_dimstats.c @@ -137,4 +137,5 @@ pc_dimstats_update(PCDIMSTATS *pds, const PCPATCH_DIMENSIONAL *pdl) } } return PC_SUCCESS; -} \ No newline at end of file +} + diff --git a/lib/pc_patch_ght.c b/lib/pc_patch_ght.c index aa543e2..1bd7957 100644 --- a/lib/pc_patch_ght.c +++ b/lib/pc_patch_ght.c @@ -604,4 +604,5 @@ pc_pointlist_from_ght(const PCPATCH_GHT *pag) PCPATCH_UNCOMPRESSED *pu; pu = pc_patch_uncompressed_from_ght(pag); return pc_pointlist_from_uncompressed(pu); -} \ No newline at end of file +} + diff --git a/lib/pc_util.c b/lib/pc_util.c index c94417d..27d6b4b 100644 --- a/lib/pc_util.c +++ b/lib/pc_util.c @@ -313,4 +313,5 @@ void pc_bounds_merge(PCBOUNDS *b1, const PCBOUNDS *b2) if ( b2->ymin < b1->ymin ) b1->ymin = b2->ymin; if ( b2->xmax > b1->xmax ) b1->xmax = b2->xmax; if ( b2->ymax > b1->ymax ) b1->ymax = b2->ymax; -} \ No newline at end of file +} + diff --git a/lib/stringbuffer.h b/lib/stringbuffer.h index dada523..2a7a06e 100644 --- a/lib/stringbuffer.h +++ b/lib/stringbuffer.h @@ -75,4 +75,5 @@ extern char stringbuffer_lastchar(stringbuffer_t *s); extern int stringbuffer_trim_trailing_white(stringbuffer_t *s); extern int stringbuffer_trim_trailing_zeroes(stringbuffer_t *s); -#endif /* _STRINGBUFFER_H */ \ No newline at end of file +#endif /* _STRINGBUFFER_H */ + From e92de9f3f36ad45347b4c41c1dcf654b92bd7bd0 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 21 Oct 2013 10:51:01 -0700 Subject: [PATCH 5/8] Remove hard requirement for CUnit to build --- configure.ac | 4 ++-- lib/cunit/Makefile | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index cc41dab..dae65b6 100644 --- a/configure.ac +++ b/configure.ac @@ -64,11 +64,11 @@ AC_CHECK_HEADER([CUnit/CUnit.h], [ AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], - [AC_MSG_ERROR([could not locate CUnit required for unit tests])] + [AC_MSG_RESULT([notice C unit tests will not be run])] ) ], [ - AC_MSG_ERROR([could not locate CUnit required for unit tests]) + AC_MSG_RESULT([notice C unit tests will not be run]) ]) AC_SUBST([CUNIT_CPPFLAGS]) diff --git a/lib/cunit/Makefile b/lib/cunit/Makefile index ea3181e..5bb6d26 100644 --- a/lib/cunit/Makefile +++ b/lib/cunit/Makefile @@ -15,6 +15,18 @@ OBJS = \ cu_pc_patch.o \ cu_pc_patch_ght.o +ifeq ($(CUNIT_LDFLAGS),) +# No cunit? Emit message and continue + +all: + @echo "CUnit not found, skipping build" + +check: + @echo "CUnit not found, skipping tests" + +else +# Yes cunit? Build tests and run + # Build the unit tester all: $(EXE) @@ -22,6 +34,8 @@ all: $(EXE) check: $(EXE) @./$(EXE) +endif + # Build the main unit test executable $(EXE): $(OBJS) ../$(LIB_A) $(CC) -o $@ $^ $(LDFLAGS) -lm @@ -33,3 +47,4 @@ $(EXE): $(OBJS) ../$(LIB_A) clean: @rm -f $(OBJS) @rm -f $(EXE) + From 577b1b77cc982dc2f829aad5ae7c5e2fd0a41e1f Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 22 Oct 2013 13:47:44 -0700 Subject: [PATCH 6/8] Add new PDAL commandline format --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7145f82..4a4c8cc 100644 --- a/README.md +++ b/README.md @@ -551,23 +551,21 @@ The only issues to watch when creating WKB patches are: ensuring the data you wr #### Build and Install PDAL #### -Support for PostgreSQL Pointcloud in PDAL is currently brand-new and will have to be [built from source](http://www.pointcloud.org/compilation/index.html). The PostgresSQL Pointcloud driver uses the "soci" module for database read/write, which can be difficult to compile. Future versions will convert to using the `libpq` PostgreSQL client libraries directly, for a simpler install. +Support for PostgreSQL Pointcloud has been added to PDAL. It is in most recent builds, but if you want the latest version, you can [build from source](http://www.pointcloud.org/compilation/index.html). First, you will need to install the many, many dependencies of PDAL. - Read the compilation instructions: http://www.pointcloud.org/compilation/index.html - Read the dependency information: http://www.pointcloud.org/compilation/dependencies.html - - Install the "boost" package if your system has one - - Install the "soci" add-on for boost, and ensure the PgSQL plug-in is built: http://soci.sourceforge.net/ - Install the "proj4" library: https://trac.osgeo.org/proj/ - Install the "geos" library: https://trac.osgeo.org/geos/ - Install the "geotiff" library: http://trac.osgeo.org/geotiff/ - Install the "gdal" library: http://gdal.org/ - Install the "liblas" library: http://liblas.org/ -Then, clone the Pointcloud PDAL repository, that contains the latest version of the Pointcloud driver for PDAL (as well as the latest version of PDAL itself): +Then, clone the PDAL repository: - - Clone into a source directory: `git clone https://github.com/pramsey/PDAL PDAL` + - Clone into a source directory: `git clone https://github.com/PDAL/PDAL PDAL` - Make a build directory: `mkdir PDAL-build` - Enter the build directory: `cd PDAL-build` - Run CMake to find dependencies: `cmake ../PDAL` @@ -576,17 +574,17 @@ Then, clone the Pointcloud PDAL repository, that contains the latest version of - Once CMake has found all dependencies, run the build: `make all` - And install the artifacts: `make install` -If all the dependencies were found, including the `soci` driver for PostgreSQL, you're ready to run a PDAL import into PostgreSQL Pointcloud! +If all the dependencies were found, you're ready to run a PDAL import into PostgreSQL Pointcloud! #### Running `pcpipeline` #### -PDAL includes a limited command-line program, `pc2pc` that does simple transformations, but in order to load data into Pointcloud we use a "PDAL pipeline". A pipeline combines a format reader, and format writer, with filters that can alter or group the points together. +PDAL includes a `command linen program `_ that allows both simple format translations and more complex "pipelines" of transformation. The `pdal translate` does simple format transformations. In order to load data into Pointcloud we use a "PDAL pipeline", by calling `pdal pipeline`. A pipeline combines a format reader, and format writer, with filters that can alter or group the points together. PDAL pipelines are XML files, which nest together readers, filters, and writers into a processing chain that will be applied to the LIDAR data. To execute a pipeline file, run it through the `pcpipeline` command: - pcpipeline pipelinefile.xml + pdal pipeline --input pipelinefile.xml Here is a simple example pipeline that reads a LAS file and writes into a PostgreSQL Pointcloud database. @@ -597,9 +595,8 @@ Here is a simple example pipeline that reads a LAS file and writes into a Postgr - + - From ded9587b6dd1b8c5e0de2060bf3aa2f6bcaec9ec Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 22 Oct 2013 14:23:58 -0700 Subject: [PATCH 7/8] Comment out ght tests --- pgsql/sql/pointcloud.sql | 68 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/pgsql/sql/pointcloud.sql b/pgsql/sql/pointcloud.sql index 7d129ec..3575971 100644 --- a/pgsql/sql/pointcloud.sql +++ b/pgsql/sql/pointcloud.sql @@ -214,40 +214,40 @@ SELECT Min(PC_PatchMin(pa,'z')) FROM pa_test_dim; -CREATE TABLE IF NOT EXISTS pa_test_ght ( - pa PCPATCH(5) -); -\d pa_test_ght - -INSERT INTO pa_test_ght (pa) VALUES ('0000000005000000000000000200000002000000030000000500060000000200000003000000050008'); -INSERT INTO pa_test_ght (pa) VALUES ('000000000500000000000000020000000600000007000000050006000000090000000A00000005000A'); -INSERT INTO pa_test_ght (pa) VALUES ('0000000005000000000000000200000002000000030000000500060000000200000003000000050003'); -INSERT INTO pa_test_ght (pa) VALUES ('0000000005000000000000000200000002000000030000000500060000000200000003000000050001'); - -SELECT Sum(PC_NumPoints(pa)) FROM pa_test_ght; -SELECT Sum(PC_MemSize(pa)) FROM pa_test_ght; -SELECT Sum(PC_PatchMax(pa,'x')) FROM pa_test_ght; -SELECT Sum(PC_PatchMin(pa,'x')) FROM pa_test_ght; - -DELETE FROM pa_test_ght; -INSERT INTO pa_test_ght (pa) -SELECT PC_Patch(PC_MakePoint(5, ARRAY[x,y,z,intensity])) -FROM ( - SELECT - -127+a/100.0 AS x, - 45+a/100.0 AS y, - 1.0*a AS z, - a/10 AS intensity, - a/400 AS gid - FROM generate_series(1,1600) AS a -) AS values GROUP BY gid; - -SELECT Sum(PC_NumPoints(pa)) FROM pa_test_ght; -SELECT Sum(PC_MemSize(pa)) FROM pa_test_ght; - -SELECT Max(PC_PatchMax(pa,'x')) FROM pa_test_ght; -SELECT Min(PC_PatchMin(pa,'x')) FROM pa_test_ght; -SELECT Min(PC_PatchMin(pa,'z')) FROM pa_test_ght; +-- CREATE TABLE IF NOT EXISTS pa_test_ght ( +-- pa PCPATCH(5) +-- ); +-- \d pa_test_ght +-- +-- INSERT INTO pa_test_ght (pa) VALUES ('0000000005000000000000000200000002000000030000000500060000000200000003000000050008'); +-- INSERT INTO pa_test_ght (pa) VALUES ('000000000500000000000000020000000600000007000000050006000000090000000A00000005000A'); +-- INSERT INTO pa_test_ght (pa) VALUES ('0000000005000000000000000200000002000000030000000500060000000200000003000000050003'); +-- INSERT INTO pa_test_ght (pa) VALUES ('0000000005000000000000000200000002000000030000000500060000000200000003000000050001'); +-- +-- SELECT Sum(PC_NumPoints(pa)) FROM pa_test_ght; +-- SELECT Sum(PC_MemSize(pa)) FROM pa_test_ght; +-- SELECT Sum(PC_PatchMax(pa,'x')) FROM pa_test_ght; +-- SELECT Sum(PC_PatchMin(pa,'x')) FROM pa_test_ght; +-- +-- DELETE FROM pa_test_ght; +-- INSERT INTO pa_test_ght (pa) +-- SELECT PC_Patch(PC_MakePoint(5, ARRAY[x,y,z,intensity])) +-- FROM ( +-- SELECT +-- -127+a/100.0 AS x, +-- 45+a/100.0 AS y, +-- 1.0*a AS z, +-- a/10 AS intensity, +-- a/400 AS gid +-- FROM generate_series(1,1600) AS a +-- ) AS values GROUP BY gid; +-- +-- SELECT Sum(PC_NumPoints(pa)) FROM pa_test_ght; +-- SELECT Sum(PC_MemSize(pa)) FROM pa_test_ght; +-- +-- SELECT Max(PC_PatchMax(pa,'x')) FROM pa_test_ght; +-- SELECT Min(PC_PatchMin(pa,'x')) FROM pa_test_ght; +-- SELECT Min(PC_PatchMin(pa,'z')) FROM pa_test_ght; From 4cca22892900ec854dc95262e4f4e6f14e0ee82a Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 22 Oct 2013 16:09:37 -0700 Subject: [PATCH 8/8] For #4, return teeny bbox for single-point patches --- pgsql/pc_pgsql.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pgsql/pc_pgsql.c b/pgsql/pc_pgsql.c index fe2392b..44a749f 100644 --- a/pgsql/pc_pgsql.c +++ b/pgsql/pc_pgsql.c @@ -940,6 +940,16 @@ pc_patch_to_geometry_wkb_envelope(const SERIALIZED_PATCH *pa, const PCSCHEMA *sc int has_srid = false; size_t size = 1 + 4 + 4 + 4 + 2*npoints*8; /* endian + type + nrings + npoints + 5 dbl pts */ + /* Bounds! */ + double xmin = pa->bounds.xmin; + double ymin = pa->bounds.ymin; + double xmax = pa->bounds.xmax; + double ymax = pa->bounds.ymax; + + /* Make sure they're slightly bigger than a point */ + if ( xmin == xmax ) xmax += xmax * 0.0000001; + if ( ymin == ymax ) ymax += ymax * 0.0000001; + if ( schema->srid > 0 ) { has_srid = true;