Skip to content

Issue with double precision points when returning points with PC_AsText #310

@Ogator

Description

@Ogator

Description

Coordinates get rounded off when retrieving point data with PC_AsText function.

Step to reproduce

Have pointcloud_postgis installed on postgresql 12.
DBMS: PostgreSQL (ver. 12.10 (Debian 12.10-1.pgdg110+1)) Case sensitivity: plain=lower, delimited=exact Driver: PostgreSQL JDBC Driver (ver. 42.2.5, JDBC4.2)

Create pointcloud_formats definition below as pcid 9:

<?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>8</pc:size>
        <pc:description>X coordinate</pc:description>
        <pc:name>X</pc:name>
        <pc:interpretation>double</pc:interpretation>
        <pc:active>true</pc:active>
    </pc:dimension>
    <pc:dimension>
        <pc:position>2</pc:position>
        <pc:size>8</pc:size>
        <pc:description>Y coordinate</pc:description>
        <pc:name>Y</pc:name>
        <pc:interpretation>double</pc:interpretation>
        <pc:active>true</pc:active>
    </pc:dimension>
    <pc:dimension>
        <pc:position>3</pc:position>
        <pc:size>8</pc:size>
        <pc:description>Z coordinate</pc:description>
        <pc:name>Z</pc:name>
        <pc:interpretation>double</pc:interpretation>
        <pc:active>true</pc:active>
    </pc:dimension>
    <pc:metadata>
        <Metadata name="compression" type="string"></Metadata>
    </pc:metadata>
    <pc:orientation>point</pc:orientation>
    <pc:version>1.3</pc:version>
</pc:PointCloudSchema>

Create a table for patch data:

create table source_point_clouds_partitioned
(
	id bigserial not null,
	patch pcpatch not null
);

Create a patch with one point:

INSERT INTO source_point_clouds_partitioned (patch) VALUES(PC_MakePatch(9,  ARRAY[525282.053, 7179377.239, -13.125]));

Retrieve point:

SELECT PC_AsText(patch) pa from source_point_clouds_partitioned;

Output:

{"pcid":9,"pts":[[525282,7.17938e+06,-13.125]]}

Note the discrepancy between Y value inserted and retrieved. It was rounded from 7179377.239 to 7179380.
How can I store coordinates without loss of precision?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions