File: patchs.rst

package info (click to toggle)
pgpointcloud 1.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,892 kB
  • sloc: sql: 40,767; ansic: 11,045; xml: 935; makefile: 297; cpp: 282; perl: 248; python: 178; sh: 92
file content (412 lines) | stat: -rw-r--r-- 13,909 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
.. _patchs:

********************************************************************************
PcPatch
********************************************************************************

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Patch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Patch(pts pcpoint[]) returns pcpatch:

Aggregate function that collects a result set of pcpoint values into a pcpatch.

.. code-block::

    INSERT INTO patches (pa)
    SELECT PC_Patch(pt) FROM points GROUP BY id/10;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_MakePatch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_MakePatch(pcid integer, vals float8[]) returns pcpatch:

Given a valid pcid schema number and an array of doubles that matches the
schema, construct a new pcpatch. Array size must be a multiple of the number of
dimensions.

.. code-block::

    SELECT PC_AsText(PC_MakePatch(1, ARRAY[-126.99,45.01,1,0, -126.98,45.02,2,0, -126.97,45.03,3,0]));

    {"pcid":1,"pts":[
     [-126.99,45.01,1,0],[-126.98,45.02,2,0],[-126.97,45.03,3,0]
    ]}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_NumPoints
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_NumPoints(p pcpatch) returns integer:

Return the number of points in this patch.

.. code-block::

    SELECT PC_NumPoints(pa) FROM patches LIMIT 1;

    9

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PCId
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_PCId(p pcpatch) returns integer:

Return the pcid schema number of points in this patch.

.. code-block::

    SELECT PC_PCId(pa) FROM patches LIMIT 1;

    1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_AsText
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_AsText(p pcpatch) returns text:

Return a JSON version of the data in that patch.

.. code-block::

    SELECT PC_AsText(pa) FROM patches LIMIT 1;

    {"pcid":1,"pts":[
     [-126.99,45.01,1,0],[-126.98,45.02,2,0],[-126.97,45.03,3,0],
     [-126.96,45.04,4,0],[-126.95,45.05,5,0],[-126.94,45.06,6,0],
     [-126.93,45.07,7,0],[-126.92,45.08,8,0],[-126.91,45.09,9,0]
    ]}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Summary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Summary(p pcpatch) returns text (from 1.1.0):

Return a JSON formatted summary of the data in that point.

.. code-block::

    SELECT PC_Summary(pa) FROM patches LIMIT 1;

    {"pcid":1, "npts":9, "srid":4326, "compr":"dimensional","dims":[{"pos":0,"name":"X","size":4,"type":"int32_t","compr":"sigbits","stats":{"min":-126.99,"max":-126.91,"avg":-126.95}},{"pos":1,"name":"Y","size":4,"type":"int32_t","compr":"sigbits","stats":{"min":45.01,"max":45.09,"avg":45.05}},{"pos":2,"name":"Z","size":4,"type":"int32_t","compr":"sigbits","stats":{"min":1,"max":9,"avg":5}},{"pos":3,"name":"Intensity","size":2,"type":"uint16_t","compr":"rle","stats":{"min":0,"max":0,"avg":0}}]}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Uncompress
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Uncompress(p pcpatch) returns pcpatch:

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 other functions that
return pcpatch will compress output to the schema-specified compression before
returning.

.. code-block::

    SELECT PC_Uncompress(pa) FROM patches
    WHERE PC_NumPoints(pa) = 1;

    01010000000000000001000000C8CEFFFFF8110000102700000A00


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Union
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Union(p pcpatch[]) returns pcpatch:

Aggregate function merges a result set of pcpatch entries into a single pcpatch.

.. code-block::

    -- Compare npoints(sum(patches)) to sum(npoints(patches))
    SELECT PC_NumPoints(PC_Union(pa)) FROM patches;
    SELECT Sum(PC_NumPoints(pa)) FROM patches;

    100


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Intersects
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Intersects(p1 pcpatch, p2 pcpatch) returns boolean:

Returns true if the bounds of p1 intersect the bounds of p2.

.. code-block::

    -- Patch should intersect itself
    SELECT PC_Intersects(
             '01010000000000000001000000C8CEFFFFF8110000102700000A00'::pcpatch,
             '01010000000000000001000000C8CEFFFFF8110000102700000A00'::pcpatch);

    t

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Explode
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: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.

.. code-block::

    SELECT PC_AsText(PC_Explode(pa)), id
    FROM patches WHERE id = 7;

                  pc_astext               | id
    --------------------------------------+----
     {"pcid":1,"pt":[-126.5,45.5,50,5]}   |  7
     {"pcid":1,"pt":[-126.49,45.51,51,5]} |  7
     {"pcid":1,"pt":[-126.48,45.52,52,5]} |  7
     {"pcid":1,"pt":[-126.47,45.53,53,5]} |  7
     {"pcid":1,"pt":[-126.46,45.54,54,5]} |  7
     {"pcid":1,"pt":[-126.45,45.55,55,5]} |  7
     {"pcid":1,"pt":[-126.44,45.56,56,5]} |  7
     {"pcid":1,"pt":[-126.43,45.57,57,5]} |  7
     {"pcid":1,"pt":[-126.42,45.58,58,5]} |  7
     {"pcid":1,"pt":[-126.41,45.59,59,5]} |  7


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PatchAvg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_PatchAvg(p pcpatch, dimname text) returns numeric:

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.

