[postgis-tickets] [PostGIS] #5520: ST_ReducePrecision not rounding coordinates as expected

PostGIS trac at osgeo.org
Fri Sep 8 13:35:49 PDT 2023


#5520: ST_ReducePrecision not rounding coordinates as expected
-----------------------+---------------------------
  Reporter:  andre286  |      Owner:  pramsey
      Type:  defect    |     Status:  new
  Priority:  high      |  Milestone:  PostGIS 3.4.1
 Component:  postgis   |    Version:  3.4.x
Resolution:            |   Keywords:
-----------------------+---------------------------
Comment (by mdavis):

 The failure to round appropriately is caused by the use of a decimal value
 as the gridSize (`0.001`).  This can be reproduced in GEOS using:
 {{{
 bin/geosop -a "LINESTRING (657035.913 6475590.114,657075.57 6475500)"
 reducePrecision N-0.001

 LINESTRING (657035.9130000001 6475590.114, 657075.5700000001 6475500)
 }}}
 GEOS also supports using a scale factor rather than a gridSize, which
 allows using an integer argument.  This produces more accurate rounding:
 {{{
 bin/geosop -a "LINESTRING (657035.913 6475590.114,657075.57 6475500)"
 reducePrecision 1000

 LINESTRING (657035.913 6475590.114, 657075.57 6475500)
 }}}
 Unfortunately this isn't exposed in PostGIS. Perhaps it could be provided
 as an alternative (say by using the "negative number" trick?)
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5520#comment:3>
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