Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38011ac

Browse files
committedAug 30, 2018
pc_bounds_to_geometry_wkb
1 parent 29fdb7c commit 38011ac

15 files changed

+4098
-4103
lines changed
 

‎lib/cunit/cu_pc_patch.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,12 @@ test_patch_wkb()
513513
PCPOINTLIST *pl1;
514514
PCPATCH_UNCOMPRESSED *pu1, *pu2;
515515
PCPATCH *pa1, *pa2, *pa3, *pa4;
516-
size_t z1, z2;
517-
uint8_t *wkb1, *wkb2;
516+
size_t z1, z2, z3;
517+
uint8_t *wkb1, *wkb2, *wkb3;
518+
char *hexwkb;
519+
520+
static char *hexresult_ndr = "01030000000100000005000000000000000000000000000000000000000000000000000000CDCCCCCCCC8C4B40EC51B81E852B4440CDCCCCCCCC8C4B40EC51B81E852B4440000000000000000000000000000000000000000000000000";
521+
static char *hexresult_xdr = "00000000030000000100000005000000000000000000000000000000000000000000000000404B8CCCCCCCCCCD40442B851EB851EC404B8CCCCCCCCCCD40442B851EB851EC000000000000000000000000000000000000000000000000";
518522

519523
pl1 = pc_pointlist_make(npts);
520524

@@ -533,6 +537,7 @@ test_patch_wkb()
533537
// str = pc_hexbytes_from_bytes(wkb1, z1);
534538
// printf("str\n%s\n",str);
535539
pa2 = pc_patch_from_wkb(simpleschema, wkb1, z1);
540+
pcfree(wkb1);
536541

537542
// printf("pa2\n%s\n",pc_patch_to_string(pa2));
538543

@@ -556,6 +561,18 @@ test_patch_wkb()
556561
CU_ASSERT_EQUAL(pu1->npoints, pu2->npoints);
557562
CU_ASSERT(memcmp(pu1->data, pu2->data, pu1->datasize) == 0);
558563

564+
wkb3 = pc_bounds_to_geometry_wkb(&pa1->bounds, simpleschema->srid, &z3);
565+
hexwkb = pc_hexbytes_from_bytes(wkb3, z3);
566+
if ( machine_endian() == PC_NDR )
567+
{
568+
CU_ASSERT_STRING_EQUAL(hexwkb, hexresult_ndr);
569+
}
570+
else
571+
{
572+
CU_ASSERT_STRING_EQUAL(hexwkb, hexresult_xdr);
573+
}
574+
pcfree(hexwkb);
575+
pcfree(wkb3);
559576

560577
pc_pointlist_free(pl1);
561578
pc_patch_free(pa1);
@@ -564,7 +581,6 @@ test_patch_wkb()
564581
pc_patch_free(pa4);
565582
pc_patch_free((PCPATCH*)pu1);
566583
pc_patch_free((PCPATCH*)pu2);
567-
pcfree(wkb1);
568584
}
569585

570586

‎lib/pc_api.h

+3
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ int pc_patch_compute_extent(PCPATCH *patch);
441441
/** True/false if bounds intersect */
442442
int pc_bounds_intersects(const PCBOUNDS *b1, const PCBOUNDS *b2);
443443

444+
/** Return the bounds as an OGC WKB geometry */
445+
uint8_t *pc_bounds_to_geometry_wkb(const PCBOUNDS *bounds, uint32_t srid, size_t *wkbsize);
446+
444447
/** Returns OGC WKB of the bounding diagonal of XY bounds */
445448
uint8_t* pc_bounding_diagonal_wkb_from_bounds(const PCBOUNDS *bounds, const PCSCHEMA *schema, size_t *wkbsize);
446449

‎lib/pc_util.c

+77
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,83 @@ static uint32_t srid_mask = 0x20000000;
290290
static uint32_t m_mask = 0x40000000;
291291
static uint32_t z_mask = 0x80000000;
292292