.. code-block::

    SELECT PC_PatchAvg(pa, 'intensity')
    FROM patches WHERE id = 7;

    5.0000000000000000


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PatchMax
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_PatchMax(p pcpatch, dimname text) returns numeric:

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.

.. code-block::

    SELECT PC_PatchMax(pa, 'x')
    FROM patches WHERE id = 7;

    -126.41

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PatchMin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_PatchMin(p pcpatch, dimname text) returns numeric:

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.

.. code-block::

    SELECT PC_PatchMin(pa, 'y')
    FROM patches WHERE id = 7;

    45.5

:PC_PatchMin(p pcpatch) returns pcpoint:

Returns a PcPoint with the minimum values of each dimension in the patch.

.. code-block::

    SELECT PC_PatchMin(pa)
    FROM patches WHERE id = 7;

    {"pcid":1,"pt":[-126.5,45.5,50,5]}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PatchAvg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_PatchAvg(p pcpatch) returns pcpoint:

Returns a PcPoint with the average values of each dimension in the patch.

.. code-block::

    SELECT PC_AsText(PC_PatchAvg(pa))
    FROM patches WHERE id = 7;

    {"pcid":1,"pt":[-126.46,45.54,54.5,5]}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PatchMax
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_PatchMax(p pcpatch) returns pcpoint:

Returns a PcPoint with the maximum values of each dimension in the patch.

.. code-block::

    SELECT PC_PatchMax(pa)
    FROM patches WHERE id = 7;

    {"pcid":1,"pt":[-126.41,45.59,59,5]}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_FilterGreaterThan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_FilterGreaterThan(p pcpatch, dimname text, float8 value) returns pcpatch:

Returns a patch with only points whose values are greater than the supplied
value for the requested dimension.

.. code-block::

    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]]}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_FilterLessThan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_FilterLessThan(p pcpatch, dimname text, float8 value) returns pcpatch:

Returns a patch with only points whose values are less than the supplied value
for the requested dimension.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_FilterBetween
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_FilterBetween(p pcpatch, dimname text, float8 value1, float8 value2) returns pcpatch:

Returns a patch with only points whose values are between (excluding) the
supplied values for the requested dimension.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_FilterEquals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_FilterEquals(p pcpatch, dimname text, float8 value) returns pcpatch:

Returns a patch with only points whose values are the same as the supplied
values for the requested dimension.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Compress
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Compress(p pcpatch,global_compression_scheme text,compression_config text) returns pcpatch:

Compress a patch with a manually specified scheme. The compression_config
semantic depends on the global compression scheme. Allowed global compression
schemes are:

- auto: determined by pcid
- laz: no compression config supported
- dimensional: configuration is a comma-separated list of per-dimension compressions from this list

    - auto: determined automatically from values stats
    - zlib: deflate compression
    - sigbits: significant bits removal
    - rle: run-length encoding

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_PointN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_IsSorted
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_IsSorted(p pcpatch, dimnames text[], strict boolean default true) returns boolean:

Checks whether a pcpatch is sorted lexicographically along the given
dimensions. The ``strict`` option further checks that the ordering is strict
(no duplicates).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Sort
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Sort(p pcpatch, dimnames text[]) returns pcpatch:

Returns a copy of the input patch lexicographically sorted along the given
dimensions.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Range
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Range(p pcpatch, start int4, n int4) returns pcpatch:

Returns a patch containing n points. These points are selected from the
start-th point with 1-based indexing.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_SetPCId
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_SetPCId(p pcpatch, pcid int4, def float8 default 0.0) returns pcpatch:

Sets the schema on a ``PcPatch``, given a valid ``pcid`` schema number.

For dimensions that are in the "new" schema but not in the "old" schema the
value ``def`` is set in the points of the output patch. ``def`` is optional,
its default value is ``0.0``.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_Transform
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_Transform(p pcpatch, pcid int4, def float8 default 0.0) returns pcpatch:

Returns a new patch with its data transformed based on the schema whose
identifier is ``pcid``.

For dimensions that are in the "new" schema but not in the "old" schema the
value ``def`` is set in the points of the output patch. ``def`` is optional,
its default value is ``0.0``.

Contrary to ``PC_SetPCId``, ``PC_Transform`` may change (transform) the patch
data if dimension interpretations, scales or offsets are different in the new
schema.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_MemSize
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:PC_MemSize(p pcpatch) returns int4:

Return the memory size of a pcpatch.

.. code-block::

    SELECT PC_MemSize(PC_Patch(PC_MakePoint(1, ARRAY[-127, 45, 124.0, 4.0])));

    161