[GRASS-dev] [GRASS GIS] #335: export floats and doubles with correct precision

GRASS GIS trac at osgeo.org
Tue Oct 14 01:35:06 EDT 2008


#335: export floats and doubles with correct precision
-------------------------+--------------------------------------------------
 Reporter:  hamish       |       Owner:  grass-dev at lists.osgeo.org
     Type:  task         |      Status:  new                      
 Priority:  minor        |   Milestone:  6.4.0                    
Component:  default      |     Version:  unspecified              
 Keywords:  precision    |    Platform:  Unspecified              
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------
 see  http://thread.gmane.org/gmane.comp.gis.grass.devel/29622/

 this started with lib/db/dbmi_base/valuefmt.c  %lf -> %.15g

 High priority:
 r.what, r.univar sum_str, r.info's fancy report min= max=, and r.colors.
 Also 'g.region -g' -> lib/gis/wind_format.c:

 {{{
 static int format_double(double value, char *buf)
 {
     sprintf(buf, "%.8f", value);
     G_trim_decimal(buf);

     return 0;
 }
 }}}

 I notice that raster/r.mapcalc/expression.c uses %.8g for a double.


 for lat/lon, %.8f is approx 1mm (1852*60*1e-8; ie better than RTK GPS),
 for meter/feet based units it's very very small.



 I guess we may as well to do this properly, i.e. split off FCELL values to
 something less precise ( %.6g,  %f,  ? ).
 Maybe new G_format_double() and G_format_float() fns for that?


 {{{
 $ svngrep -r '%\.[1-9][0-9][fg]' * | cut -f1 -d: | uniq

 display/d.rast.edit/edit.c
 display/d.zoom/set.c
 general/g.setproj/main.c
 general/g.setproj/get_num.c
 general/g.setproj/get_deg.c
 lib/proj/convert.c
 lib/proj/get_proj.c
 lib/vector/rtree/gammavol.c
 lib/vector/Vlib/intersect.c
 lib/gis/quant_io.c
 lib/gis/gislib.dox
 lib/gis/proj3.c
 lib/gis/color_write.c
 lib/gis/cats.c
 lib/g3d/g3dkeys.c
 lib/g3d/writeascii.c
 lib/g3d/filecompare.c
 lib/g3d/g3dcats.c
 lib/db/dbmi_base/datetime.c
 lib/db/dbmi_base/valuefmt.c
 ps/ps.map/ps_fclrtbl.c
 raster/r.colors/rules.c
 raster/r.stats/raw_stats.c
 raster/r.univar2/stats.c
 raster/r.reclass/main.c
 raster/r.recode/read_rules.c
 raster/r.info/main.c
 raster/r.quant/read_rules.c
 raster/r.distance/report.c
 raster/r.cats/main.c
 raster/r.external/main.c
 raster/r.what/main.c
 raster/r.statistics/o_average.c
 raster/r.average/main.c
 scripts/r.in.srtm/r.in.srtm
 vector/v.to.points/main.c
 vector/v.segment/main.c
 vector/v.label.sa/main.c
 vector/v.what.rast/main.c
 vector/v.to.db/update.c
 vector/v.to.db/report.c
 vector/v.kernel/main.c
 vector/v.in.ascii/points.c
 }}}


 the list is long and manual review is needed for each one.


 Hamish

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/335>
GRASS GIS <http://grass.osgeo.org>


More information about the grass-dev mailing list