293+
uint8_t *
294+
pc_bounds_to_geometry_wkb(const PCBOUNDS *bounds, uint32_t srid, size_t *wkbsize)
295+
{
296+
/* Bounds! */
297+
double xmin = bounds->xmin;
298+
double ymin = bounds->ymin;
299+
double xmax = bounds->xmax;
300+
double ymax = bounds->ymax;
301+
302+
static uint32_t srid_mask = 0x20000000;
303+
static uint32_t npoints_by_type[] = { 0, 1, 2, 5 };
304+
/* WKB POINT, LINESTRING or POLYGON */
305+
uint32_t wkbtype = 1 + (xmin != xmax) + (ymin != ymax);
306+
uint32_t npoints = npoints_by_type[wkbtype];
307+
uint8_t *wkb, *ptr;
308+
/* endian + (type + nrings? + npoints?) + npoints dbl pt */
309+
size_t size = 1 + wkbtype * 4 + npoints * 2 * 8;
310+
311+
if ( srid )
312+
{
313+
wkbtype |= srid_mask;
314+
size += 4;
315+
}
316+
317+
wkb = pcalloc(size);
318+
ptr = wkb;
319+
320+
ptr = wkb_set_char(ptr, machine_endian()); /* Endian flag */
321+
322+
ptr = wkb_set_uint32(ptr, wkbtype); /* TYPE = POINT, LINESTRING or POLYGON */
323+
324+
if ( srid )
325+
{
326+
ptr = wkb_set_uint32(ptr, srid); /* SRID */
327+
}
328+
329+
switch ( wkbtype )
330+
{
331+
case 3 /* POLYGON */ : ptr = wkb_set_uint32(ptr, 1); /* NRINGS */
332+
case 2 /* LINESTRING */ : ptr = wkb_set_uint32(ptr, npoints); /* NPOINTS */
333+
}
334+
335+
/* Point 0 */
336+
ptr = wkb_set_double(ptr, xmin);
337+
ptr = wkb_set_double(ptr, ymin);
338+
339+
if ( wkbtype == 2 ) // LINESTRING
340+
{
341+
/* Point 1 */
342+
ptr = wkb_set_double(ptr, xmax);
343+
ptr = wkb_set_double(ptr, ymax);
344+
}
345+
else if( wkbtype == 3 ) // POLYGON
346+
{
347+
/* Point 1 */
348+
ptr = wkb_set_double(ptr, xmin);
349+
ptr = wkb_set_double(ptr, ymax);
350+
351+
/* Point 2 */
352+
ptr = wkb_set_double(ptr, xmax);
353+
ptr = wkb_set_double(ptr, ymax);
354+
355+
/* Point 3 */
356+
ptr = wkb_set_double(ptr, xmax);
357+
ptr = wkb_set_double(ptr, ymin);
358+
359+
/* Point 4 */
360+
ptr = wkb_set_double(ptr, xmin);
361+
ptr = wkb_set_double(ptr, ymin);
362+
}
363+
364+
if ( wkbsize )
365+
*wkbsize = size;
366+
367+
return wkb;
368+
}
369+
293370
uint8_t *
294371
pc_bounding_diagonal_wkb_from_bounds(
295372
const PCBOUNDS *bounds, const PCSCHEMA *schema, size_t *wkbsize)

‎pgsql/.gitignore

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
regression.out
2-
regression.diffs
3-
results/
4-
tmp_check/
5-
log/
6-
Makefile
7-
sqldefines.h
1+
regression.out
2+
regression.diffs
3+
results/
4+
tmp_check/
5+
log/
6+
Makefile
7+
sqldefines.h

‎pgsql/META.json

+41-41
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
{
2-
"name": "pointcloud",
3-
"abstract": "LIDAR data support type and functions",
4-
"description": "Point and Patch types for LIDAR storage. Aggregate and access functions. JSON and binary serializations. Compression.",
5-
"version": "1.0.0",
6-
"release_status": "unstable",
7-
"maintainer": "Paul Ramsey",
8-
"license": "bsd",
9-
"provides": {
10-
"pointcloud": {
11-
"abstract": "LIDAR point and patch types and functions",
12-
"version": "1.0.0",
13-
"file": "",
14-
"docfile": ""
15-
}
16-
}
17-
"prereqs": {
18-
"runtime": {
19-
"requires": {
20-
}
21-
}
22-
},
23-
"generated_by": "Paul Ramsey",
24-
"resources": {
25-
"bugtracker": {
26-
"web": "https://github.com/pgpointcloud/pointcloud"
27-
},
28-
"repository": {
29-
"url": "",
30-
"web": "https://github.com/pgpointcloud/pointcloud",
31-
"type": "git"
32-
}
33-
},
34-
"meta-spec": {
35-
"version": "1.0.0",
36-
"url": "http://pgxn.org/meta/spec.txt"
37-
},
38-
"tags": [
39-
"gis", "lidar"
40-
]
41-
}
1+
{
2+
"name": "pointcloud",
3+
"abstract": "LIDAR data support type and functions",
4+
"description": "Point and Patch types for LIDAR storage. Aggregate and access functions. JSON and binary serializations. Compression.",
5+
"version": "1.0.0",
6+
"release_status": "unstable",
7+
"maintainer": "Paul Ramsey",
8+
"license": "bsd",
9+
"provides": {
10+
"pointcloud": {
11+
"abstract": "LIDAR point and patch types and functions",
12+
"version": "1.0.0",
13+
"file": "",
14+
"docfile": ""
15+
}
16+
}
17+
"prereqs": {
18+
"runtime": {
19+
"requires": {
20+
}
21+
}
22+
},
23+
"generated_by": "Paul Ramsey",
24+
"resources": {
25+
"bugtracker": {
26+
"web": "https://github.com/pgpointcloud/pointcloud"
27+
},
28+
"repository": {
29+
"url": "",
30+
"web": "https://github.com/pgpointcloud/pointcloud",
31+
"type": "git"
32+
}
33+
},
34+
"meta-spec": {
35+
"version": "1.0.0",
36+
"url": "http://pgxn.org/meta/spec.txt"
37+
},
38+
"tags": [
39+
"gis", "lidar"
40+
]
41+
}

‎pgsql/Makefile.in

+58-58
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
# pointcloud
2-
3-
include ../config.mk
4-
5-
SQLPP = @SQLPP@
6-
7-
OBJS = \
8-
pc_inout.o \
9-
pc_access.o \
10-
pc_editor.o \
11-
pc_pgsql.o
12-
13-
SED = sed
14-
EXTENSION = pointcloud
15-
EXTVERSION=$(shell cat ../Version.config)
16-
EXTVERSION_MAJOR=$(shell cut -d. -f1,2 ../Version.config)
17-
MODULE_big = $(EXTENSION)-$(EXTVERSION_MAJOR)
18-
UPGRADABLE = 1.1.0 1.1.1
19-
20-
UPGRADES = \
21-
$(shell echo $(UPGRADABLE) | \
22-
$(SED) 's/^/$(EXTENSION)--/' | \
23-
$(SED) 's/$$/--$(EXTVERSION).sql/' | \
24-
$(SED) 's/ /--$(EXTVERSION).sql $(EXTENSION)--/g') \
25-
$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql \
26-
$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql
27-
28-
DATA_built = \
29-
$(EXTENSION).control \
30-
$(EXTENSION)--$(EXTVERSION).sql \
31-
$(UPGRADES)
32-
33-
REGRESS = pointcloud pointcloud_columns schema
34-
35-
ifneq ("$(LAZPERF_STATUS)", "disabled")
36-
REGRESS += pointcloud-laz
37-
endif
38-
39-
# Add in build/link flags for lib
40-
PG_CPPFLAGS += -I../lib
41-
SHLIB_LINK += ../lib/$(LIB_A) ../lib/$(LIB_A_LAZPERF) -lstdc++ $(filter -lm, $(LIBS)) $(XML2_LDFLAGS) $(ZLIB_LDFLAGS)
42-
43-
# We are going to use PGXS for sure
44-
include $(PGXS)
45-
46-
$(EXTENSION).control: $(EXTENSION).control.in Makefile
47-
$(SED) -e 's/#POINTCLOUD_VERSION#/$(EXTVERSION)/' \
48-
-e 's/#POINTCLOUD_VERSION_MAJOR#/$(EXTVERSION_MAJOR)/' $< > $@
49-
50-
$(EXTENSION)--$(EXTVERSION).sql: $(EXTENSION).sql.in Makefile
51-
$(SQLPP) -I. $< | $(SED) -e 's/#POINTCLOUD_VERSION#/$(EXTVERSION)/' > $@
52-
53-
# NOTE: relies on PERL being defined by PGXS
54-
$(EXTENSION)--%--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql ../util/proc_upgrade.pl
55-
cat $< | ../util/proc_upgrade.pl > $@
56-
57-
$(EXTENSION)--%--$(EXTVERSION)next.sql: $(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql
58-
ln -f $< $@
1+
# pointcloud
2+
3+
include ../config.mk
4+
5+
SQLPP = @SQLPP@
6+
7+
OBJS = \
8+
pc_inout.o \
9+
pc_access.o \
10+
pc_editor.o \
11+
pc_pgsql.o
12+
13+
SED = sed
14+
EXTENSION = pointcloud
15+
EXTVERSION=$(shell cat ../Version.config)
16+
EXTVERSION_MAJOR=$(shell cut -d. -f1,2 ../Version.config)
17+
MODULE_big = $(EXTENSION)-$(EXTVERSION_MAJOR)
18+
UPGRADABLE = 1.1.0 1.1.1
19+
20+
UPGRADES = \
21+
$(shell echo $(UPGRADABLE) | \
22+
$(SED) 's/^/$(EXTENSION)--/' | \
23+
$(SED) 's/$$/--$(EXTVERSION).sql/' | \
24+
$(SED) 's/ /--$(EXTVERSION).sql $(EXTENSION)--/g') \
25+
$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql \
26+
$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql
27+
28+
DATA_built = \
29+
$(EXTENSION).control \
30+
$(EXTENSION)--$(EXTVERSION).sql \
31+
$(UPGRADES)
32+
33+
REGRESS = pointcloud pointcloud_columns schema
34+
35+
ifneq ("$(LAZPERF_STATUS)", "disabled")
36+
REGRESS += pointcloud-laz
37+
endif
38+
39+
# Add in build/link flags for lib
40+
PG_CPPFLAGS += -I../lib
41+
SHLIB_LINK += ../lib/$(LIB_A) ../lib/$(LIB_A_LAZPERF) -lstdc++ $(filter -lm, $(LIBS)) $(XML2_LDFLAGS) $(ZLIB_LDFLAGS)
42+
43+
# We are going to use PGXS for sure
44+
include $(PGXS)
45+
46+
$(EXTENSION).control: $(EXTENSION).control.in Makefile
47+
$(SED) -e 's/#POINTCLOUD_VERSION#/$(EXTVERSION)/' \
48+
-e 's/#POINTCLOUD_VERSION_MAJOR#/$(EXTVERSION_MAJOR)/' $< > $@
49+
50+
$(EXTENSION)--$(EXTVERSION).sql: $(EXTENSION).sql.in Makefile
51+
$(SQLPP) -I. $< | $(SED) -e 's/#POINTCLOUD_VERSION#/$(EXTVERSION)/' > $@
52+
53+
# NOTE: relies on PERL being defined by PGXS
54+
$(EXTENSION)--%--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql ../util/proc_upgrade.pl
55+
cat $< | ../util/proc_upgrade.pl > $@
56+
57+
$(EXTENSION)--%--$(EXTVERSION)next.sql: $(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql
58+
ln -f $< $@

‎pgsql/expected/pointcloud.out

+51-51
Large diffs are not rendered by default.

‎pgsql/pc_access.c

+1,182-1,182
Large diffs are not rendered by default.

‎pgsql/pc_editor.c

+126-126
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,126 @@
1-
/***********************************************************************
2-
* pc_editor.c
3-
*
4-
* Editor functions for points and patches in PgSQL.
5-
*
6-
* Copyright (c) 2017 Oslandia
7-
*
8-
***********************************************************************/
9-
10-
#include "pc_pgsql.h" /* Common PgSQL support for our type */
11-
12-
Datum pcpatch_setpcid(PG_FUNCTION_ARGS);
13-
Datum pcpatch_transform(PG_FUNCTION_ARGS);
14-
15-
16-
static SERIALIZED_PATCH *
17-
pcpatch_set_schema(SERIALIZED_PATCH *serpa,
18-
PCSCHEMA *oschema, PCSCHEMA *nschema, float8 def)
19-
{
20-
SERIALIZED_PATCH *serpatch;
21-
PCPATCH *paout;
22-
23-
if ( pc_schema_same_dimensions(oschema, nschema) )
24-
{
25-
// oschema and nschema have the same dimensions at the same
26-
// positions, so we can take a fast path and avoid the
27-
// point-by-point dimension-by-dimension copying
28-
29-
if ( oschema->compression == nschema->compression )
30-
{
31-
// no need to deserialize the patch
32-
serpatch = palloc(serpa->size);
33-
if ( ! serpatch )
34-
return NULL;
35-
memcpy(serpatch, serpa, serpa->size);
36-
serpatch->pcid = nschema->pcid;
37-
return serpatch;
38-
}
39-
else
40-
{
41-
paout = pc_patch_deserialize(serpa, oschema);
42-
if ( ! paout )
43-
return NULL;
44-
paout->schema = nschema;
45-
}
46-
} else {
47-
PCPATCH *patch;
48-
49-
patch = pc_patch_deserialize(serpa, oschema);
50-
if ( ! patch )
51-
return NULL;
52-
53-
paout = pc_patch_set_schema(patch, nschema, def);
54-
55-
if ( patch != paout )
56-
pc_patch_free(patch);
57-
58-
if ( ! paout )
59-
return NULL;
60-
61-
}
62-
63-
serpatch = pc_patch_serialize(paout, NULL);
64-
pc_patch_free(paout);
65-
66-
return serpatch;
67-
}
68-
69-
70-
PG_FUNCTION_INFO_V1(pcpatch_setpcid);
71-
Datum pcpatch_setpcid(PG_FUNCTION_ARGS)
72-
{
73-
SERIALIZED_PATCH *serpatch;
74-
SERIALIZED_PATCH *serpa = PG_GETARG_SERPATCH_P(0);
75-
int32 pcid = PG_GETARG_INT32(1);
76-
float8 def = PG_GETARG_FLOAT8(2);
77-
PCSCHEMA *oschema = pc_schema_from_pcid(serpa->pcid, fcinfo);
78-
PCSCHEMA *nschema = pc_schema_from_pcid(pcid, fcinfo);
79-
80-
serpatch = pcpatch_set_schema(serpa, oschema, nschema, def);
81-
if ( ! serpatch )
82-
PG_RETURN_NULL();
83-
PG_RETURN_POINTER(serpatch);
84-
}
85-
86-
87-
PG_FUNCTION_INFO_V1(pcpatch_transform);
88-
Datum pcpatch_transform(PG_FUNCTION_ARGS)
89-
{
90-
SERIALIZED_PATCH *serpatch;
91-
SERIALIZED_PATCH *serpa = PG_GETARG_SERPATCH_P(0);
92-
int32 pcid = PG_GETARG_INT32(1);
93-
float8 def = PG_GETARG_FLOAT8(2);
94-
PCSCHEMA *oschema = pc_schema_from_pcid(serpa->pcid, fcinfo);
95-
PCSCHEMA *nschema = pc_schema_from_pcid(pcid, fcinfo);
96-
97-
// fast path to setpcid if no data transformation is required
98-
99-
if ( pc_schema_same_interpretations(oschema, nschema) )
100-
{
101-
serpatch = pcpatch_set_schema(serpa, oschema, nschema, def);
102-
if ( ! serpatch )
103-
PG_RETURN_NULL();
104-
PG_RETURN_POINTER(serpatch);
105-
}
106-
else
107-
{
108-
PCPATCH *patch, *paout;
109-
110-
patch = pc_patch_deserialize(serpa, oschema);
111-
if ( ! patch )
112-
PG_RETURN_NULL();
113-
114-
paout = pc_patch_transform(patch, nschema, def);
115-
116-
pc_patch_free(patch);
117-
118-
if ( ! paout )
119-
PG_RETURN_NULL();
120-
121-
serpatch = pc_patch_serialize(paout, NULL);
122-
pc_patch_free(paout);
123-
124-
PG_RETURN_POINTER(serpatch);
125-
}
126-
}
1+
/***********************************************************************
2+
* pc_editor.c
3+
*
4+
* Editor functions for points and patches in PgSQL.
5+
*
6+
* Copyright (c) 2017 Oslandia
7+
*
8+
***********************************************************************/
9+
10+
#include "pc_pgsql.h" /* Common PgSQL support for our type */
11+
12+
Datum pcpatch_setpcid(PG_FUNCTION_ARGS);
13+
Datum pcpatch_transform(PG_FUNCTION_ARGS);
14+
15+
16+
static SERIALIZED_PATCH *
17+
pcpatch_set_schema(SERIALIZED_PATCH *serpa,
18+
PCSCHEMA *oschema, PCSCHEMA *nschema, float8 def)
19+
{
20+
SERIALIZED_PATCH *serpatch;
21+
PCPATCH *paout;
22+
23+
if ( pc_schema_same_dimensions(oschema, nschema) )
24+
{
25+
// oschema and nschema have the same dimensions at the same
26+
// positions, so we can take a fast path and avoid the
27+
// point-by-point dimension-by-dimension copying
28+
29+
if ( oschema->compression == nschema->compression )
30+
{
31+
// no need to deserialize the patch
32+
serpatch = palloc(serpa->size);
33+
if ( ! serpatch )
34+
return NULL;
35+
memcpy(serpatch, serpa, serpa->size);
36+
serpatch->pcid = nschema->pcid;
37+
return serpatch;
38+
}
39+
else
40+
{
41+
paout = pc_patch_deserialize(serpa, oschema);
42+
if ( ! paout )
43+
return NULL;
44+
paout->schema = nschema;
45+
}
46+
} else {
47+
PCPATCH *patch;
48+
49+
patch = pc_patch_deserialize(serpa, oschema);
50+
if ( ! patch )
51+
return NULL;
52+
53+
paout = pc_patch_set_schema(patch, nschema, def);
54+
55+
if ( patch != paout )
56+
pc_patch_free(patch);
57+
58+
if ( ! paout )
59+
return NULL;
60+
61+
}
62+
63+
serpatch = pc_patch_serialize(paout, NULL);
64+
pc_patch_free(paout);
65+
66+
return serpatch;
67+
}
68+
69+
70+
PG_FUNCTION_INFO_V1(pcpatch_setpcid);
71+
Datum pcpatch_setpcid(PG_FUNCTION_ARGS)
72+
{
73+
SERIALIZED_PATCH *serpatch;
74+
SERIALIZED_PATCH *serpa = PG_GETARG_SERPATCH_P(0);
75+
int32 pcid = PG_GETARG_INT32(1);
76+
float8 def = PG_GETARG_FLOAT8(2);
77+
PCSCHEMA *oschema = pc_schema_from_pcid(serpa->pcid, fcinfo);
78+
PCSCHEMA *nschema = pc_schema_from_pcid(pcid, fcinfo);
79+
80+
serpatch = pcpatch_set_schema(serpa, oschema, nschema, def);
81+
if ( ! serpatch )
82+
PG_RETURN_NULL();
83+
PG_RETURN_POINTER(serpatch);
84+
}
85+
86+
87+
PG_FUNCTION_INFO_V1(pcpatch_transform);
88+
Datum pcpatch_transform(PG_FUNCTION_ARGS)
89+
{
90+
SERIALIZED_PATCH *serpatch;
91+
SERIALIZED_PATCH *serpa = PG_GETARG_SERPATCH_P(0);
92+
int32 pcid = PG_GETARG_INT32(1);
93+
float8 def = PG_GETARG_FLOAT8(2);
94+
PCSCHEMA *oschema = pc_schema_from_pcid(serpa->pcid, fcinfo);
95+
PCSCHEMA *nschema = pc_schema_from_pcid(pcid, fcinfo);
96+
97+
// fast path to setpcid if no data transformation is required
98+
99+
if ( pc_schema_same_interpretations(oschema, nschema) )
100+
{
101+
serpatch = pcpatch_set_schema(serpa, oschema, nschema, def);
102+
if ( ! serpatch )
103+
PG_RETURN_NULL();
104+
PG_RETURN_POINTER(serpatch);
105+
}
106+
else
107+
{
108+
PCPATCH *patch, *paout;
109+
110+
patch = pc_patch_deserialize(serpa, oschema);
111+
if ( ! patch )
112+
PG_RETURN_NULL();
113+
114+
paout = pc_patch_transform(patch, nschema, def);
115+
116+
pc_patch_free(patch);
117+
118+
if ( ! paout )
119+
PG_RETURN_NULL();
120+
121+
serpatch = pc_patch_serialize(paout, NULL);
122+
pc_patch_free(paout);
123+
124+
PG_RETURN_POINTER(serpatch);
125+
}
126+
}

‎pgsql/pc_inout.c

+470-470
Large diffs are not rendered by default.

‎pgsql/pc_pgsql.c

+849-950
Large diffs are not rendered by default.

‎pgsql/pointcloud.control.in

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# pointcloud extension
2-
comment = 'data type for lidar point clouds'
3-
default_version = '#POINTCLOUD_VERSION#'
4-
module_pathname = '$libdir/pointcloud-#POINTCLOUD_VERSION_MAJOR#'
5-
relocatable = true
6-
superuser = true
7-
#requires = 'postgis'
1+
# pointcloud extension
2+
comment = 'data type for lidar point clouds'
3+
default_version = '#POINTCLOUD_VERSION#'
4+
module_pathname = '$libdir/pointcloud-#POINTCLOUD_VERSION_MAJOR#'
5+
relocatable = true
6+
superuser = true
7+
#requires = 'postgis'

‎pgsql/pointcloud.sql.in

+534-534
Large diffs are not rendered by default.

‎pgsql/sql/pointcloud-laz.sql

+229-229
Large diffs are not rendered by default.

‎pgsql/sql/pointcloud.sql

+445-445
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.