<div dir="ltr">Hi,<div><br></div><div>your issue is not with ST_SnapToGrid but with floating point precision. There is no floating point number that represents 44.0588 exactly, instead it might be represented by the binary 0x40460786c226809e, which, when transformed into text, returns the exact result 44.058800000000005.</div><div><br></div><div>If you want a max number of digits in your output, you should consider using ST_AsText(geometry, precision), in your case using a precision of 4. That does enforce a maximum number of decimal digits on the output.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 14, 2020 at 5:25 PM Alexandre Neto <<a href="mailto:senhor.neto@gmail.com">senhor.neto@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="ltr">Hi,<br><div><br></div><div>I am using st_snaptogrid to reduce the number of relevant decimals places in a linetringZ geometry. </div><div><br></div><div>I am using variant 4, where I give also an origin geometry, which was set to 0,0,0,0</div><div><br></div><div>SELECT st_snaptogrid(geometria, st_makepoint(0,0,0,0), 0.0001, 0.0001, 0.0001, 0) as geom<br>FROM seg_via_rodov<br></div><div><br></div><div>Here's an example:<br><br>SELECT st_astext(geometria)<br>from seg_via_rodov<br>LIMIT 1<br></div><div><br></div><div>st_astext                                                                                                                                                                                                                                                      |<br>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|<br>LINESTRING Z (-30237.8998031556 267117.061188696 44.1488024536882,-30236.3648673971 267121.174528336 44.1488024536882,-30234.8299319437 267125.287868282 44.1488024536882,-30233.1869835505 267129.149672231 44.1233890804773,-30231.2234287545 267132.86408063|<br></div><div><br></div><div><br></div><div>SELECT st_snaptogrid(geometria, st_makepoint(0,0,0,0), 0.0001, 0.0001, 0.0001, 0) as geom<br>FROM seg_via_rodov<br>LIMIT 1<br></div><div><br></div><div>geom                                                                                                                                                                                                                                                           |<br>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|<br>LINESTRING(-30237.899800000003 267117.0612 44.1488,-30236.3649 267121.1745 44.1488,-30234.8299 267125.2879 44.1488,-30233.187 267129.1497 44.123400000000004,-30231.223400000003 267132.8641 44.058800000000005,-30228.5936 267137.1744 43.9301,-30225.93810000|<br></div><div><br></div><div><br></div><div dir="auto">I found this old bug report, but I wonder if there's a workaround for it.</div><div dir="auto"><br></div><div dir="auto"><a href="https://trac.osgeo.org/postgis/ticket/3929" target="_blank">https://trac.osgeo.org/postgis/ticket/3929</a><br></div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto"><br></div><div dir="auto">Alexandre Neto</div><div><br></div></div></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Raúl Marín Rodríguez<br><a href="http://carto.com" target="_blank">carto.com</a></div>