[postgis-tickets] [PostGIS] #3929: Unexpected rounding from ST_SnapToGrid
PostGIS
trac at osgeo.org
Sat Dec 2 00:57:28 PST 2017
#3929: Unexpected rounding from ST_SnapToGrid
-----------------------+---------------------------
Reporter: michaudm | Owner: pramsey
Type: defect | Status: closed
Priority: medium | Milestone: PostGIS 2.4.2
Component: postgis | Version: 2.4.x
Resolution: wontfix | Keywords:
-----------------------+---------------------------
Comment (by michaudm):
Hi Paul,
I'm not a C programmer so I don't know if the problem can be solved in
Geos/PostGIS, but in java,
{{{
rint(311.4/0.1)*0.1 -> 311.40000000000003
}}}
while
{{{
round(311.4/0.1)*0.1 -> 311.4
}}}
If I use rint, I obtain exactly the same result as in your example while
with round, I get correct result.
Moreover, I noticed the following comment in the makePrecise method of JTS
code :
{{{
if (modelType == FIXED) {
return Math.round(val * scale) / scale;
// return Math.rint(val * scale) / scale;
}
}}}
Not sure how to interpret these results as I'm not a IEEE double precision
expert, but maybe there is something to do, especially if it makes JTS and
Geos behaviour closer.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3929#comment:2>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list