[GRASS-dev] [GRASS GIS] #2770: r.mapcalc reports syntax error for valid script but no error for separate expressions

GRASS GIS trac at osgeo.org
Tue Oct 20 06:23:16 PDT 2015


#2770: r.mapcalc reports syntax error for valid script but no error for separate
expressions
-------------------------+-------------------------
 Reporter:  marisn       |      Owner:  grass-dev@…
     Type:  defect       |     Status:  new
 Priority:  normal       |  Milestone:
Component:  Raster       |    Version:  svn-trunk
 Keywords:  r.mapcalc    |        CPU:  Unspecified
 Platform:  Unspecified  |
-------------------------+-------------------------
 Seems that r.mapcalc doesn't like some sequences of valid expressions.
 Following examples show the same expressions copy/pasted into interactive
 r.mapcalc session all together and one by one. Notice - same syntax once
 causes "syntax error" but no "syntax error" is generated if execution
 happens to be performed on a separate r.mapcalc process.
 {{{
 r.mapcalc --overwrite
 Enter expressions, "end" when done.
 mapcalc> speed_up = if(speed < 5, speed + 1, speed)
 mapcalc> max_speed = if( !isnull(speed[0,1]), 0,\
 mapcalc>             if( !isnull(speed[0,2]), 1,\
 mapcalc>             if( !isnull(speed[0,3]), 2,\
 mapcalc>             if( !isnull(speed[0,4]), 3,\
 mapcalc>             if( !isnull(speed[0,5]), 4, 5)))))
 mapcalc> res_speed = if(speed_up > max_speed, max_speed, speed_up)
 mapcalc> moved = if( res_speed[0, 0] == 0, 0,\
 syntax error, unexpected '[', expecting ')'
 mapcalc>         if( res_speed[0,-1] == 1, 1,\
 mapcalc>         if( res_speed[0,-2] == 2, 2,\
 mapcalc>         if( res_speed[0,-3] == 3, 3,\
 mapcalc>         if( res_speed[0,-4] == 4, 4,\
 mapcalc>         if( res_speed[0,-5] == 5, 5, null()))))))
 mapcalc> end
 Parse error

 }}}

 {{{
 r.mapcalc --overwrite
 Enter expressions, "end" when done.
 mapcalc> speed_up = if(speed < 5, speed + 1, speed)
 mapcalc> end

  100%
 GRASS 7.1.svn (xy_loc):~/soft/grass_trunk > r.mapcalc --overwrite
 Enter expressions, "end" when done.
 mapcalc> max_speed = if( !isnull(speed[0,1]), 0,\
 mapcalc>             if( !isnull(speed[0,2]), 1,\
 mapcalc>             if( !isnull(speed[0,3]), 2,\
 mapcalc>             if( !isnull(speed[0,4]), 3,\
 mapcalc>             if( !isnull(speed[0,5]), 4, 5)))))
 mapcalc> end

  100%
 GRASS 7.1.svn (xy_loc):~/soft/grass_trunk > r.mapcalc --overwrite
 Enter expressions, "end" when done.
 mapcalc> res_speed = if(speed_up > max_speed, max_speed, speed_up)
 mapcalc> end

  100%
 GRASS 7.1.svn (xy_loc):~/soft/grass_trunk > r.mapcalc --overwrite
 Enter expressions, "end" when done.
 mapcalc> moved = if( res_speed[0, 0] == 0, 0,\
 mapcalc>         if( res_speed[0,-1] == 1, 1,\
 mapcalc>         if( res_speed[0,-2] == 2, 2,\
 mapcalc>         if( res_speed[0,-3] == 3, 3,\
 mapcalc>         if( res_speed[0,-4] == 4, 4,\
 mapcalc>         if( res_speed[0,-5] == 5, 5, null()))))))
 mapcalc> end

  100%
 }}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2770>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list