[GRASS-dev] [GRASS GIS] #2515: d.rast: multiple calling G_find_raster2()

GRASS GIS trac at osgeo.org
Fri Dec 26 12:03:16 PST 2014


#2515: d.rast: multiple calling G_find_raster2()
-----------------------------------+----------------------------------------
 Reporter:  martinl                |       Owner:  grass-dev@…              
     Type:  task                   |      Status:  new                      
 Priority:  minor                  |   Milestone:  7.1.0                    
Component:  Default                |     Version:  svn-trunk                
 Keywords:  d.rast, G_find_raster  |    Platform:  Unspecified              
      Cpu:  Unspecified            |  
-----------------------------------+----------------------------------------

Comment(by glynn):

 Replying to [ticket:2515 martinl]:
 > When rendering raster data using `d.rast` the function
 `G_find_raster2()` is called multiple times, this could be probably
 reduced... ???

 Maybe. Although most of this isn't specific to d.rast, but applies to any
 module which accesses raster maps. Most lib/raster functions which take a
 map name as an argument end up calling G_find_raster2().

 Taking d.rast as an example, setting a breakpoint on G_find_raster2()
 shows:

 {{{
 #0  G_find_raster2 () at find_rast.c:78
 #1 Rast_map_is_fp () at open.c:742
 #2 main () at main.c:100

 #0  G_find_raster2 () at find_rast.c:78
 #1 Rast_map_is_fp () at open.c:742
 #2 Rast_read_colors () at color_read.c:67
 #3 display () at display.c:22
 #4 main () at main.c:109

 #0  G_find_raster2 () at find_rast.c:78
 #1 Rast__open_old () at open.c:174
 #2 Rast_open_old () at open.c:113
 #3 cell_draw () at display.c:59
 #4 display () at display.c:34
 #5 main () at main.c:109

 #0  G_find_raster2 () at find_rast.c:78
 #1 Rast_map_type () at open.c:775
 #2 Rast__open_old () at open.c:204
 #3 Rast_open_old () at open.c:113
 #4 cell_draw () at display.c:59
 #5 display () at display.c:34
 #6 main () at main.c:109

 #0  G_find_raster2 () at find_rast.c:78
 #1 Rast_get_gdal_link () at gdal.c:251
 #2 Rast__open_old () at open.c:251
 #3 Rast_open_old () at open.c:113
 #4 cell_draw () at display.c:59
 #5 display () at display.c:34
 #6 main () at main.c:109

 #0  G_find_raster2 () at find_rast.c:78
 #1 Rast_map_type () at open.c:775
 #2 Rast_get_gdal_link () at gdal.c:254
 #3 Rast__open_old () at open.c:251
 #4 Rast_open_old () at open.c:113
 #5 cell_draw () at display.c:59
 #6 display () at display.c:34
 #7 main () at main.c:109
 }}}

 Six calls, of which one is from Rast_map_is_fp(), one from
 Rast_read_colors() (via Rast_map_is_fp()), and the other four from
 Rast_open_old().

 Some of those could be eliminated. E.g. Rast_get_gdal_link() could
 probably skip the explicit G_find_raster2() call and move the
 Rast_map_type() call to after the G_fopen_old_misc() call (i.e. the check
 for whether the map is actually GDAL-linked).

 A more general solution would be to replace the use of (name, mapset) with
 a map handle ("fd"). This would require opening maps earlier, but would
 allow information to be retrieved from the fileinfo structure. E.g. calls
 to Rast_map_type() could be replaced with Rast_get_map_type(), which is
 just:
 {{{
 RASTER_MAP_TYPE Rast_get_map_type(int fd)
 {
     struct fileinfo *fcb = &R__.fileinfo[fd];

     return fcb->map_type;
 }
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2515#comment:1>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list