[GRASS-dev] [GRASS GIS] #1405: [PATCH] Direct floating point values comparison in r.terraflow

GRASS GIS trac at osgeo.org
Mon Jul 18 09:15:26 EDT 2011


#1405: [PATCH] Direct floating point values comparison in r.terraflow
-------------------------+--------------------------------------------------
 Reporter:  dron         |       Owner:  grass-dev@…              
     Type:  defect       |      Status:  new                      
 Priority:  normal       |   Milestone:                           
Component:  Raster       |     Version:  svn-trunk                
 Keywords:  r.terraflow  |    Platform:  Unspecified              
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------
 r.terraflow module does direct comparison of two floating point values.
 This is wrong and results in emergency exit with "cell file resolution
 differs from current region" message. There is a trivial patch fixing
 that:

 {{{
 --- main.cc     (revision 47154)
 +++ main.cc     (working copy)
 @@ -216,8 +216,8 @@
      G_fatal_error(_("Cannot read header of [%s]"), cellname);

    /* check compatibility with module region */
 -  if (!((region->ew_res == cell_hd.ew_res)
 -               && (region->ns_res == cell_hd.ns_res))) {
 +  if (!(fabs(region->ew_res - cell_hd.ew_res) < 0.0000001
 +               && fabs(region->ns_res - cell_hd.ns_res) < 0.0000001)) {
      G_fatal_error(_("cell file %s resolution differs from current
 region"),
                                   cellname);
    } else {
 }}}

 Applicable for 6.4, 6.5 and 7.0 branches.

 Best regards,[[BR]]
 Andrey

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



More information about the grass-dev mailing list