1

I want to perform ST_SnaptoGrid on a line but the result is very strange. I tested this line of code on 3 separate postgis sessions and the results of all of them was the same:

SELECT ST_AsText(ST_SnapToGrid(
        ST_GeomFromText('LINESTRING(334729.13 4103548.88,334729.12 4103548.5300000003)'),
        0.001)
    );

The result is :

LINESTRING(334729.13 4103548.88,334729.12 4103548.5300000003)

The strange part is that when I test it with a different cell size:

SELECT ST_AsText(ST_SnapToGrid(
        ST_GeomFromText('LINESTRING(334729.13 4103548.88,334729.12 4103548.5300000003)'),
        0.1)
    );

It results to:

LINESTRING(334729.10000000003 4103548.9000000004,334729.10000000003 4103548.5)

Another example of a strange behavor is running this code:

SELECT ST_AsText(ST_SnapToGrid(
    ST_GeomFromText('LINESTRING(334729.13 4103548.88,334729.12 4103548.53)'),
    0.001)
);

results in:

LINESTRING(334729.13 4103548.88,334729.12 4103548.5300000003)

Can anyone help?

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.