Fix astext output for point

This commit is contained in:
Paul Ramsey 2013-01-30 14:08:04 -08:00
parent 6df96b0cbf
commit f4b6a31db3
7 changed files with 16 additions and 74 deletions

View File

@ -176,6 +176,7 @@ pc_point_to_string(const PCPOINT *pt)
}
stringbuffer_aprintf(sb, "%g", pc_point_get_double_by_index(pt, i));
}
stringbuffer_append(sb, " )");
str = stringbuffer_getstringcopy(sb);
stringbuffer_destroy(sb);
return str;

View File

@ -152,8 +152,8 @@ stringbuffer_getstringcopy(stringbuffer_t *s)
{
size_t size = (s->str_end - s->str_start) + 1;
char *str = malloc(size);
memcpy(str, s->str_start, size);
str[size - 1] = '\0';
memcpy(str, s->str_start, size-1);
str[size-1] = '\0';
return str;
}

1
pgsql/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
regression.*

View File

@ -67,4 +67,12 @@ SELECT Sum(PC_Get(pt, 'y')) FROM pt_test;
0.09
(1 row)
SELECT PC_AsText(pt) FROM pt_test;
pc_astext
-----------------------------
( 1 : 0.01, 0.02, 0.03, 4 )
( 1 : 0.02, 0.03, 0.03, 5 )
( 1 : 0.03, 0.04, 0.03, 6 )
(3 rows)
DROP TABLE pt_test;

View File

@ -284,8 +284,8 @@ pc_patch_serialize(const PCPATCH *pcpch)
/* Compress uncompressed patches before saving */
patch = pc_patch_compress(pcpch);
/* Allocate */
serpch_size = sizeof(SERIALIZED_PATCH) - 1 + patch->datasize;
/* Allocate: size(int4) + pcid(int4) + npoints(int4) + box(4*float8) + data(?) */
serpch_size = 4+4+4+4*8+patch->datasize;
serpch = palloc(serpch_size);
/* Copy */

View File

@ -1,70 +0,0 @@
CREATE EXTENSION pointcloud;
INSERT INTO pointcloud_formats (pcid, srid, schema)
VALUES (1, 0,
'<?xml version="1.0" encoding="UTF-8"?>
<pc:PointCloudSchema xmlns:pc="http://pointcloud.org/schemas/PC/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pc:dimension>
<pc:position>1</pc:position>
<pc:size>4</pc:size>
<pc:description>X coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.</pc:description>
<pc:name>X</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>2</pc:position>
<pc:size>4</pc:size>
<pc:description>Y coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.</pc:description>
<pc:name>Y</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>3</pc:position>
<pc:size>4</pc:size>
<pc:description>Z coordinate as a long integer. You must use the scale and offset information of the header to determine the double value.</pc:description>
<pc:name>Z</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>4</pc:position>
<pc:size>2</pc:size>
<pc:description>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.</pc:description>
<pc:name>Intensity</pc:name>
<pc:interpretation>uint16_t</pc:interpretation>
<pc:scale>1</pc:scale>
</pc:dimension>
<pc:metadata>
<Metadata name="compression"></Metadata>
<Metadata name="ght_xmin"></Metadata>
<Metadata name="ght_ymin"></Metadata>
<Metadata name="ght_xmax"></Metadata>
<Metadata name="ght_ymax"></Metadata>
<Metadata name="ght_keylength"></Metadata>
<Metadata name="ght_depth"></Metadata>
<Metadata name="spatialreference" type="id">4326</Metadata>
</pc:metadata>
</pc:PointCloudSchema>'
);
CREATE TABLE pt_test (
pt PCPOINT
);
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;
pc_get
--------
4
5
6
(3 rows)
SELECT Sum(PC_Get(pt, 'y')) FROM pt_test;
sum
------
0.09
(1 row)
DROP TABLE pt_test;

View File

@ -60,4 +60,6 @@ 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_AsText(pt) FROM pt_test;
DROP TABLE pt_test;