CREATE EXTENSION pointcloud;
SELECT PC_Version();
INSERT INTO pointcloud_formats (pcid, srid, schema)
VALUES (1, 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
none
4326
'
),
(3, 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
dimensional
4326
'
)
,(10, 0, -- All (signed) interpretations, uncompressed
'
1 x
1 int8_t
0.01
2 y
2 int8_t
0.01
3 i2
2 int16_t
0.01
4 i4
4 int32_t
0.01
5 i8
8 int64_t
0.01
6 f4
4 float
0.01
7 f8
8 double
0.01
'
)
,(11, 0, -- All (signed) interpretations, dimensionally-compressed
'
1 x
1 int8_t
0.01
2 y
2 int8_t
0.01
3 i2
2 int16_t
0.01
4 i4
4 int32_t
0.01
5 i8
8 int64_t
0.01
6 f4
4 float
0.01
7 f8
8 double
0.01
dimensional
'
)
;
CREATE TABLE IF NOT EXISTS pt_test (
pt PCPOINT(1)
);
\d pt_test
DELETE FROM pt_test;
INSERT INTO pt_test (pt) VALUES ('00000000020000000100000002000000030004');
INSERT INTO pt_test (pt) VALUES ('00000000010000000100000002000000030004');
INSERT INTO pt_test (pt) VALUES ('00000000010000000200000003000000030005');
INSERT INTO pt_test (pt) VALUES ('00000000010000000300000004000000030006');
SELECT PC_Get(pt, 'Intensity') FROM pt_test;
SELECT Sum(PC_Get(pt, 'y')) FROM pt_test;
SELECT PC_Get(pt) FROM pt_test;
SELECT PC_AsText(pt) FROM pt_test;
SELECT PC_AsText(PC_Patch(pt)) FROM pt_test;
SELECT PC_AsText(PC_Explode(PC_Patch(pt))) FROM pt_test;
SELECT Sum(PC_MemSize(pt)) FROM pt_test;
CREATE TABLE IF NOT EXISTS pa_test (
pa PCPATCH(1)
);
\d pa_test
DELETE FROM pa_test;
INSERT INTO pa_test (pa) VALUES ('0000000002000000000000000200000002000000030000000500060000000200000003000000050008');
INSERT INTO pa_test (pa) VALUES ('0000000001000000000000000200000002000000030000000500060000000200000003000000050008');
INSERT INTO pa_test (pa) VALUES ('000000000100000000000000020000000600000007000000050006000000090000000A00000005000A');
INSERT INTO pa_test (pa) VALUES ('000000000100000000000000020000000600000007000000050006000000090000000A00000005000A');
INSERT INTO pa_test (pa) VALUES ('000000000100000000000000020000000600000007000000050006000000090000000A00000005000A');
SELECT PC_Uncompress(pa) FROM pa_test LIMIT 1;
SELECT PC_AsText(pa) FROM pa_test;
SELECT PC_Envelope(pa) from pa_test;
SELECT PC_AsText(PC_Union(pa)) FROM pa_test;
SELECT sum(PC_NumPoints(pa)) FROM pa_test;
CREATE TABLE IF NOT EXISTS pa_test_dim (
pa PCPATCH(3)
);
\d pa_test_dim
INSERT INTO pa_test_dim (pa) VALUES ('0000000003000000000000000200000002000000030000000500060000000200000003000000050008');
INSERT INTO pa_test_dim (pa) VALUES ('000000000300000000000000020000000600000007000000050006000000090000000A00000005000A');
INSERT INTO pa_test_dim (pa) VALUES ('0000000003000000000000000200000002000000030000000500060000000200000003000000050003');
INSERT INTO pa_test_dim (pa) VALUES ('0000000003000000000000000200000002000000030000000500060000000200000003000000050001');
SELECT Sum(PC_NumPoints(pa)) FROM pa_test_dim;
SELECT Sum(PC_MemSize(pa)) FROM pa_test_dim;
SELECT Sum(PC_PatchMax(pa,'x')) FROM pa_test_dim;
SELECT Sum(PC_PatchMin(pa,'x')) FROM pa_test_dim;
DELETE FROM pa_test_dim;
INSERT INTO pa_test_dim (pa)
SELECT PC_Patch(PC_MakePoint(3, 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_dim;
SELECT Sum(PC_MemSize(pa)) FROM pa_test_dim;
SELECT Max(PC_PatchMax(pa,'x')) FROM pa_test_dim;
SELECT Min(PC_PatchMin(pa,'x')) FROM pa_test_dim;
SELECT Min(PC_PatchMin(pa,'z')) FROM pa_test_dim;
SELECT PC_Summary(pa) summary FROM pa_test_dim order by 1 limit 1;
--DROP TABLE pts_collection;
DROP TABLE pt_test;
DROP TABLE pa_test;
DROP TABLE pa_test_dim;
-- See https://github.com/pgpointcloud/pointcloud/issues/44
SELECT PC_AsText(PC_Patch(ARRAY[PC_MakePoint(3, ARRAY[-127, 45, 124.0, 4.0])]::pcpoint[]));
SELECT 'pc_id1', PC_PCId(PC_Patch(PC_MakePoint(3, ARRAY[-1,-2,-3,-4])));
SELECT 'pc_id2', PC_PCId(PC_MakePoint(3, ARRAY[-1,-2,-3,-4]));
-- Test PC_Compress
-- Also regression tests for
-- https://github.com/pgpointcloud/pointcloud/issues/69
WITH points AS (
SELECT ARRAY[
(2^08/256.0*v)*0.01, -- int8_t
-(2^08/256.0*v)*0.01, -- int8_t
(2^16/256.0*v)*0.01, -- int16_t
(2^32/256.0*v)*0.01, -- int32_t
(2^64/256.0*v)*0.01, -- int64_t
(2^32/256.0*v)*0.01, -- float
(2^64/256.0*v)*0.01 -- double
] a, v/16 v
FROM generate_series(-127,127,4) v
), p1 AS (
SELECT v, PC_Patch(PC_MakePoint(10, a)) p from points -- uncompressed
GROUP BY v
)
SELECT 'compr' test,
p1.v, compr, sc,
PC_AsText(p1.p) =
PC_AsText(PC_Compress(p1.p, compr,
array_to_string(
array_fill(sc,ARRAY[7]),
','
)
)) ok
FROM p1, ( values
('dimensional','rle'),
('dimensional','zlib'),
('dimensional','sigbits'),
('dimensional','auto')
-- ,('ght',null) -- fails due to https://github.com/pgpointcloud/pointcloud/issues/35
) dimcompr(compr,sc)
WHERE NOT ok
ORDER BY compr,sc,v;
TRUNCATE pointcloud_formats;