From 063a5b16516c2a2752811da58d3ec81ff994f53f Mon Sep 17 00:00:00 2001 From: Blottiere Paul Date: Mon, 11 Jun 2018 14:27:37 +0100 Subject: [PATCH] Remove GHT support --- .install-libght.sh | 4 - .travis.yml | 5 +- README.md | 132 ++-- config.mk.in | 3 - configure.ac | 114 +--- lib/Makefile | 5 +- lib/cunit/Makefile | 5 +- lib/cunit/cu_pc_patch.c | 120 ---- lib/cunit/cu_pc_patch_ght.c | 152 ----- lib/cunit/cu_tester.c | 2 - .../data/simple-schema-empty-description.xml | 6 - lib/cunit/data/simple-schema-empty-name.xml | 6 - lib/cunit/data/simple-schema-fine.xml | 6 - .../data/simple-schema-missing-dimension.xml | 6 - lib/cunit/data/simple-schema-no-intensity.xml | 6 - lib/cunit/data/simple-schema-no-name.xml | 6 - lib/cunit/data/simple-schema-xy.xml | 6 - lib/cunit/data/simple-schema-xym.xml | 6 - lib/cunit/data/simple-schema-xyz.xml | 6 - lib/cunit/data/simple-schema-xyzm.xml | 6 - lib/cunit/data/simple-schema.xml | 6 - lib/pc_api.h | 16 +- lib/pc_api_internal.h | 13 - lib/pc_config.h.in | 4 +- lib/pc_filter.c | 9 - lib/pc_mem.c | 19 - lib/pc_patch.c | 97 +-- lib/pc_patch_dimensional.c | 4 +- lib/pc_patch_ght.c | 599 ------------------ lib/pc_patch_lazperf.c | 2 +- lib/pc_patch_uncompressed.c | 4 +- lib/pc_pointlist.c | 4 - lib/pc_schema.c | 8 - lib/pc_sort.c | 16 - pgsql/Makefile | 8 +- pgsql/expected/pointcloud-ght.out | 122 ---- pgsql/expected/pointcloud.out | 13 - pgsql/pc_access.c | 16 +- pgsql/pc_pgsql.c | 106 ---- pgsql/pointcloud.sql.in | 9 +- pgsql/sql/pointcloud-ght.sql | 80 --- pgsql/sql/pointcloud.sql | 13 - tools/benchmark.pl | 4 +- 43 files changed, 108 insertions(+), 1666 deletions(-) delete mode 100644 .install-libght.sh delete mode 100644 lib/cunit/cu_pc_patch_ght.c delete mode 100644 lib/pc_patch_ght.c delete mode 100644 pgsql/expected/pointcloud-ght.out delete mode 100644 pgsql/sql/pointcloud-ght.sql diff --git a/.install-libght.sh b/.install-libght.sh deleted file mode 100644 index 1b23989..0000000 --- a/.install-libght.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -ex -git clone https://github.com/pramsey/libght.git -cd libght; cmake .; make; sudo make install; sudo ldconfig diff --git a/.travis.yml b/.travis.yml index 90aa186..3e828f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ install: - sudo apt-get install -qq g++-4.8 - export CXX="g++-4.8" - sh .install-lazperf.sh - - sh .install-libght.sh - npm install -g eclint@1.1.5 addons: @@ -26,7 +25,7 @@ addons: script: - eclint check * */* */cunit/* - - ./tools/build-install.sh --with-lazperf=/usr/local --with-libght=/usr/local && make check - - ./tools/build-install.sh --with-lazperf=/usr/local --without-libght && ./tools/valgrind.sh + - ./tools/build-install.sh --with-lazperf=/usr/local && make check + - ./tools/build-install.sh --with-lazperf=/usr/local && ./tools/valgrind.sh - make installcheck || { cat pgsql/regression.diffs && false; } - (cd tools/benchmark_compression && sh compression_benchmark.sh) diff --git a/README.md b/README.md index af463a0..cef227b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ A PostgreSQL extension for storing point cloud (LIDAR) data. - PostgreSQL and PostgreSQL development packages must be installed (pg_config and server headers). For Red Hat and Ubuntu, the package names are usually "postgresql-dev" or "postgresql-devel" - 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") ### Build ### @@ -34,10 +33,6 @@ Run unit tests: - ``make check`` -Note that if you configured PointCloud using a non-standard LibGHT location, you may need to add its location to the ``LD_LIBRARY_PATH`` environment variable. For example: - -- ``LD_LIBRARY_PATH=$HOME/local/lib make check`` - ### SQL Tests ### pointcloud includes SQL tests to run against an existing installation. @@ -57,23 +52,23 @@ This command will create a database named `contrib_regression` and will execute ## Schemas ## -LIDAR sensors quickly produce millions of points with large numbers of variables measured on each point. The challenge for a point cloud database extension is efficiently storing this data while allowing high fidelity access to the many variables stored. +LIDAR sensors quickly produce millions of points with large numbers of variables measured on each point. The challenge for a point cloud database extension is efficiently storing this data while allowing high fidelity access to the many variables stored. -Much of the complexity in handling LIDAR comes from the need to deal with multiple variables per point. The variables captured by LIDAR sensors varies by sensor and capture process. Some data sets might contain only X/Y/Z values. Others will contain dozens of variables: X, Y, Z; intensity and return number; red, green, and blue values; return times; and many more. There is no consistency in how variables are stored: intensity might be stored in a 4-byte integer, or in a single byte; X/Y/Z might be doubles, or they might be scaled 4-byte integers. +Much of the complexity in handling LIDAR comes from the need to deal with multiple variables per point. The variables captured by LIDAR sensors varies by sensor and capture process. Some data sets might contain only X/Y/Z values. Others will contain dozens of variables: X, Y, Z; intensity and return number; red, green, and blue values; return times; and many more. There is no consistency in how variables are stored: intensity might be stored in a 4-byte integer, or in a single byte; X/Y/Z might be doubles, or they might be scaled 4-byte integers. PostgreSQL Pointcloud deals with all this variability by using a "schema document" to describe the contents of any particular LIDAR point. Each point contains a number of dimensions, and each dimension can be of any data type, with scaling and/or offsets applied to move between the actual value and the value stored in the database. The schema document format used by PostgreSQL Pointcloud is the same one used by the [PDAL](http://pointcloud.org) library. Here is a simple 4-dimensional schema document you can insert into `pointcloud_formats` to work with the examples below: - INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 4326, + INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 4326, ' - 1 4 - X coordinate as a long integer. You must use the - scale and offset information of the header to + X coordinate as a long integer. You must use the + scale and offset information of the header to determine the double value. X int32_t @@ -82,8 +77,8 @@ Here is a simple 4-dimensional schema document you can insert into `pointcloud_f 2 4 - Y coordinate as a long integer. You must use the - scale and offset information of the header to + Y coordinate as a long integer. You must use the + scale and offset information of the header to determine the double value. Y int32_t @@ -92,8 +87,8 @@ Here is a simple 4-dimensional schema document you can insert into `pointcloud_f 3 4 - Z coordinate as a long integer. You must use the - scale and offset information of the header to + Z coordinate as a long integer. You must use the + scale and offset information of the header to determine the double value. Z int32_t @@ -102,9 +97,9 @@ Here is a simple 4-dimensional schema document you can insert into `pointcloud_f 4 2 - The intensity value is the integer representation - of the pulse return magnitude. This value is optional - and system specific. However, it should always be + The intensity value is the integer representation + of the pulse return magnitude. This value is optional + and system specific. However, it should always be included if available. Intensity uint16_t @@ -124,7 +119,7 @@ The central role of the schema document in interpreting the contents of a point ### PcPoint ### -The basic point cloud type is a `PcPoint`. Every point has a (large?) number of dimensions, but at a minimum an X and Y coordinate that place it in space. +The basic point cloud type is a `PcPoint`. Every point has a (large?) number of dimensions, but at a minimum an X and Y coordinate that place it in space. Points can be rendered in a human-readable JSON form using the `PC_AsText(pcpoint)` function. The "pcid" is the foreign key reference to the `pointcloud_formats` table, where the meaning of each dimension in the "pt" array of doubles is explained. The underlying storage of the data might not be double, but by the time it has been extracted, scaled and offset, it is representable as doubles. @@ -136,9 +131,9 @@ Points can be rendered in a human-readable JSON form using the `PC_AsText(pcpoin ### PcPatch ### -The structure of database storage is such that storing billions of points as individual records in a table is not an efficient use of resources. Instead, we collect a group of `PcPoint` into a `PcPatch`. Each patch should hopefully contain points that are near together. +The structure of database storage is such that storing billions of points as individual records in a table is not an efficient use of resources. Instead, we collect a group of `PcPoint` into a `PcPatch`. Each patch should hopefully contain points that are near together. -Instead of a table of billions of single `PcPoint` records, a collection of LIDAR data can be represented in the database as a much smaller collection (10s of millions) of `PcPatch` records. +Instead of a table of billions of single `PcPoint` records, a collection of LIDAR data can be represented in the database as a much smaller collection (10s of millions) of `PcPatch` records. Patches can be rendered into a human-readable JSON form using the `PC_AsText(pcpatch)` function. The "pcid" is the foreign key reference to the `pointcloud_formats` table. @@ -152,9 +147,9 @@ Patches can be rendered into a human-readable JSON form using the `PC_AsText(pcp ## Tables ## -Usually you will only be creating tables for storing `PcPatch` objects, and using `PcPoint` objects as transitional objects for filtering, but it is possible to create tables of both types. `PcPatch` and `PcPoint` columns both require an argument that indicate the `pcid` that will be used to interpret the column. +Usually you will only be creating tables for storing `PcPatch` objects, and using `PcPoint` objects as transitional objects for filtering, but it is possible to create tables of both types. `PcPatch` and `PcPoint` columns both require an argument that indicate the `pcid` that will be used to interpret the column. - -- This example requires the schema entry from the previous + -- This example requires the schema entry from the previous -- section to be loaded so that pcid==1 exists. -- A table of points @@ -178,7 +173,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc SELECT * FROM pointcloud_columns; - schema | table | column | pcid | srid | type + schema | table | column | pcid | srid | type --------+-------------+--------+------+------+--------- public | points | pt | 1 | 4326 | pcpoint public | patches | pa | 1 | 4326 | pcpatch @@ -191,7 +186,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc **PC_MakePoint(pcid integer, vals float8[])** returns **pcpoint** > Given a valid `pcid` schema number and an array of doubles that matches the schema, construct a new `pcpoint`. -> +> > SELECT PC_MakePoint(1, ARRAY[-127, 45, 124.0, 4.0]); > > 010100000064CEFFFF94110000703000000400 @@ -201,8 +196,8 @@ Now that you have created two tables, you'll see entries for them in the `pointc > INSERT INTO points (pt) > SELECT PC_MakePoint(1, ARRAY[x,y,z,intensity]) > FROM ( -> SELECT -> -127+a/100.0 AS x, +> SELECT +> -127+a/100.0 AS x, > 45+a/100.0 AS y, > 1.0*a AS z, > a/10 AS intensity @@ -210,7 +205,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc > ) AS values; **PC_AsText(p pcpoint)** returns **text** - + > Return a JSON version of the data in that point. > > SELECT PC_AsText('010100000064CEFFFF94110000703000000400'::pcpoint); @@ -222,8 +217,8 @@ Now that you have created two tables, you'll see entries for them in the `pointc > Return the `pcid` schema number of this point. > > SELECT PC_PCId('010100000064CEFFFF94110000703000000400'::pcpoint); -> -> 1 +> +> 1 **PC_Get(pt pcpoint, dimname text)** returns **numeric** @@ -268,21 +263,21 @@ Now that you have created two tables, you'll see entries for them in the `pointc > Return the number of points in this patch. > > SELECT PC_NumPoints(pa) FROM patches LIMIT 1; -> -> 9 +> +> 9 **PC_PCId(p pcpatch)** returns **integer** (from 1.1.0) > Return the `pcid` schema number of points in this patch. > > SELECT PC_PCId(pa) FROM patches LIMIT 1; -> -> 1 +> +> 1 **PC_AsText(p pcpatch)** returns **text** > Return a JSON version of the data in that patch. -> +> > SELECT PC_AsText(pa) FROM patches LIMIT 1; > > {"pcid":1,"pts":[ @@ -303,14 +298,14 @@ Now that you have created two tables, you'll see entries for them in the `pointc > Returns an uncompressed version of the patch (compression type 'none'). > In order to return an uncompressed patch on the wire, this must be the -> outer function with return type `pcpatch` in your SQL query. All +> outer function with return type `pcpatch` in your SQL query. All > other functions that return `pcpatch` will compress output to the > schema-specified compression before returning. > -> SELECT PC_Uncompress(pa) FROM patches +> SELECT PC_Uncompress(pa) FROM patches > WHERE PC_NumPoints(pa) = 1; > -> 01010000000000000001000000C8CEFFFFF8110000102700000A00 +> 01010000000000000001000000C8CEFFFFF8110000102700000A00 **PC_Union(p pcpatch[])** returns **pcpatch** @@ -320,7 +315,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc > SELECT PC_NumPoints(PC_Union(pa)) FROM patches; > SELECT Sum(PC_NumPoints(pa)) FROM patches; > -> 100 +> 100 **PC_Intersects(p1 pcpatch, p2 pcpatch)** returns **boolean** @@ -336,11 +331,11 @@ Now that you have created two tables, you'll see entries for them in the `pointc **PC_Explode(p pcpatch)** returns **SetOf[pcpoint]** > Set-returning function, converts patch into result set of one point record for each point in the patch. -> -> SELECT PC_AsText(PC_Explode(pa)), id +> +> SELECT PC_AsText(PC_Explode(pa)), id > FROM patches WHERE id = 7; > -> pc_astext | id +> pc_astext | id > --------------------------------------+---- > {"pcid":1,"pt":[-126.5,45.5,50,5]} | 7 > {"pcid":1,"pt":[-126.49,45.51,51,5]} | 7 @@ -355,30 +350,30 @@ Now that you have created two tables, you'll see entries for them in the `pointc **PC_PatchAvg(p pcpatch, dimname text)** returns **numeric** -> Reads the values of the requested dimension for all points in the patch +> Reads the values of the requested dimension for all points in the patch > and returns the *average* of those values. Dimension name must exist in the schema. > -> SELECT PC_PatchAvg(pa, 'intensity') +> SELECT PC_PatchAvg(pa, 'intensity') > FROM patches WHERE id = 7; > > 5.0000000000000000 **PC_PatchMax(p pcpatch, dimname text)** returns **numeric** -> Reads the values of the requested dimension for all points in the patch +> Reads the values of the requested dimension for all points in the patch > and returns the *maximum* of those values. Dimension name must exist in the schema. > -> SELECT PC_PatchMax(pa, 'x') +> SELECT PC_PatchMax(pa, 'x') > FROM patches WHERE id = 7; > > -126.41 **PC_PatchMin(p pcpatch, dimname text)** returns **numeric** -> Reads the values of the requested dimension for all points in the patch +> Reads the values of the requested dimension for all points in the patch > and returns the *minimum* of those values. Dimension name must exist in the schema. > -> SELECT PC_PatchMin(pa, 'y') +> SELECT PC_PatchMin(pa, 'y') > FROM patches WHERE id = 7; > > 45.5 @@ -415,7 +410,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc > Returns a patch with only points whose values are greater than the supplied value > for the requested dimension. > -> SELECT PC_AsText(PC_FilterGreaterThan(pa, 'y', 45.57)) +> SELECT PC_AsText(PC_FilterGreaterThan(pa, 'y', 45.57)) > FROM patches WHERE id = 7; > > {"pcid":1,"pts":[[-126.42,45.58,58,5],[-126.41,45.59,59,5]]} @@ -441,7 +436,6 @@ Now that you have created two tables, you'll see entries for them in the `pointc > The compression_config semantic depends on the global compression scheme. > 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 @@ -453,7 +447,7 @@ Now that you have created two tables, you'll see entries for them in the `pointc **PC_PointN(p pcpatch, n int4)** returns **pcpoint** -> Returns the n-th point of the patch with 1-based indexing. Negative n counts point from the end. +> Returns the n-th point of the patch with 1-based indexing. Negative n counts point from the end. **PC_IsSorted(p pcpatch, dimnames text[], strict boolean default true)** returns **boolean** @@ -524,7 +518,7 @@ The `pointcloud_postgis` extension adds functions that allow you to use PostgreS CREATE EXTENSION postgis; CREATE EXTENSION pointcloud; CREATE EXTENSION pointcloud_postgis; - + **PC_Intersects(p pcpatch, g geometry)** returns **boolean**
**PC_Intersects(g geometry, p pcpatch)** returns **boolean** @@ -537,16 +531,16 @@ The `pointcloud_postgis` extension adds functions that allow you to use PostgreS **PC_Intersection(pcpatch, geometry)** returns **pcpatch** -> Returns a PcPatch which only contains points that intersected the +> Returns a PcPatch which only contains points that intersected the > geometry. > > SELECT PC_AsText(PC_Explode(PC_Intersection( -> pa, +> pa, > 'SRID=4326;POLYGON((-126.451 45.552, -126.42 47.55, -126.40 45.552, -126.451 45.552))'::geometry > ))) > FROM patches WHERE id = 7; > -> pc_astext +> pc_astext > -------------------------------------- > {"pcid":1,"pt":[-126.44,45.56,56,5]} > {"pcid":1,"pt":[-126.43,45.57,57,5]} @@ -558,9 +552,9 @@ The `pointcloud_postgis` extension adds functions that allow you to use PostgreS > Casts PcPoint to the PostGIS geometry equivalent, placing the x/y/z/m of the > PcPoint into the x/y/z/m of the PostGIS point. -> +> > SELECT ST_AsText(PC_MakePoint(1, ARRAY[-127, 45, 124.0, 4.0])::geometry); -> +> > POINT Z (-127 45 124) **PC_EnvelopeGeometry(pcpatch)** returns **geometry** @@ -611,7 +605,6 @@ There are currently four 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 ``, then a compression of "none" is assumed. @@ -647,7 +640,7 @@ For LIDAR data organized into patches of points that sample similar areas, the d ## Binary Formats ## -In order to preserve some compactness in dump files and network transmissions, the binary formats need to retain their native compression. All binary formats are hex-encoded before output. +In order to preserve some compactness in dump files and network transmissions, the binary formats need to retain their native compression. All binary formats are hex-encoded before output. The point and patch binary formats start with a common header, which provides: @@ -697,7 +690,7 @@ There are four possible compression types used in dimensional compression: - significant bits removal = 2, - deflate = 3 - + #### No dimension compress #### For dimensional compression 0 (no compression) the values just appear in order. The length of words in this dimension must be determined from the schema document. @@ -726,27 +719,16 @@ Significant bits removal starts with two words. The first word just gives the nu Where simple compression schemes fail, general purpose compression is applied to the dimension using zlib. The data area is a raw zlib buffer suitable for passing directly to the inflate() function. The size of the input buffer is given in the common dimension header. The size of the output buffer can be derived from the patch metadata by multiplying the dimension word size by the number of points in the patch. -### Patch Binary (GHT) #### - - byte: endianness (1 = NDR, 0 = XDR) - uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: 1 = GHT compression - uint32: npoints - uint32: GHT data size - uint8: GHT data - -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: 2 = 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. +Use LAZPERF library to read the LAZ data buffer out into a LAZ buffer. ## Loading Data ## @@ -861,12 +843,12 @@ The PDAL [writers.pgpointcloud](http://www.pdal.io/stages/writers.pgpointcloud.h - **pcid**: An existing PCID to use for the point cloud schema [Optional] - **pre_sql**: Before the pipeline runs, read and execute this SQL file or command [Optional] - **post_sql**: After the pipeline runs, read and execute this SQL file or command [Optional] - + The PDAL [readers.pgpointcloud](http://www.pdal.io/stages/readers.pgpointcloud.html) for PostgreSQL Pointcloud takes the following options: - **connection**: The PostgreSQL database connection string. E.g. `host=localhost user=username password=pw db=dbname port=5432` - **table**: The database table to read the patches from. -- **schema**: The schema to read the table from. [Optional] +- **schema**: The schema to read the table from. [Optional] - **column**: The column name in the patch table to read from. [Optional: "pa"] - **where**: SQL where clause to constrain the query [Optional] - **spatialreference**: Overrides the database declared SRID [Optional] diff --git a/config.mk.in b/config.mk.in index c2e1895..f3ebb6d 100644 --- a/config.mk.in +++ b/config.mk.in @@ -11,9 +11,6 @@ ZLIB_LDFLAGS = @ZLIB_LDFLAGS@ CUNIT_CPPFLAGS = @CUNIT_CPPFLAGS@ CUNIT_LDFLAGS = @CUNIT_LDFLAGS@ -GHT_CPPFLAGS = @GHT_CPPFLAGS@ -GHT_LDFLAGS = @GHT_LDFLAGS@ - PG_CONFIG = @PG_CONFIG@ PGXS = @PGXS@ diff --git a/configure.ac b/configure.ac index 230e69d..79140ee 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl * configure.ac dnl * dnl * Pointclound build configuration. dnl * -dnl * PgSQL Pointcloud is free and open source software provided +dnl * PgSQL Pointcloud is free and open source software provided dnl * by the Government of Canada dnl * Copyright (c) 2013 Natural Resources Canada dnl * @@ -49,32 +49,32 @@ AC_SUBST([POINTCLOUD_VERSION]) AC_DEFINE_UNQUOTED([POINTCLOUD_VERSION], ["$POINTCLOUD_VERSION"], [Pointcloud version]) dnl =========================================================================== -dnl Detect ZLib if it is installed +dnl Detect ZLib if it is installed dnl =========================================================================== ZLIB_LDFLAGS="" AC_CHECK_HEADER([zlib.h], [ ZLIB_CPPFLAGS="$CPPFLAGS" - AC_CHECK_LIB([z], - [inflate], - [ZLIB_LDFLAGS="$LDFLAGS -lz"], + AC_CHECK_LIB([z], + [inflate], + [ZLIB_LDFLAGS="$LDFLAGS -lz"], [AC_MSG_ERROR([could not locate zlib])] ) ], [ AC_MSG_ERROR([could not locate zlib]) ]) - + AC_SUBST([ZLIB_CPPFLAGS]) AC_SUBST([ZLIB_LDFLAGS]) dnl =========================================================================== -dnl Detect CUnit if it is installed +dnl Detect CUnit if it is installed dnl =========================================================================== -AC_ARG_WITH([cunit], - [AS_HELP_STRING([--with-cunit=DIR], [specify the base cunit install directory])], +AC_ARG_WITH([cunit], + [AS_HELP_STRING([--with-cunit=DIR], [specify the base cunit install directory])], [CUNITDIR="$withval"], [CUNITDIR=""]) if test "x$CUNITDIR" = "xyes"; then @@ -85,7 +85,7 @@ if test "x$CUNITDIR" != "x"; then dnl CUNITDIR was specified, so let's look there! - dnl Build the linker and include flags + dnl Build the linker and include flags CUNIT_LDFLAGS="-L${CUNITDIR}/lib" CUNIT_CPPFLAGS="-I${CUNITDIR}/include" @@ -102,9 +102,9 @@ fi dnl Run the header/link tests AC_CHECK_HEADER([CUnit/CUnit.h], [ CUNIT_CPPFLAGS="$CPPFLAGS" - AC_CHECK_LIB([cunit], - [CU_initialize_registry], - [CUNIT_LDFLAGS="$LDFLAGS -lcunit" FOUND_CUNIT="YES"], + AC_CHECK_LIB([cunit], + [CU_initialize_registry], + [CUNIT_LDFLAGS="$LDFLAGS -lcunit" FOUND_CUNIT="YES"], [FOUND_CUNIT="NO"] ) ], @@ -138,8 +138,8 @@ dnl =========================================================================== dnl Detect the version of PostgreSQL installed on the system dnl =========================================================================== -AC_ARG_WITH([pgconfig], - [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])], +AC_ARG_WITH([pgconfig], + [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])], [PG_CONFIG="$withval"], [PG_CONFIG=""]) if test "x$PG_CONFIG" = "x"; then @@ -165,8 +165,8 @@ fi dnl =========================================================================== -dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some -dnl distributions such as Debian also include pg_config as part of libpq-dev +dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some +dnl distributions such as Debian also include pg_config as part of libpq-dev dnl packages, but don't install the Makefile it points to unless dnl the postgresql-server-dev packages are installed :) dnl =========================================================================== @@ -181,9 +181,9 @@ 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=`$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'` +dnl the final version. This is to guard against user error... +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" @@ -195,7 +195,7 @@ AC_MSG_RESULT([checking PostgreSQL version... $PGSQL_FULL_VERSION]) dnl Ensure that we are using PostgreSQL >= 9.0 if test ! "$PGSQL_MAJOR_VERSION" -ge 9; then AC_MSG_ERROR([PointCloud requires PostgreSQL >= 9.0]) -fi +fi dnl Extract the linker and include flags for the frontend (for programs that use libpq) PGSQL_FE_LDFLAGS=-L`$PG_CONFIG --libdir`" -lpq" @@ -219,16 +219,16 @@ AC_CHECK_LIB([pq], [PQserverVersion], []) LIBS="$LIBS_SAVE" -AC_DEFINE_UNQUOTED([PGSQL_VERSION], [$PGSQL_VERSION], [PostgreSQL server version]) +AC_DEFINE_UNQUOTED([PGSQL_VERSION], [$PGSQL_VERSION], [PostgreSQL server version]) AC_SUBST([PGSQL_VERSION]) dnl =========================================================================== -dnl Detect LibXML2 +dnl Detect LibXML2 dnl =========================================================================== -AC_ARG_WITH([xml2config], - [AS_HELP_STRING([--with-xml2config=FILE], [specify an alternative xml2-config file])], +AC_ARG_WITH([xml2config], + [AS_HELP_STRING([--with-xml2config=FILE], [specify an alternative xml2-config file])], [XML2CONFIG="$withval"], [XML2CONFIG=""]) if test "x$XML2CONFIG" = "x"; then @@ -248,12 +248,12 @@ else AC_MSG_RESULT([Using user-specified xml2-config file: $XML2CONFIG]) else AC_MSG_ERROR([the user-specified xml2-config file $XML2CONFIG does not exist]) - fi + fi fi fi -dnl Extract the linker and include flags +dnl Extract the linker and include flags XML2_LDFLAGS=`$XML2CONFIG --libs` XML2_CPPFLAGS=`$XML2CONFIG --cflags` @@ -278,61 +278,6 @@ AC_SUBST([LIBXML2_VERSION]) AC_SUBST([XML2_LDFLAGS]) AC_SUBST([XML2_CPPFLAGS]) -dnl =========================================================================== -dnl Detect LibGHT -dnl =========================================================================== - -AC_ARG_WITH([libght], - [AS_HELP_STRING([--with-libght=DIR], [specify the base libght installation directory])], - [GHTDIR="$withval"], [GHTDIR=""]) - -if test "x$GHTDIR" = "xyes"; then - AC_MSG_ERROR([you must specify a parameter to --with-libght, e.g. --with-libght=/opt/local]) -fi - -if test "x$GHTDIR" = "x"; then - dnl GHTDIR was not specified, so search in usual system places - AC_CHECK_HEADER([ght.h], [GHT_CPPFLAGS="$CPPFLAGS" FOUND_GHT_H="YES"], [FOUND_GHT_H="NO"]) - AC_CHECK_LIB([ght], [ght_init], [GHT_LDFLAGS="-lght" FOUND_GHT_LIB="YES"], [FOUND_GHT_LIB="NO"]) -elif test "x$GHTDIR" != "xno"; then - dnl GHTDIR was specified, so let's look there! - - - dnl Extract the linker and include flags - GHT_LDFLAGS="-L${GHTDIR}/lib -lght" - GHT_CPPFLAGS="-I${GHTDIR}/include" - - dnl Check headers file - CPPFLAGS_SAVE="$CPPFLAGS" - CPPFLAGS="$GHT_CPPFLAGS $XML2_CPPFLAGS" - - dnl Check libraries file - LIBS_SAVE="$LIBS" - LIBS="$GHT_LDFLAGS $XML2_LDFLAGS" - - AC_CHECK_HEADER([ght.h], [FOUND_GHT_H="YES"], [FOUND_GHT_H="NO"]) - AC_CHECK_LIB([ght], [ght_init], [FOUND_GHT_LIB="YES"], [FOUND_GHT_LIB="NO"]) - - dnl back to the originals - LIBS="${LIBS_SAVE}" - CPPFLAGS="${CPPFLAGS_SAVE}" -fi - -if test "x$FOUND_GHT_H" = "xYES" -a "x$FOUND_GHT_LIB" = "xYES"; then - AC_DEFINE([HAVE_LIBGHT], [1], [Have libght]) - GHT_STATUS="enabled" - if test $GHTDIR; then - GHT_STATUS="$GHTDIR" - fi -else - GHT_LDFLAGS="" - GHT_CPPFLAGS="" - GHT_STATUS="disabled" -fi - -AC_SUBST([GHT_LDFLAGS]) -AC_SUBST([GHT_CPPFLAGS]) - dnl =========================================================================== dnl Detect LazPerf dnl =========================================================================== @@ -391,10 +336,10 @@ dnl =========================================================================== dnl Output the relevant files dnl =========================================================================== -AC_OUTPUT([ +AC_OUTPUT([ config.mk ]) - + dnl =========================================================================== dnl Display the configuration status information dnl =========================================================================== @@ -410,7 +355,6 @@ 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}]) -AC_MSG_RESULT([ LibGHT status: ${GHT_STATUS}]) AC_MSG_RESULT([ LazPerf status: ${LAZPERF_STATUS}]) AC_MSG_RESULT([ CUnit status: ${CUNIT_STATUS}]) AC_MSG_RESULT() diff --git a/lib/Makefile b/lib/Makefile index 622a949..cf42c73 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,8 +1,8 @@ include ../config.mk -CPPFLAGS = $(XML2_CPPFLAGS) $(ZLIB_CPPFLAGS) $(GHT_CPPFLAGS) $(LAZPERF_CPPFLAGS) -LDFLAGS = $(XML2_LDFLAGS) $(ZLIB_LDFLAGS) $(GHT_LDFLASGS) +CPPFLAGS = $(XML2_CPPFLAGS) $(ZLIB_CPPFLAGS) $(LAZPERF_CPPFLAGS) +LDFLAGS = $(XML2_LDFLAGS) $(ZLIB_LDFLAGS) CFLAGS += -fPIC OBJS = \ @@ -13,7 +13,6 @@ OBJS = \ pc_patch.o \ pc_patch_dimensional.o \ pc_patch_uncompressed.o \ - pc_patch_ght.o \ pc_point.o \ pc_pointlist.o \ pc_schema.o \ diff --git a/lib/cunit/Makefile b/lib/cunit/Makefile index 2b5307a..d69f03d 100644 --- a/lib/cunit/Makefile +++ b/lib/cunit/Makefile @@ -1,8 +1,8 @@ include ../../config.mk -CPPFLAGS = $(XML2_CPPFLAGS) $(CUNIT_CPPFLAGS) $(ZLIB_CPPFLAGS) $(GHT_CPPFLAGS) -I.. -LDFLAGS = $(XML2_LDFLAGS) $(CUNIT_LDFLAGS) $(ZLIB_LDFLAGS) $(GHT_LDFLAGS) +CPPFLAGS = $(XML2_CPPFLAGS) $(CUNIT_CPPFLAGS) $(ZLIB_CPPFLAGS) -I.. +LDFLAGS = $(XML2_LDFLAGS) $(CUNIT_LDFLAGS) $(ZLIB_LDFLAGS) EXE = cu_tester @@ -13,7 +13,6 @@ OBJS = \ cu_pc_schema.o \ cu_pc_point.o \ cu_pc_patch.o \ - cu_pc_patch_ght.o \ cu_pc_patch_lazperf.o \ cu_pc_sort.o \ cu_pc_util.o diff --git a/lib/cunit/cu_pc_patch.c b/lib/cunit/cu_pc_patch.c index 09baae1..68ea7bf 100644 --- a/lib/cunit/cu_pc_patch.c +++ b/lib/cunit/cu_pc_patch.c @@ -625,36 +625,6 @@ test_patch_filter() return; } -#if defined(HAVE_LIBGHT) && defined(HAVE_LAZPERF) -static void -test_patch_compress_from_ght_to_lazperf() -{ - PCPOINT *point; - PCPOINTLIST *pointlist; - PCPATCH_GHT *patch_ght; - PCPATCH_LAZPERF *patch_lazperf; - - pointlist = pc_pointlist_make(1); - point = pc_point_make(simplelazschema); - pc_point_set_double_by_name(point, "x", 2.0); - pc_point_set_double_by_name(point, "y", 1.9); - pc_point_set_double_by_name(point, "Z", 0.34); - pc_point_set_double_by_name(point, "intensity", 10); - pc_pointlist_add_point(pointlist, point); - - patch_ght = pc_patch_ght_from_pointlist(pointlist); - CU_ASSERT(patch_ght->type == PC_GHT); - - patch_lazperf = (PCPATCH_LAZPERF *)pc_patch_compress((PCPATCH *)patch_ght, NULL); - CU_ASSERT(patch_lazperf != NULL); - CU_ASSERT(patch_lazperf->type == PC_LAZPERF); - - pc_pointlist_free(pointlist); - pc_patch_free((PCPATCH *)patch_ght); - pc_patch_free((PCPATCH *)patch_lazperf); -} -#endif /* defined(HAVE_LIBGHT) && defined(HAVE_LAZPERF) */ - static void test_patch_pointn_last_first() { @@ -791,39 +761,6 @@ test_patch_pointn_dimensional_compression_rle() test_patch_pointn_dimensional_compression(PC_DIM_RLE); } -static void -test_patch_pointn_ght_compression() -{ - // 00 endian (big) - // 00000000 pcid - // 00000000 compression - // 00000003 npoints - // 0000000800000003000000050006 pt1 (XYZi) - // 0000000200000003000000040008 pt2 (XYZi) - // 0000000200000003000000040009 pt3 (XYZi) - - char *hexbuf = "00000000000000000000000003000000080000000300000005000600000002000000030000000400080000000200000003000000040009"; - size_t hexsize = strlen(hexbuf); - uint8_t *wkb = pc_bytes_from_hexbytes(hexbuf, hexsize); - - PCPATCH *pa = pc_patch_from_wkb(simpleschema, wkb, hexsize/2); - PCPOINTLIST *li = pc_pointlist_from_patch(pa); - -#ifdef HAVE_LIBGHT - PCPATCH_GHT* pag = pc_patch_ght_from_pointlist(li); - PCPOINT *pt = pc_patch_pointn((PCPATCH*) pag, 2); - CU_ASSERT(pt != NULL); - CU_ASSERT_STRING_EQUAL(pc_point_to_string(pt), "{\"pcid\":0,\"pt\":[0.02,0.03,0.04,8]}"); - pc_patch_free( (PCPATCH*) pag ); - pc_point_free(pt); -#endif - - // free - pcfree(wkb); - pc_patch_free(pa); - pc_pointlist_free(li); -} - #ifdef HAVE_LAZPERF static void test_patch_pointn_laz_compression() @@ -1215,56 +1152,6 @@ test_patch_set_schema_compression_lazperf() } #endif /* HAVE_LAZPERF */ -#ifdef HAVE_LIBGHT -static void -test_patch_set_schema_compression_ght() -{ - // init data - PCPATCH_GHT *pag; - PCPATCH *pat0, *pat1; - PCPOINTLIST *pl; - PCPOINT *pt; - char *str; - int i; - int npts = 4; - - // build a patch - pl = pc_pointlist_make(npts); - - for ( i = npts; i >= 0; i-- ) - { - pt = pc_point_make(simpleschema); - pc_point_set_double_by_name(pt, "X", i * 0.1); - pc_point_set_double_by_name(pt, "Y", i * 0.2); - pc_point_set_double_by_name(pt, "Z", i * 0.3); - pc_point_set_double_by_name(pt, "Intensity", 10); - pc_pointlist_add_point(pl, pt); - } - - pag = pc_patch_ght_from_pointlist(pl); - - // assign a valid schema to the patch - pat0 = pc_patch_set_schema((PCPATCH*) pag, simpleschema_nointensity, 0.0); - CU_ASSERT(pat0 != NULL); - str = pc_patch_to_string(pat0); - CU_ASSERT_STRING_EQUAL(str, "{\"pcid\":0,\"pts\":[[0.4,0.8,1.2],[0.3,0.6,0.9],[0.2,0.4,0.6],[0.1,0.2,0.3],[0,0,0]]}"); - pcfree(str); - - // assign a schema with unknown dimension to the patch - pat1 = pc_patch_set_schema(pat0, simpleschema, 0.0); - CU_ASSERT(pat1 != NULL); - str = pc_patch_to_string(pat1); - CU_ASSERT_STRING_EQUAL(str, "{\"pcid\":0,\"pts\":[[0.4,0.8,1.2,0],[0.3,0.6,0.9,0],[0.2,0.4,0.6,0],[0.1,0.2,0.3,0],[0,0,0,0]]}"); - pcfree(str); - - pc_patch_free(pat0); - pc_patch_free(pat1); - - pc_patch_free((PCPATCH*) pag); - pc_pointlist_free(pl); -} -#endif - static void test_patch_set_schema_dimensional_compression(enum DIMCOMPRESSIONS dimcomp) { @@ -1450,16 +1337,12 @@ CU_TestInfo patch_tests[] = { PC_TEST(test_patch_union), PC_TEST(test_patch_wkb), PC_TEST(test_patch_filter), -#if defined(HAVE_LIBGHT) && defined(HAVE_LAZPERF) - PC_TEST(test_patch_compress_from_ght_to_lazperf), -#endif PC_TEST(test_patch_pointn_last_first), PC_TEST(test_patch_pointn_no_compression), PC_TEST(test_patch_pointn_dimensional_compression_none), PC_TEST(test_patch_pointn_dimensional_compression_zlib), PC_TEST(test_patch_pointn_dimensional_compression_sigbits), PC_TEST(test_patch_pointn_dimensional_compression_rle), - PC_TEST(test_patch_pointn_ght_compression), #ifdef HAVE_LAZPERF PC_TEST(test_patch_pointn_laz_compression), #endif @@ -1477,9 +1360,6 @@ CU_TestInfo patch_tests[] = { #endif PC_TEST(test_patch_set_schema_compression_none), PC_TEST(test_patch_set_schema_compression_none_offset), -#ifdef HAVE_LIBGHT - PC_TEST(test_patch_set_schema_compression_ght), -#endif PC_TEST(test_patch_set_schema_dimensional_compression_none), PC_TEST(test_patch_set_schema_dimensional_compression_zlib), PC_TEST(test_patch_set_schema_dimensional_compression_sigbits), diff --git a/lib/cunit/cu_pc_patch_ght.c b/lib/cunit/cu_pc_patch_ght.c deleted file mode 100644 index 4967ee0..0000000 --- a/lib/cunit/cu_pc_patch_ght.c +++ /dev/null @@ -1,152 +0,0 @@ -/*********************************************************************** -* cu_pc_schema.c -* -* Testing for the schema API functions -* -* Portions Copyright (c) 2012, OpenGeo -* -***********************************************************************/ - -#include "CUnit/Basic.h" -#include "cu_tester.h" - -/* GLOBALS ************************************************************/ - -static PCSCHEMA *simpleschema = NULL; -static const char *simplexmlfile = "data/simple-schema-fine.xml"; - -/* Setup/teardown for this suite */ -static int -init_suite(void) -{ - char *xmlstr = file_to_str(simplexmlfile); - simpleschema = pc_schema_from_xml(xmlstr); - pcfree(xmlstr); - if ( !simpleschema ) return 1; - - return 0; -} - -static int -clean_suite(void) -{ - pc_schema_free(simpleschema); - return 0; -} - -/* TESTS **************************************************************/ - -#ifdef HAVE_LIBGHT - -static void -test_patch_ght() -{ - PCPOINT *pt; - int i; - static int npts = 100; - PCPOINTLIST *pl; - PCPATCH_GHT *pag; - PCPATCH_UNCOMPRESSED *pu; - - pl = pc_pointlist_make(npts); - - for ( i = 0; i < npts; i++ ) - { - pt = pc_point_make(simpleschema); - pc_point_set_double_by_name(pt, "x", 45 + i*0.000004); - pc_point_set_double_by_name(pt, "y", 45 + i*0.000001666); - pc_point_set_double_by_name(pt, "Z", 10 + i*0.34); - pc_point_set_double_by_name(pt, "intensity", 10); - pc_pointlist_add_point(pl, pt); - } - - pag = pc_patch_ght_from_pointlist(pl); - pc_pointlist_free(pl); - - pu = pc_patch_uncompressed_from_ght(pag); - CU_ASSERT_EQUAL(npts, pag->npoints); - CU_ASSERT_EQUAL(npts, pu->npoints); - - CU_ASSERT_DOUBLE_EQUAL(pag->bounds.xmax, 45.0004, 0.0001); - CU_ASSERT_DOUBLE_EQUAL(pag->bounds.ymax, 45.000165, 0.000001); - - // pl2 = pc_pointlist_from_uncompressed(pu); - // for ( i = 0; i < npts; i++ ) - // { - // PCPOINT *pt = pc_pointlist_get_point(pl2, i); - // double x, y, z, ints; - // pc_point_get_double_by_name(pt, "x", &x); - // pc_point_get_double_by_name(pt, "y", &y); - // pc_point_get_double_by_name(pt, "Z", &z); - // pc_point_get_double_by_name(pt, "intensity", &ints); - // printf("(%g %g %g) %g\n", x, y, z, ints); - // } - // pc_pointlist_free(pl2); - - pc_patch_uncompressed_free(pu); - pc_patch_ght_free(pag); -} - -static void -test_patch_ght_filtering() -{ - int dimnum = 2; /* Z */ - PCPOINT *pt; - int i; - static int npts = 100; - PCPOINTLIST *pl; - PCPATCH_GHT *pag, *pag_filtered; - - pl = pc_pointlist_make(npts); - - for ( i = 0; i < npts; i++ ) - { - pt = pc_point_make(simpleschema); - pc_point_set_double_by_name(pt, "x", 45 + i*0.000004); - pc_point_set_double_by_name(pt, "y", 45 + i*0.000001666); - pc_point_set_double_by_name(pt, "Z", 10 + i*0.34); - pc_point_set_double_by_name(pt, "intensity", 10); - pc_pointlist_add_point(pl, pt); - } - - pag = pc_patch_ght_from_pointlist(pl); - pc_pointlist_free(pl); - - pag_filtered = pc_patch_ght_filter(pag, dimnum, PC_LT, 10, 10); - CU_ASSERT_EQUAL(pag_filtered->npoints, 0); - pc_patch_ght_free(pag_filtered); - - pag_filtered = pc_patch_ght_filter(pag, dimnum, PC_LT, 11, 11); - CU_ASSERT_EQUAL(pag_filtered->npoints, 3); - pc_patch_ght_free(pag_filtered); - - pag_filtered = pc_patch_ght_filter(pag, dimnum, PC_GT, 11, 11); - CU_ASSERT_EQUAL(pag_filtered->npoints, 97); - pc_patch_ght_free(pag_filtered); - - pag_filtered = pc_patch_ght_filter(pag, dimnum, PC_BETWEEN, 11, 16); - CU_ASSERT_EQUAL(pag_filtered->npoints, 15); - pc_patch_ght_free(pag_filtered); - - pc_patch_ght_free(pag); -} - - -#endif /* HAVE_LIBGHT */ - -/* REGISTER ***********************************************************/ - -CU_TestInfo ght_tests[] = { -#ifdef HAVE_LIBGHT - PC_TEST(test_patch_ght), - PC_TEST(test_patch_ght_filtering), -#endif - CU_TEST_INFO_NULL -}; - -CU_SuiteInfo ght_suite = { - .pName = "ght", - .pInitFunc = init_suite, - .pCleanupFunc = clean_suite, - .pTests = ght_tests -}; diff --git a/lib/cunit/cu_tester.c b/lib/cunit/cu_tester.c index 306a78f..344a77c 100644 --- a/lib/cunit/cu_tester.c +++ b/lib/cunit/cu_tester.c @@ -16,7 +16,6 @@ extern CU_SuiteInfo schema_suite; extern CU_SuiteInfo patch_suite; extern CU_SuiteInfo point_suite; -extern CU_SuiteInfo ght_suite; extern CU_SuiteInfo bytes_suite; extern CU_SuiteInfo lazperf_suite; extern CU_SuiteInfo sort_suite; @@ -53,7 +52,6 @@ int main(int argc, char *argv[]) schema_suite, patch_suite, point_suite, - ght_suite, bytes_suite, lazperf_suite, sort_suite, diff --git a/lib/cunit/data/simple-schema-empty-description.xml b/lib/cunit/data/simple-schema-empty-description.xml index 72916d6..a24f23a 100644 --- a/lib/cunit/data/simple-schema-empty-description.xml +++ b/lib/cunit/data/simple-schema-empty-description.xml @@ -34,12 +34,6 @@
dimensional - - - - - - 4326
diff --git a/lib/cunit/data/simple-schema-empty-name.xml b/lib/cunit/data/simple-schema-empty-name.xml index 319072d..efdfe9a 100644 --- a/lib/cunit/data/simple-schema-empty-name.xml +++ b/lib/cunit/data/simple-schema-empty-name.xml @@ -41,12 +41,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-fine.xml b/lib/cunit/data/simple-schema-fine.xml index 50e6918..3c6420c 100644 --- a/lib/cunit/data/simple-schema-fine.xml +++ b/lib/cunit/data/simple-schema-fine.xml @@ -34,12 +34,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-missing-dimension.xml b/lib/cunit/data/simple-schema-missing-dimension.xml index 08955b2..0c374e6 100644 --- a/lib/cunit/data/simple-schema-missing-dimension.xml +++ b/lib/cunit/data/simple-schema-missing-dimension.xml @@ -34,12 +34,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-no-intensity.xml b/lib/cunit/data/simple-schema-no-intensity.xml index 396a052..9481473 100644 --- a/lib/cunit/data/simple-schema-no-intensity.xml +++ b/lib/cunit/data/simple-schema-no-intensity.xml @@ -26,12 +26,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-no-name.xml b/lib/cunit/data/simple-schema-no-name.xml index 832224b..809700b 100644 --- a/lib/cunit/data/simple-schema-no-name.xml +++ b/lib/cunit/data/simple-schema-no-name.xml @@ -40,12 +40,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-xy.xml b/lib/cunit/data/simple-schema-xy.xml index 7bf8954..80e3ab6 100644 --- a/lib/cunit/data/simple-schema-xy.xml +++ b/lib/cunit/data/simple-schema-xy.xml @@ -26,12 +26,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-xym.xml b/lib/cunit/data/simple-schema-xym.xml index 3421d48..76f7852 100644 --- a/lib/cunit/data/simple-schema-xym.xml +++ b/lib/cunit/data/simple-schema-xym.xml @@ -34,12 +34,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-xyz.xml b/lib/cunit/data/simple-schema-xyz.xml index 944512a..5055606 100644 --- a/lib/cunit/data/simple-schema-xyz.xml +++ b/lib/cunit/data/simple-schema-xyz.xml @@ -34,12 +34,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema-xyzm.xml b/lib/cunit/data/simple-schema-xyzm.xml index 517fbeb..80949dd 100644 --- a/lib/cunit/data/simple-schema-xyzm.xml +++ b/lib/cunit/data/simple-schema-xyzm.xml @@ -42,12 +42,6 @@ dimensional - - - - - - 4326 diff --git a/lib/cunit/data/simple-schema.xml b/lib/cunit/data/simple-schema.xml index c3799a6..d4fb7f5 100644 --- a/lib/cunit/data/simple-schema.xml +++ b/lib/cunit/data/simple-schema.xml @@ -34,12 +34,6 @@ dimensional - - - - - - 4326 diff --git a/lib/pc_api.h b/lib/pc_api.h index dca1235..eba7358 100644 --- a/lib/pc_api.h +++ b/lib/pc_api.h @@ -21,10 +21,6 @@ #include "pc_config.h" #include "hashtable.h" -#ifdef HAVE_LIBGHT -#include "ght.h" -#endif - #ifndef __GNUC__ #define __attribute__ (x) #endif @@ -39,9 +35,8 @@ enum COMPRESSIONS { PC_NONE = 0, - PC_GHT = 1, - PC_DIMENSIONAL = 2, - PC_LAZPERF = 3 + PC_DIMENSIONAL = 1, + PC_LAZPERF = 2 }; /** @@ -196,13 +191,6 @@ typedef struct PCBYTES *bytes; } PCPATCH_DIMENSIONAL; -typedef struct -{ - PCPATCH_COMMON - size_t ghtsize; - uint8_t *ght; -} PCPATCH_GHT; - typedef struct { PCPATCH_COMMON diff --git a/lib/pc_api_internal.h b/lib/pc_api_internal.h index 54d8a52..f909bb6 100644 --- a/lib/pc_api_internal.h +++ b/lib/pc_api_internal.h @@ -197,19 +197,6 @@ PCPATCH_UNCOMPRESSED* pc_patch_uncompressed_from_dimensional(const PCPATCH_DIMEN int pc_patch_uncompressed_add_point(PCPATCH_UNCOMPRESSED *c, const PCPOINT *p); PCPOINT *pc_patch_uncompressed_pointn(const PCPATCH_UNCOMPRESSED *patch, int n); -/* GHT PATCHES */ -char* pc_patch_ght_to_string(const PCPATCH_GHT *patch); -PCPATCH_GHT* pc_patch_ght_from_uncompressed(const PCPATCH_UNCOMPRESSED *pa); -PCPATCH_GHT* pc_patch_ght_from_pointlist(const PCPOINTLIST *pdl); -PCPATCH_UNCOMPRESSED* pc_patch_uncompressed_from_ght(const PCPATCH_GHT *pght); -void pc_patch_ght_free(PCPATCH_GHT *paght); -int pc_patch_ght_compute_extent(PCPATCH_GHT *patch); -uint8_t* pc_patch_ght_to_wkb(const PCPATCH_GHT *patch, size_t *wkbsize); -PCPATCH* pc_patch_ght_from_wkb(const PCSCHEMA *schema, const uint8_t *wkb, size_t wkbsize); -PCPOINTLIST* pc_pointlist_from_ght(const PCPATCH_GHT *pag); -PCPATCH_GHT* pc_patch_ght_filter(const PCPATCH_GHT *patch, uint32_t dimnum, PC_FILTERTYPE filter, double val1, double val2); -PCPOINT *pc_patch_ght_pointn(const PCPATCH_GHT *patch, int n); - /* LAZPERF PATCHES */ PCPATCH_LAZPERF* pc_patch_lazperf_from_pointlist(const PCPOINTLIST *pl); PCPATCH_LAZPERF* pc_patch_lazperf_from_uncompressed(const PCPATCH_UNCOMPRESSED *pa); diff --git a/lib/pc_config.h.in b/lib/pc_config.h.in index 2298d52..89978ff 100644 --- a/lib/pc_config.h.in +++ b/lib/pc_config.h.in @@ -2,12 +2,10 @@ #undef PGSQL_VERSION -#undef HAVE_LIBGHT - #undef HAVE_LAZPERF #undef HAVE_CUNIT -#undef PROJECT_SOURCE_DIR +#undef PROJECT_SOURCE_DIR #undef POINTCLOUD_VERSION diff --git a/lib/pc_filter.c b/lib/pc_filter.c index 4d353c8..5d5cd9f 100644 --- a/lib/pc_filter.c +++ b/lib/pc_filter.c @@ -251,15 +251,6 @@ pc_patch_filter(const PCPATCH *pa, uint32_t dimnum, PC_FILTERTYPE filter, double paout = (PCPATCH*)pu; break; } - case PC_GHT: - { - PCPATCH_GHT *pgh = pc_patch_ght_filter((PCPATCH_GHT*)pa, dimnum, filter, val1, val2); - /* pc_patch_ght_filter computes the bounds itself */ - /* TODO: add stats computation to pc_patch_ght_filter */ - /* pc_patch_ght_filter is just re-using the input stats, which is wrong */ - paout = (PCPATCH*)pgh; - break; - } case PC_DIMENSIONAL: { PCBITMAP *map = pc_patch_dimensional_bitmap((PCPATCH_DIMENSIONAL*)pa, dimnum, filter, val1, val2); diff --git a/lib/pc_mem.c b/lib/pc_mem.c index 70a53db..86d6714 100644 --- a/lib/pc_mem.c +++ b/lib/pc_mem.c @@ -90,15 +90,6 @@ void pc_install_default_handlers(void) pc_context.err = default_error_handler; pc_context.info = default_info_handler; pc_context.warn = default_warn_handler; - -#ifdef HAVE_LIBGHT - ght_set_handlers( - (void *)default_allocator, (void *)default_reallocator, - (void *)default_freeor, (void *)default_error_handler, - (void *)default_info_handler, (void *)default_warn_handler - ); -#endif - } void pc_set_handlers( @@ -119,17 +110,7 @@ void pc_set_handlers( pc_context.err = error_handler; pc_context.warn = warn_handler; pc_context.info = info_handler; - -#ifdef HAVE_LIBGHT - ght_set_handlers( - (void *)allocator, (void *)reallocator, - (void *)deallocator, (void *)error_handler, - (void *)info_handler, (void *)warn_handler - ); -#endif - return; - } diff --git a/lib/pc_patch.c b/lib/pc_patch.c index 1800d2a..1b15496 100644 --- a/lib/pc_patch.c +++ b/lib/pc_patch.c @@ -22,8 +22,6 @@ pc_patch_compute_extent(PCPATCH *pa) { case PC_NONE: return pc_patch_uncompressed_compute_extent((PCPATCH_UNCOMPRESSED*)pa); - case PC_GHT: - return pc_patch_ght_compute_extent((PCPATCH_GHT*)pa); case PC_DIMENSIONAL: return pc_patch_dimensional_compute_extent((PCPATCH_DIMENSIONAL*)pa); case PC_LAZPERF: @@ -53,14 +51,6 @@ pc_patch_compute_stats(PCPATCH *pa) pc_patch_uncompressed_free(pu); return PC_SUCCESS; } - case PC_GHT: - { - PCPATCH_UNCOMPRESSED *pu = pc_patch_uncompressed_from_ght((PCPATCH_GHT*)pa); - pc_patch_uncompressed_compute_stats(pu); - pa->stats = pc_stats_clone(pu->stats); - pc_patch_uncompressed_free(pu); - return PC_SUCCESS; - } case PC_LAZPERF: { PCPATCH_UNCOMPRESSED *pu = pc_patch_uncompressed_from_lazperf((PCPATCH_LAZPERF*)pa); @@ -99,11 +89,6 @@ pc_patch_free(PCPATCH *patch) pc_patch_uncompressed_free((PCPATCH_UNCOMPRESSED*)patch); break; } - case PC_GHT: - { - pc_patch_ght_free((PCPATCH_GHT*)patch); - break; - } case PC_DIMENSIONAL: { pc_patch_dimensional_free((PCPATCH_DIMENSIONAL*)patch); @@ -153,15 +138,6 @@ pc_patch_compress(const PCPATCH *patch, void *userdata) /* Make sure it's compressed, return */ return (PCPATCH*)pc_patch_dimensional_compress((PCPATCH_DIMENSIONAL*)patch, (PCDIMSTATS*)userdata); } - else if ( patch_compression == PC_GHT ) - { - /* Uncompress, dimensionalize, dimensionally compress, return */ - PCPATCH_UNCOMPRESSED *pcu = pc_patch_uncompressed_from_ght((PCPATCH_GHT*)patch); - PCPATCH_DIMENSIONAL *pcdu = pc_patch_dimensional_from_uncompressed(pcu); - PCPATCH_DIMENSIONAL *pcdc = pc_patch_dimensional_compress(pcdu, NULL); - pc_patch_dimensional_free(pcdu); - return (PCPATCH*)pcdc; - } else if ( patch_compression == PC_LAZPERF ) { PCPATCH_UNCOMPRESSED *pcu = pc_patch_uncompressed_from_lazperf( (PCPATCH_LAZPERF*) patch ); @@ -187,11 +163,6 @@ pc_patch_compress(const PCPATCH *patch, void *userdata) return (PCPATCH*)pcu; } - else if ( patch_compression == PC_GHT ) - { - PCPATCH_UNCOMPRESSED *pcu = pc_patch_uncompressed_from_ght((PCPATCH_GHT*)patch); - return (PCPATCH*)pcu; - } else if ( patch_compression == PC_LAZPERF ) { PCPATCH_UNCOMPRESSED *pcu = pc_patch_uncompressed_from_lazperf( (PCPATCH_LAZPERF*)patch ); @@ -202,35 +173,6 @@ pc_patch_compress(const PCPATCH *patch, void *userdata) pcerror("%s: unknown patch compression type %d", __func__, patch_compression); } } - case PC_GHT: - { - if ( patch_compression == PC_NONE ) - { - PCPATCH_GHT *pgc = pc_patch_ght_from_uncompressed((PCPATCH_UNCOMPRESSED*)patch); - if ( ! pgc ) pcerror("%s: ght compression failed", __func__); - return (PCPATCH*)pgc; - } - else if ( patch_compression == PC_DIMENSIONAL ) - { - PCPATCH_UNCOMPRESSED *pcu = pc_patch_uncompressed_from_dimensional((PCPATCH_DIMENSIONAL*)patch); - PCPATCH_GHT *pgc = pc_patch_ght_from_uncompressed((PCPATCH_UNCOMPRESSED*)patch); - pc_patch_uncompressed_free(pcu); - return (PCPATCH*)pgc; - } - else if ( patch_compression == PC_GHT ) - { - return (PCPATCH*)patch; - } - else if ( patch_compression == PC_LAZPERF ) - { - PCPATCH_LAZPERF *pal = pc_patch_lazperf_from_uncompressed((PCPATCH_UNCOMPRESSED*)patch); - return (PCPATCH*)pal; - } - else - { - pcerror("%s: unknown patch compression type %d", __func__, patch_compression); - } - } case PC_LAZPERF: { if ( patch_compression == PC_NONE ) @@ -246,13 +188,6 @@ pc_patch_compress(const PCPATCH *patch, void *userdata) pc_patch_uncompressed_free( pad ); return (PCPATCH*)pal; } - else if ( patch_compression == PC_GHT ) - { - PCPATCH_UNCOMPRESSED *pcu = pc_patch_uncompressed_from_ght((PCPATCH_GHT*)patch); - PCPATCH_LAZPERF *pal = pc_patch_lazperf_from_uncompressed((PCPATCH_UNCOMPRESSED*)pcu); - pc_patch_uncompressed_free(pcu); - return (PCPATCH*)pal; - } else if ( patch_compression == PC_LAZPERF ) { return (PCPATCH*)patch; @@ -289,12 +224,6 @@ pc_patch_uncompress(const PCPATCH *patch) return (PCPATCH*)patch; } - if ( patch_compression == PC_GHT ) - { - PCPATCH_UNCOMPRESSED *pu = pc_patch_uncompressed_from_ght((PCPATCH_GHT*)patch); - return (PCPATCH*)pu; - } - if ( patch_compression == PC_LAZPERF ) { PCPATCH_UNCOMPRESSED *pu = pc_patch_uncompressed_from_lazperf( (PCPATCH_LAZPERF*)patch ); @@ -312,7 +241,7 @@ pc_patch_from_wkb(const PCSCHEMA *s, uint8_t *wkb, size_t wkbsize) /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uchar[]: data (interpret relative to pcid and compression) */ uint32_t compression, pcid; @@ -348,11 +277,6 @@ pc_patch_from_wkb(const PCSCHEMA *s, uint8_t *wkb, size_t wkbsize) patch = pc_patch_dimensional_from_wkb(s, wkb, wkbsize); break; } - case PC_GHT: - { - patch = pc_patch_ght_from_wkb(s, wkb, wkbsize); - break; - } case PC_LAZPERF: { patch = pc_patch_lazperf_from_wkb(s, wkb, wkbsize); @@ -384,7 +308,7 @@ pc_patch_to_wkb(const PCPATCH *patch, size_t *wkbsize) /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uchar[]: data (interpret relative to pcid and compression) */ switch ( patch->type ) @@ -397,10 +321,6 @@ pc_patch_to_wkb(const PCPATCH *patch, size_t *wkbsize) { return pc_patch_dimensional_to_wkb((PCPATCH_DIMENSIONAL*)patch, wkbsize); } - case PC_GHT: - { - return pc_patch_ght_to_wkb((PCPATCH_GHT*)patch, wkbsize); - } case PC_LAZPERF: { return pc_patch_lazperf_to_wkb((PCPATCH_LAZPERF*)patch, wkbsize); @@ -419,8 +339,6 @@ pc_patch_to_string(const PCPATCH *patch) return pc_patch_uncompressed_to_string((PCPATCH_UNCOMPRESSED*)patch); case PC_DIMENSIONAL: return pc_patch_dimensional_to_string((PCPATCH_DIMENSIONAL*)patch); - case PC_GHT: - return pc_patch_ght_to_string((PCPATCH_GHT*)patch); case PC_LAZPERF: return pc_patch_lazperf_to_string( (PCPATCH_LAZPERF*)patch ); } @@ -481,15 +399,6 @@ pc_patch_from_patchlist(PCPATCH **palist, int numpatches) pc_patch_free((PCPATCH*)pu); break; } - case PC_GHT: - { - PCPATCH_UNCOMPRESSED *pu = pc_patch_uncompressed_from_ght((const PCPATCH_GHT*)pa); - size_t sz = pu->schema->size * pu->npoints; - memcpy(buf, pu->data, sz); - buf += sz; - pc_patch_uncompressed_free(pu); - break; - } case PC_NONE: { PCPATCH_UNCOMPRESSED *pu = (PCPATCH_UNCOMPRESSED*)pa; @@ -604,8 +513,6 @@ PCPOINT *pc_patch_pointn(const PCPATCH *patch, int n) return pc_patch_uncompressed_pointn((PCPATCH_UNCOMPRESSED*)patch,n); case PC_DIMENSIONAL: return pc_patch_dimensional_pointn((PCPATCH_DIMENSIONAL*)patch,n); - case PC_GHT: - return pc_patch_ght_pointn((PCPATCH_GHT*)patch,n); case PC_LAZPERF: return pc_patch_lazperf_pointn((PCPATCH_LAZPERF*)patch, n); } diff --git a/lib/pc_patch_dimensional.c b/lib/pc_patch_dimensional.c index 786dbb0..c7da154 100644 --- a/lib/pc_patch_dimensional.c +++ b/lib/pc_patch_dimensional.c @@ -218,7 +218,7 @@ pc_patch_dimensional_to_wkb(const PCPATCH_DIMENSIONAL *patch, size_t *wkbsize) /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uint32: npoints dimensions[]: pcbytes (interpret relative to pcid and compressions) */ @@ -259,7 +259,7 @@ pc_patch_dimensional_from_wkb(const PCSCHEMA *schema, const uint8_t *wkb, size_t /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uint32: npoints dimensions[]: dims (interpret relative to pcid and compressions) */ diff --git a/lib/pc_patch_ght.c b/lib/pc_patch_ght.c deleted file mode 100644 index 5970aec..0000000 --- a/lib/pc_patch_ght.c +++ /dev/null @@ -1,599 +0,0 @@ -/*********************************************************************** -* pc_patch_dght.c -* -* GHT compressed patch handling. Create, get and set values from the -* geohashtree (ght) ordered PCPATCH structure. -* -* PgSQL Pointcloud is free and open source software provided -* by the Government of Canada -* Copyright (c) 2013 Natural Resources Canada -* -***********************************************************************/ - -#include -#include -#include "pc_api_internal.h" - - -/* Includes and functions that expect GHT headers and definitions */ - -#ifdef HAVE_LIBGHT -static GhtType -ght_type_from_pc_type(const int pctype) -{ - switch(pctype) - { - case PC_UNKNOWN: - return GHT_UNKNOWN; - case PC_INT8: - return GHT_INT8; - case PC_UINT8: - return GHT_UINT8; - case PC_INT16: - return GHT_INT16; - case PC_UINT16: - return GHT_UINT16; - case PC_INT32: - return GHT_INT32; - case PC_UINT32: - return GHT_UINT32; - case PC_INT64: - return GHT_INT64; - case PC_UINT64: - return GHT_UINT64; - case PC_DOUBLE: - return GHT_DOUBLE; - case PC_FLOAT: - return GHT_FLOAT; - } - - return GHT_UNKNOWN; -} - -static GhtDimensionPtr -ght_dimension_from_pc_dimension(const PCDIMENSION *d) -{ - GhtDimensionPtr dim; - GhtType type = ght_type_from_pc_type(d->interpretation); - ght_dimension_new_from_parameters(d->name, d->description, type, d->scale, d->offset, &dim); - return dim; -} - - -static GhtSchemaPtr -ght_schema_from_pc_schema(const PCSCHEMA *pcschema) -{ - int i; - GhtSchemaPtr schema; - - ght_schema_new(&schema); - - for ( i = 0; i < pcschema->ndims; i++ ) - { - GhtDimensionPtr dim = ght_dimension_from_pc_dimension(pcschema->dims[i]); - ght_schema_add_dimension(schema, dim); - } - - return schema; -} - -static GhtTreePtr -ght_tree_from_pc_patch(const PCPATCH_GHT *paght) -{ - GhtTreePtr tree; - GhtReaderPtr reader; - GhtSchemaPtr ghtschema; - - ghtschema = ght_schema_from_pc_schema(paght->schema); - if ( ! ghtschema ) - return NULL; - - if ( GHT_OK != ght_reader_new_mem(paght->ght, paght->ghtsize, ghtschema, &reader) ) - return NULL; - - if ( GHT_OK != ght_tree_read(reader, &tree) ) - return NULL; - - return tree; -} -#endif /* HAVE_LIBGHT */ - -PCPATCH_GHT * -pc_patch_ght_from_pointlist(const PCPOINTLIST *pdl) -{ - PCPATCH_UNCOMPRESSED *patch = pc_patch_uncompressed_from_pointlist(pdl); - PCPATCH_GHT *ghtpatch = pc_patch_ght_from_uncompressed(patch); - pc_patch_uncompressed_free(patch); - return ghtpatch; -} - -PCPATCH_GHT * -pc_patch_ght_from_uncompressed(const PCPATCH_UNCOMPRESSED *pa) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return NULL; -#else - - int i, j; - int pointcount = 0; - GhtSchemaPtr schema; - GhtTreePtr tree; - GhtCoordinate coord; - GhtNodePtr node; - PCPOINT pt; - PCDIMENSION *xdim, *ydim; - PCPATCH_GHT *paght = NULL; - size_t pt_size = pa->schema->size; - - /* Cannot handle empty patches */ - if ( ! pa || ! pa->npoints ) return NULL; - - pt.schema = pa->schema; - pt.readonly = PC_TRUE; - - xdim = pa->schema->xdim; - ydim = pa->schema->ydim; - - schema = ght_schema_from_pc_schema(pa->schema); - if ( ght_tree_new(schema, &tree) != GHT_OK ) { - pcerror("ght_tree_new failed"); - return NULL; - } - - /* Build up the tree from the points. */ - for ( i = 0; i < pa->npoints; i++ ) - { - pt.data = pa->data + pt_size * i; - pc_point_get_double(&pt, xdim, &(coord.x)); - pc_point_get_double(&pt, ydim, &(coord.y)); - - /* Build a node from the x/y information */ - /* TODO, make resolution configurable from the schema */ - if ( ght_node_new_from_coordinate(&coord, GHT_MAX_HASH_LENGTH, &node) == GHT_OK ) - { - unsigned int num_dims; - ght_schema_get_num_dimensions(schema, &num_dims); - /* Add attributes to the node */ - for ( j = 0; j < num_dims; j++ ) - { - PCDIMENSION *dim; - GhtDimensionPtr ghtdim; - GhtAttributePtr attr; - double val; - - dim = pc_schema_get_dimension(pa->schema, j); - - /* Don't add X or Y as attributes, they are already embodied in the hash */ - if ( dim == pa->schema->xdim || dim == pa->schema->ydim ) - continue; - - pc_point_get_double(&pt, dim, &val); - - ght_schema_get_dimension_by_index(schema, j, &ghtdim); - ght_attribute_new_from_double(ghtdim, val, &attr); - ght_node_add_attribute(node, attr); - } - - /* Add the node to the tree */ - /* TODO, make duplicate handling configurable from the schema */ - if ( ght_tree_insert_node(tree, node) == GHT_OK ) - { - pointcount++; - } - else - { - // ght_tree_free(tree); - pcerror("ght_tree_insert_node failed"); - return NULL; - } - } - else - { - ght_tree_free(tree); - pcerror("ght_node_new_from_coordinate failed"); - return NULL; - } - } - - /* Compact the tree */ - if ( ght_tree_compact_attributes(tree) == GHT_OK ) - { - GhtWriterPtr writer; - paght = pcalloc(sizeof(PCPATCH_GHT)); - paght->type = PC_GHT; - paght->readonly = PC_FALSE; - paght->schema = pa->schema; - paght->npoints = pointcount; - paght->bounds = pa->bounds; - paght->stats = pc_stats_clone(pa->stats); - - /* Convert the tree to a memory buffer */ - ght_writer_new_mem(&writer); - ght_tree_write(tree, writer); - ght_writer_get_size(writer, &(paght->ghtsize)); - paght->ght = pcalloc(paght->ghtsize); - ght_writer_get_bytes(writer, paght->ght); - ght_writer_free(writer); - } - - // Let the hierarchical memory manager clean up the tree - // ght_tree_free(tree); - return paght; -#endif -} - -void -pc_patch_ght_free(PCPATCH_GHT *paght) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return; -#else - assert(paght); - assert(paght->schema); - - pc_patch_free_stats((PCPATCH*) paght); - - /* A readonly tree won't own it's ght buffer, */ - /* so only free a readwrite tree */ - if ( ! paght->readonly ) - { - if ( paght->ght ) - pcfree(paght->ght); - } - - pcfree(paght); -#endif -} - - - -PCPATCH_UNCOMPRESSED * -pc_patch_uncompressed_from_ght(const PCPATCH_GHT *paght) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return NULL; -#else - int i, npoints; - PCPATCH_UNCOMPRESSED *patch; - PCPOINT point; - const PCSCHEMA *schema; - GhtNodeListPtr nodelist; - GhtCoordinate coord; - GhtNodePtr node; - GhtTreePtr tree; - GhtAttributePtr attr; - - /* Build a structured tree from the tree serialization */ - if ( ! paght || ! paght->ght ) return NULL; - tree = ght_tree_from_pc_patch(paght); - if ( ! tree ) return NULL; - - /* Convert tree to nodelist */ - ght_nodelist_new(paght->npoints, &nodelist); - ght_tree_to_nodelist(tree, nodelist); - - /* Allocate uncompressed patch */ - ght_nodelist_get_num_nodes(nodelist, &npoints); - schema = paght->schema; - patch = pcalloc(sizeof(PCPATCH_UNCOMPRESSED)); - patch->type = PC_NONE; - patch->readonly = PC_FALSE; - patch->schema = schema; - patch->npoints = npoints; - patch->bounds = paght->bounds; - patch->stats = pc_stats_clone(paght->stats); - patch->maxpoints = npoints; - patch->datasize = schema->size * npoints; - patch->data = pcalloc(patch->datasize); - - /* Set up utility point */ - point.schema = schema; - point.readonly = PC_FALSE; - point.data = patch->data; - - /* Process each point... */ - for ( i = 0; i < npoints; i++ ) - { - double val; - - /* Read and set X and Y */ - ght_nodelist_get_node(nodelist, i, &node); - ght_node_get_coordinate(node, &coord); - pc_point_set_x(&point, coord.x); - pc_point_set_y(&point, coord.y); - - /* Read and set all the attributes */ - ght_node_get_attributes(node, &attr); - while ( attr ) - { - GhtDimensionPtr dim; - const char *name; - ght_attribute_get_value(attr, &val); - ght_attribute_get_dimension(attr, &dim); - ght_dimension_get_name(dim, &name); - pc_point_set_double_by_name(&point, name, val); - ght_attribute_get_next(attr, &attr); - } - point.data += schema->size; - } - - /* Done w/ nodelist and tree */ - ght_nodelist_free_deep(nodelist); - // ght_tree_free(tree); - - /* Done */ - return patch; -#endif -} - - -PCPATCH * -pc_patch_ght_from_wkb(const PCSCHEMA *schema, const uint8_t *wkb, size_t wkbsize) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return NULL; -#else - /* - byte: endianness (1 = NDR, 0 = XDR) - uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) - uint32: npoints - uint32: ghtsize - uint8[]: ghtbuffer - */ - static size_t hdrsz = 1+4+4+4; /* endian + pcid + compression + npoints */ - PCPATCH_GHT *patch; - uint8_t swap_endian = (wkb[0] != machine_endian()); - uint32_t npoints; - size_t ghtsize; - const uint8_t *buf; - - if ( wkb_get_compression(wkb) != PC_GHT ) - { - pcerror("%s: call with wkb that is not GHT compressed", __func__); - return NULL; - } - - npoints = wkb_get_npoints(wkb); - - patch = pcalloc(sizeof(PCPATCH_GHT)); - patch->type = PC_GHT; - patch->readonly = PC_FALSE; - patch->schema = schema; - patch->npoints = npoints; - patch->stats = NULL; - - /* Start on the GHT */ - buf = wkb+hdrsz; - ghtsize = wkb_get_int32(buf, swap_endian); - buf += 4; /* Move to start of GHT buffer */ - - /* Copy in the tree buffer */ - patch->ght = pcalloc(ghtsize); - patch->ghtsize = ghtsize; - memcpy(patch->ght, buf, ghtsize); - - return (PCPATCH*)patch; -#endif -} - - -int -pc_patch_ght_compute_extent(PCPATCH_GHT *patch) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return PC_FAILURE; -#else - - GhtTreePtr tree; - GhtArea area; - - /* Get a tree */ - tree = ght_tree_from_pc_patch(patch); - if ( ! tree ) return PC_FAILURE; - - /* Calculate bounds and save */ - if ( GHT_OK != ght_tree_get_extent(tree, &area) ) - return PC_FAILURE; - - patch->bounds.xmin = area.x.min; - patch->bounds.xmax = area.x.max; - patch->bounds.ymin = area.y.min; - patch->bounds.ymax = area.y.max; - - // ght_tree_free(tree); - - return PC_SUCCESS; -#endif -} - -char * -pc_patch_ght_to_string(const PCPATCH_GHT *pa) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return NULL; -#else - PCPATCH_UNCOMPRESSED *patch = pc_patch_uncompressed_from_ght(pa); - char *str = pc_patch_uncompressed_to_string(patch); - pc_patch_uncompressed_free(patch); - return str; -#endif -} - -uint8_t * -pc_patch_ght_to_wkb(const PCPATCH_GHT *patch, size_t *wkbsize) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return NULL; -#else - /* - byte: endianness (1 = NDR, 0 = XDR) - uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) - uint32: npoints - uint32: ghtsize - uint8[]: ghtbuffer - */ - - uint8_t *buf; - char endian = machine_endian(); - /* endian + pcid + compression + npoints + ghtsize + ght */ - size_t size = 1 + 4 + 4 + 4 + 4 + patch->ghtsize; - - uint8_t *wkb = pcalloc(size); - uint32_t compression = patch->type; - uint32_t npoints = patch->npoints; - uint32_t pcid = patch->schema->pcid; - uint32_t ghtsize = patch->ghtsize; - wkb[0] = endian; /* Write endian flag */ - memcpy(wkb + 1, &pcid, 4); /* Write PCID */ - memcpy(wkb + 5, &compression, 4); /* Write compression */ - memcpy(wkb + 9, &npoints, 4); /* Write npoints */ - memcpy(wkb + 13, &ghtsize, 4); /* Write ght buffer size */ - - buf = wkb + 17; - memcpy(buf, patch->ght, patch->ghtsize); - if ( wkbsize ) *wkbsize = size; - return wkb; -#endif -} - -PCPATCH_GHT * -pc_patch_ght_filter(const PCPATCH_GHT *patch, uint32_t dimnum, PC_FILTERTYPE filter, double val1, double val2) -{ -#ifndef HAVE_LIBGHT - pcerror("%s: libght support is not enabled", __func__); - return NULL; -#else - /* - byte: endianness (1 = NDR, 0 = XDR) - uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) - uint32: npoints - uint32: ghtsize - uint8[]: ghtbuffer - */ - - GhtTreePtr tree; - GhtTreePtr tree_filtered; - GhtErr err; - GhtWriterPtr writer; - GhtArea area; - const char *dimname; - const PCDIMENSION *dim; - PCPATCH_GHT *paght; - int npoints; - - /* Echo null back */ - if ( ! patch ) return NULL; - - /* Get a tree */ - tree = ght_tree_from_pc_patch(patch); - if ( ! tree ) pcerror("%s: call to ght_tree_from_pc_patch failed", __func__); - - /* Get dimname */ - dim = pc_schema_get_dimension(patch->schema, dimnum); - if ( ! dim ) pcerror("%s: invalid dimension number (%d)", __func__, dimnum); - dimname = dim->name; - - switch ( filter ) - { - case PC_GT: - err = ght_tree_filter_greater_than(tree, dimname, val1 > val2 ? val1 : val2, &tree_filtered); - break; - case PC_LT: - err = ght_tree_filter_less_than(tree, dimname, val1 < val2 ? val1 : val2, &tree_filtered); - break; - case PC_EQUAL: - err = ght_tree_filter_equal(tree, dimname, val1, &tree_filtered); - break; - case PC_BETWEEN: - err = ght_tree_filter_between(tree, dimname, val1, val2, &tree_filtered); - break; - default: - pcerror("%s: invalid filter type (%d)", __func__, filter); - return NULL; - } - - /* ght_tree_filter_* returns a tree with NULL tree element and npoints == 0 */ - /* for empty filter results (everything got filtered away) */ - if ( err != GHT_OK || ! tree_filtered ) - pcerror("%s: ght_tree_filter failed", __func__); - - /* Read numpoints left in patch */ - ght_tree_get_numpoints(tree_filtered, &(npoints)); - - /* Allocate a fresh GHT patch for output */ - paght = pcalloc(sizeof(PCPATCH_GHT)); - paght->type = PC_GHT; - paght->readonly = PC_FALSE; - paght->schema = patch->schema; - paght->npoints = npoints; - paght->stats = NULL; - - /* No points, not much to do... */ - if ( ! npoints ) - { - paght->ghtsize = 0; - paght->ght = NULL; - } - else - { - /* Calculate bounds and save */ - if ( GHT_OK != ght_tree_get_extent(tree_filtered, &area) ) - pcerror("%s: ght_tree_get_extent failed", __func__); - - paght->bounds.xmin = area.x.min; - paght->bounds.xmax = area.x.max; - paght->bounds.ymin = area.y.min; - paght->bounds.ymax = area.y.max; - - /* TODO: Replace this; need to update stats too */ - paght->stats = pc_stats_clone(patch->stats); - - /* Convert the tree to a memory buffer */ - ght_writer_new_mem(&writer); - ght_tree_write(tree_filtered, writer); - ght_writer_get_size(writer, &(paght->ghtsize)); - paght->ght = pcalloc(paght->ghtsize); - ght_writer_get_bytes(writer, paght->ght); - ght_writer_free(writer); - } - - // ght_tree_free(tree_filtered); - // ght_tree_free(tree); - - return paght; - -#endif -} - - -PCPOINTLIST * -pc_pointlist_from_ght(const PCPATCH_GHT *pag) -{ - PCPATCH_UNCOMPRESSED *pu; - pu = pc_patch_uncompressed_from_ght(pag); - PCPOINTLIST *pl = pc_pointlist_from_uncompressed(pu); - pl->mem = pc_patch_uncompressed_readonly(pu); - pc_patch_free((PCPATCH *)pu); - return pl; -} - - -PCPOINT * -pc_patch_ght_pointn(const PCPATCH_GHT *patch, int n) -{ - PCPATCH_UNCOMPRESSED *pu; - pu = pc_patch_uncompressed_from_ght(patch); - PCPOINT *pt = pc_patch_uncompressed_pointn(pu,n); - pc_patch_free((PCPATCH *)pu); - return pt; -} diff --git a/lib/pc_patch_lazperf.c b/lib/pc_patch_lazperf.c index 20e79d2..c40a352 100644 --- a/lib/pc_patch_lazperf.c +++ b/lib/pc_patch_lazperf.c @@ -186,7 +186,7 @@ pc_patch_lazperf_from_wkb(const PCSCHEMA *schema, const uint8_t *wkb, size_t wkb /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uint32: npoints uint32: lazperfsize uint8[]: lazerperfbuffer diff --git a/lib/pc_patch_uncompressed.c b/lib/pc_patch_uncompressed.c index 0d21fd9..fe691bd 100644 --- a/lib/pc_patch_uncompressed.c +++ b/lib/pc_patch_uncompressed.c @@ -73,7 +73,7 @@ pc_patch_uncompressed_to_wkb(const PCPATCH_UNCOMPRESSED *patch, size_t *wkbsize) /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uint32: npoints uchar[]: data (interpret relative to pcid) */ @@ -100,7 +100,7 @@ pc_patch_uncompressed_from_wkb(const PCSCHEMA *s, const uint8_t *wkb, size_t wkb /* byte: endianness (1 = NDR, 0 = XDR) uint32: pcid (key to POINTCLOUD_SCHEMAS) - uint32: compression (0 = no compression, 1 = dimensional, 2 = GHT) + uint32: compression (0 = no compression, 1 = dimensional, 2 = lazperf) uint32: npoints pcpoint[]: data (interpret relative to pcid) */ diff --git a/lib/pc_pointlist.c b/lib/pc_pointlist.c index fe8dd9b..6d87a45 100644 --- a/lib/pc_pointlist.c +++ b/lib/pc_pointlist.c @@ -121,10 +121,6 @@ pc_pointlist_from_patch(const PCPATCH *patch) { return pc_pointlist_from_uncompressed((PCPATCH_UNCOMPRESSED*)patch); } - case PC_GHT: - { - return pc_pointlist_from_ght((PCPATCH_GHT*)patch); - } case PC_DIMENSIONAL: { return pc_pointlist_from_dimensional((PCPATCH_DIMENSIONAL*)patch); diff --git a/lib/pc_schema.c b/lib/pc_schema.c index 9f38cb8..c6f73bb 100644 --- a/lib/pc_schema.c +++ b/lib/pc_schema.c @@ -96,8 +96,6 @@ pc_compression_name(int num) { case PC_NONE: return "none"; - case PC_GHT: - return "ght"; case PC_DIMENSIONAL: return "dimensional"; case PC_LAZPERF: @@ -125,12 +123,6 @@ pc_compression_number(const char *str) return PC_LAZPERF; } - if ( (str[0] == 'g' || str[0] == 'G') && - (strcasecmp(str, "ght") == 0) ) - { - return PC_GHT; - } - if ( (str[0] == 'n' || str[0] == 'N') && (strcasecmp(str, "none") == 0) ) { diff --git a/lib/pc_sort.c b/lib/pc_sort.c index efae7c1..7317e54 100644 --- a/lib/pc_sort.c +++ b/lib/pc_sort.c @@ -224,19 +224,6 @@ pc_patch_dimensional_is_sorted(const PCPATCH_DIMENSIONAL *pdl, PCDIMENSION_LIST } -uint32_t -pc_patch_ght_is_sorted(const PCPATCH_GHT *pa, PCDIMENSION_LIST dim, char strict) -{ - PCPATCH_UNCOMPRESSED *pu = pc_patch_uncompressed_from_ght(pa); - if ( !pu ) { - pcerror("Patch uncompression failed"); - return PC_FAILURE - 1; // aliasing issue : PC_FALSE == PC_FAILURE... - } - uint32_t is_sorted = pc_patch_uncompressed_is_sorted(pu,dim,strict); - pc_patch_free((PCPATCH*)pu); - return is_sorted; -} - uint32_t pc_patch_lazperf_is_sorted(const PCPATCH_LAZPERF *pa, PCDIMENSION_LIST dim, char strict) { @@ -266,9 +253,6 @@ pc_patch_is_sorted(const PCPATCH *pa, const char **name, int ndims, char strict) case PC_DIMENSIONAL: is_sorted = pc_patch_dimensional_is_sorted((PCPATCH_DIMENSIONAL*)pa,dim,strict); break; - case PC_GHT: - is_sorted = pc_patch_ght_is_sorted((PCPATCH_GHT*)pa,dim,strict); - break; case PC_LAZPERF: is_sorted = pc_patch_lazperf_is_sorted((PCPATCH_LAZPERF*)pa,dim,strict); break; diff --git a/pgsql/Makefile b/pgsql/Makefile index 24e809b..3d333e7 100644 --- a/pgsql/Makefile +++ b/pgsql/Makefile @@ -30,17 +30,13 @@ DATA_built = \ REGRESS = pointcloud pointcloud_columns schema -ifneq ($(GHT_LDFLAGS),) -REGRESS += pointcloud-ght -endif - ifneq ($(LAZPERF_STATUS), "disabled") REGRESS += pointcloud-laz endif # Add in build/link flags for lib -PG_CPPFLAGS += -I../lib $(GHT_CPPFLAGS) -SHLIB_LINK += ../lib/$(LIB_A) ../lib/$(LIB_A_LAZPERF) -lstdc++ $(filter -lm, $(LIBS)) $(XML2_LDFLAGS) $(ZLIB_LDFLAGS) $(GHT_LDFLAGS) +PG_CPPFLAGS += -I../lib +SHLIB_LINK += ../lib/$(LIB_A) ../lib/$(LIB_A_LAZPERF) -lstdc++ $(filter -lm, $(LIBS)) $(XML2_LDFLAGS) $(ZLIB_LDFLAGS) # We are going to use PGXS for sure include $(PGXS) diff --git a/pgsql/expected/pointcloud-ght.out b/pgsql/expected/pointcloud-ght.out deleted file mode 100644 index 06ea485..0000000 --- a/pgsql/expected/pointcloud-ght.out +++ /dev/null @@ -1,122 +0,0 @@ -INSERT INTO pointcloud_formats (pcid, srid, schema) -VALUES (5, 0, -' - - - 1 - 4 - X coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. - X - int32_t - 0.01 - - - 2 - 4 - Y coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. - Y - int32_t - 0.01 - - - 3 - 4 - Z coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. - Z - int32_t - 0.01 - - - 4 - 2 - The intensity value is the integer representation of the pulse return magnitude. This value is optional and system specific. However, it should always be included if available. - Intensity - uint16_t - 1 - - - ght - 4326 - -' -); -CREATE TABLE IF NOT EXISTS pa_test_ght ( - pa PCPATCH(5) -); -\d pa_test_ght - Table "public.pa_test_ght" - Column | Type | Modifiers ---------+------------+----------- - pa | pcpatch(5) | - -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; - sum ------ - 8 -(1 row) - -SELECT Sum(PC_MemSize(pa)) FROM pa_test_ght; - sum ------ - 582 -(1 row) - -SELECT Sum(PC_PatchMax(pa,'x')) FROM pa_test_ght; - sum ------- - 0.15 -(1 row) - -SELECT Sum(PC_PatchMin(pa,'x')) FROM pa_test_ght; - sum ------- - 0.12 -(1 row) - -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; - sum ------- - 1600 -(1 row) - -SELECT Sum(PC_MemSize(pa)) FROM pa_test_ght; - sum -------- - 38681 -(1 row) - -SELECT Max(PC_PatchMax(pa,'x')) FROM pa_test_ght; - max ------- - -111 -(1 row) - -SELECT Min(PC_PatchMin(pa,'x')) FROM pa_test_ght; - min ---------- - -126.99 -(1 row) - -SELECT Min(PC_PatchMin(pa,'z')) FROM pa_test_ght; - min ------ - 1 -(1 row) - -TRUNCATE pointcloud_formats; diff --git a/pgsql/expected/pointcloud.out b/pgsql/expected/pointcloud.out index 79df7a7..a143295 100644 --- a/pgsql/expected/pointcloud.out +++ b/pgsql/expected/pointcloud.out @@ -44,12 +44,6 @@ VALUES (1, 0, -- XYZI, scaled, uncompressed none - - - - - - 4326 ' @@ -140,12 +134,6 @@ VALUES (1, 0, -- XYZI, scaled, uncompressed none - - - - - - 4326 ' @@ -545,7 +533,6 @@ FROM p1, ( values ('dimensional','sigbits'), ('dimensional','auto'), ('laz','null') - -- ,('ght',null) -- fails due to https://github.com/pgpointcloud/pointcloud/issues/35 ) dimcompr(compr,sc) ORDER BY compr,sc,v; test | v | compr | sc | ok diff --git a/pgsql/pc_access.c b/pgsql/pc_access.c index fda1d03..62599f2 100644 --- a/pgsql/pc_access.c +++ b/pgsql/pc_access.c @@ -44,7 +44,6 @@ Datum pcpoint_pcid(PG_FUNCTION_ARGS); Datum pc_version(PG_FUNCTION_ARGS); Datum pc_pgsql_version(PG_FUNCTION_ARGS); Datum pc_libxml2_version(PG_FUNCTION_ARGS); -Datum pc_libght_enabled(PG_FUNCTION_ARGS); Datum pc_lazperf_enabled(PG_FUNCTION_ARGS); /* Generic aggregation functions */ @@ -690,14 +689,11 @@ Datum pcpatch_compress(PG_FUNCTION_ARGS) pa = (PCPATCH*)pc_patch_dimensional_compress(pdl, stats); pc_patch_dimensional_free(pdl); }} - else if ( strcmp(compr_in, "ght") == 0 ) { - schema->compression = PC_GHT; - } else if ( strcmp(compr_in, "laz") == 0 ) { schema->compression = PC_LAZPERF; } else { - elog(ERROR, "Unrecognized compression '%s'. Please specify 'auto','dimensional' or 'ght'", compr_in); + elog(ERROR, "Unrecognized compression '%s'. Please specify 'auto','dimensional' or 'laz'", compr_in); } pa->schema = schema; /* install overridden schema */ @@ -939,16 +935,6 @@ Datum pc_libxml2_version(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(version_text); } -PG_FUNCTION_INFO_V1(pc_libght_enabled); -Datum pc_libght_enabled(PG_FUNCTION_ARGS) -{ -#ifdef HAVE_LIBGHT - PG_RETURN_BOOL(TRUE); -#else - PG_RETURN_BOOL(FALSE); -#endif -} - PG_FUNCTION_INFO_V1(pc_lazperf_enabled); Datum pc_lazperf_enabled(PG_FUNCTION_ARGS) { diff --git a/pgsql/pc_pgsql.c b/pgsql/pc_pgsql.c index 4e14c28..c7b7057 100644 --- a/pgsql/pc_pgsql.c +++ b/pgsql/pc_pgsql.c @@ -429,12 +429,6 @@ pc_patch_serialized_size(const PCPATCH *patch) PCPATCH_UNCOMPRESSED *pu = (PCPATCH_UNCOMPRESSED*)patch; return common_size + stats_size + pu->datasize; } - case PC_GHT: - { - static size_t ghtsize_size = 4; - PCPATCH_GHT *pg = (PCPATCH_GHT*)patch; - return common_size + stats_size + ghtsize_size + pg->ghtsize; - } case PC_DIMENSIONAL: { return common_size + stats_size + pc_patch_dimensional_serialized_size((PCPATCH_DIMENSIONAL*)patch); @@ -537,54 +531,6 @@ pc_patch_dimensional_serialize(const PCPATCH *patch_in) } -static SERIALIZED_PATCH * -pc_patch_ght_serialize(const PCPATCH *patch_in) -{ - // uint32_t size; - // uint32_t pcid; - // uint32_t compression; - // uint32_t npoints; - // double xmin, xmax, ymin, ymax; - // data: - // pcpoint[3] stats; - // uint32_t ghtsize; - // uint8_t ght[]; - - size_t serpch_size = pc_patch_serialized_size(patch_in); - SERIALIZED_PATCH *serpch = pcalloc(serpch_size); - const PCPATCH_GHT *patch = (PCPATCH_GHT*)patch_in; - uint32_t ghtsize = patch->ghtsize; - uint8_t *buf = serpch->data; - - assert(patch); - assert(patch->type == PC_GHT); - - /* Copy basics */ - serpch->pcid = patch->schema->pcid; - serpch->npoints = patch->npoints; - serpch->bounds = patch->bounds; - serpch->compression = patch->type; - - /* Write stats into the buffer first */ - if ( patch->stats ) - { - buf += pc_patch_stats_serialize(buf, patch->schema, patch->stats); - } - else - { - pcerror("%s: stats missing!", __func__); - } - - /* Write tree buffer size */ - memcpy(buf, &(ghtsize), 4); - buf += 4; - - /* Write tree buffer */ - memcpy(buf, patch->ght, patch->ghtsize); - SET_VARSIZE(serpch, serpch_size); - return serpch; -} - static SERIALIZED_PATCH * pc_patch_lazperf_serialize(const PCPATCH *patch_in) { @@ -706,11 +652,6 @@ pc_patch_serialize(const PCPATCH *patch_in, void *userdata) serpatch = pc_patch_dimensional_serialize(patch); break; } - case PC_GHT: - { - serpatch = pc_patch_ght_serialize(patch); - break; - } case PC_LAZPERF: { serpatch = pc_patch_lazperf_serialize(patch); @@ -858,51 +799,6 @@ pc_patch_dimensional_deserialize(const SERIALIZED_PATCH *serpatch, const PCSCHEM * set up pointers to the start of the buffer, so we can build it out later * if necessary. */ -static PCPATCH * -pc_patch_ght_deserialize(const SERIALIZED_PATCH *serpatch, const PCSCHEMA *schema) -{ - // typedef struct - // { - // uint32_t size; - // uint32_t pcid; - // uint32_t compression; - // uint32_t npoints; - // double xmin, xmax, ymin, ymax; - // data: - // pcpoint[3] pcstats(min, max, avg) - // uint32_t ghtsize; - // uint8_t ght[]; - // } - // SERIALIZED_PATCH; - - PCPATCH_GHT *patch; - uint32_t ghtsize; - int npoints = serpatch->npoints; - size_t stats_size = pc_stats_size(schema); // 3 pcpoints worth of stats - uint8_t *buf = (uint8_t*)serpatch->data + stats_size; - - /* Reference the external data */ - patch = pcalloc(sizeof(PCPATCH_GHT)); - - /* Set up basic info */ - patch->type = serpatch->compression; - patch->schema = schema; - patch->readonly = true; - patch->npoints = npoints; - patch->bounds = serpatch->bounds; - - /* Point into the stats area */ - patch->stats = pc_patch_stats_deserialize(schema, serpatch->data); - - /* Set up ght buffer */ - memcpy(&ghtsize, buf, 4); - patch->ghtsize = ghtsize; - patch->ght = buf + 4; - - /* That's it */ - return (PCPATCH*)patch; -} - static PCPATCH * pc_patch_lazperf_deserialize(const SERIALIZED_PATCH *serpatch, const PCSCHEMA *schema) { @@ -945,8 +841,6 @@ pc_patch_deserialize(const SERIALIZED_PATCH *serpatch, const PCSCHEMA *schema) return pc_patch_uncompressed_deserialize(serpatch, schema); case PC_DIMENSIONAL: return pc_patch_dimensional_deserialize(serpatch, schema); - case PC_GHT: - return pc_patch_ght_deserialize(serpatch, schema); case PC_LAZPERF: return pc_patch_lazperf_deserialize(serpatch, schema); } diff --git a/pgsql/pointcloud.sql.in b/pgsql/pointcloud.sql.in index bed0cd7..0ee7b10 100644 --- a/pgsql/pointcloud.sql.in +++ b/pgsql/pointcloud.sql.in @@ -66,11 +66,6 @@ CREATE OR REPLACE FUNCTION pc_libxml2_version() RETURNS text AS 'MODULE_PATHNAME', 'pc_libxml2_version' LANGUAGE 'c' IMMUTABLE STRICT; --- Return whether libght is enabled -CREATE OR REPLACE FUNCTION pc_libght_enabled() - RETURNS boolean AS 'MODULE_PATHNAME', 'pc_libght_enabled' - LANGUAGE 'c' IMMUTABLE STRICT; - -- Return whether lazperf is enabled CREATE OR REPLACE FUNCTION pc_lazperf_enabled() RETURNS boolean AS 'MODULE_PATHNAME', 'pc_lazperf_enabled' @@ -120,7 +115,6 @@ DECLARE pcscrver TEXT; pgsqlver TEXT; libxml2ver TEXT; - libghtenabled BOOLEAN; lazperfenabled BOOLEAN; BEGIN pclibver := pc_lib_version(); @@ -128,10 +122,9 @@ BEGIN pcver := _pc_version_no_commit(pclibver, pcscrver); pgsqlver := pc_pgsql_version(); libxml2ver := pc_libxml2_version(); - libghtenabled := pc_libght_enabled(); lazperfenabled := pc_lazperf_enabled(); RETURN 'POINTCLOUD="' || pclibver || '" PGSQL="' || pgsqlver || '" LIBXML2="' || libxml2ver || - '" LIBGHT enabled=' || libghtenabled || ' LAZPERF enabled=' || lazperfenabled; + ' LAZPERF enabled=' || lazperfenabled; END; $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT; diff --git a/pgsql/sql/pointcloud-ght.sql b/pgsql/sql/pointcloud-ght.sql deleted file mode 100644 index 92f05d8..0000000 --- a/pgsql/sql/pointcloud-ght.sql +++ /dev/null @@ -1,80 +0,0 @@ -INSERT INTO pointcloud_formats (pcid, srid, schema) -VALUES (5, 0, -' - - - 1 - 4 - X coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. - X - int32_t - 0.01 - - - 2 - 4 - Y coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. - Y - int32_t - 0.01 - - - 3 - 4 - Z coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. - Z - int32_t - 0.01 - - - 4 - 2 - The intensity value is the integer representation of the pulse return magnitude. This value is optional and system specific. However, it should always be included if available. - Intensity - uint16_t - 1 - - - ght - 4326 - -' -); - - -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; - -TRUNCATE pointcloud_formats; diff --git a/pgsql/sql/pointcloud.sql b/pgsql/sql/pointcloud.sql index 8552d9d..adfeee1 100644 --- a/pgsql/sql/pointcloud.sql +++ b/pgsql/sql/pointcloud.sql @@ -42,12 +42,6 @@ VALUES (1, 0, -- XYZI, scaled, uncompressed none - - - - - - 4326 ' @@ -138,12 +132,6 @@ VALUES (1, 0, -- XYZI, scaled, uncompressed none - - - - - - 4326 ' @@ -378,7 +366,6 @@ FROM p1, ( values ('dimensional','sigbits'), ('dimensional','auto'), ('laz','null') - -- ,('ght',null) -- fails due to https://github.com/pgpointcloud/pointcloud/issues/35 ) dimcompr(compr,sc) ORDER BY compr,sc,v; diff --git a/tools/benchmark.pl b/tools/benchmark.pl index 8b2ad43..10ed19d 100755 --- a/tools/benchmark.pl +++ b/tools/benchmark.pl @@ -259,8 +259,8 @@ avg(pc_memsize(\"${col}\"))/avg(pc_numpoints(\"${col}\")), -- 4 avg(pc_memsize(\"${col}\")), -- 5 array_to_string(array_agg(distinct CASE WHEN PC_Compression(\"${col}\") = 0 THEN 'NONE' - WHEN PC_Compression(\"${col}\") = 1 THEN 'GHT' - WHEN PC_Compression(\"${col}\") = 2 THEN 'DIMENSIONAL' + WHEN PC_Compression(\"${col}\") = 1 THEN 'DIMENSIONAL' + WHEN PC_Compression(\"${col}\") = 2 THEN 'LAZPERF' ELSE 'UNKNOWN' END ), ','),