Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ogator opened this issue May 23, 2022 · 0 comments
Open

Comments

@Ogator
Copy link

Ogator commented May 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant