[postgis-devel] [PostGIS] #2051: ST_AsGeoJSON printing too many digits

PostGIS trac at osgeo.org
Wed Oct 17 01:56:58 PDT 2012


#2051: ST_AsGeoJSON printing too many digits
---------------------+------------------------------------------------------
 Reporter:  strk     |       Owner:  pramsey      
     Type:  defect   |      Status:  new          
 Priority:  medium   |   Milestone:  PostGIS 2.0.2
Component:  postgis  |     Version:  2.0.x        
 Keywords:           |  
---------------------+------------------------------------------------------
 I found that ST_AsGeoJSON is printing more digits than the double number
 can hold, or that's the only explanation I can find for this:

 {{{
 =# with inp as ( SELECT st_snaptogrid('POINT(59.987654321987654321
 -59.987654321987654321)'::geometry, 0.01) as g ) select ST_AsText(g) as
 text, ST_AsGeoJSON(g) as json from inp;
 -[ RECORD 1
 ]-----------------------------------------------------------------
 text | POINT(59.99 -59.99)
 json |
 {"type":"Point","coordinates":[59.990000000000002,-59.990000000000002]}
 }}}

 I understand 0.01 is not a power of 2, but I think being consistent
 between ST_AsText and ST_AsGeoJSON would be nice

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2051>
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-devel mailing list