Opened 10 years ago

Closed 6 years ago

#2515 closed task (invalid)

d.rast: multiple calling G_find_raster2()

Reported by: martinl Owned by: grass-dev@…
Priority: minor Milestone: 7.2.4
Component: Default Version: svn-trunk
Keywords: d.rast, G_find_raster Cc:
CPU: Unspecified Platform: Unspecified

Description

When rendering raster data using d.rast the function G_find_raster2() is called multiple times, this could be probably reduced... ???

D1/1: Cairo_Set_window: 0.000000 480.000000 0.000000 640.000000
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster(): name=dmt mapset=
D1/1: G_find_raster(): name=MASK mapset=pg
D1/1: Cairo_Set_window: 0.000000 480.000000 0.000000 640.000000
D1/1: Cairo_Set_window: 0.000000 480.000000 80.000000 560.000000
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster2(): name=dmt mapset=PERMANENT
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster2(): name=dmt mapset=PERMANENT
D1/1: G_find_raster2(): name=dmt mapset=
D1/1: G_find_raster2(): name=dmt mapset=PERMANENT
D1/1: G_find_raster(): name=MASK mapset=pg

Change History (8)

in reply to:  description comment:1 by glynn, 10 years ago

Replying to 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;
}

comment:2 by neteler, 9 years ago

Milestone: 7.1.07.2.0

Milestone renamed

comment:3 by neteler, 8 years ago

Milestone: 7.2.07.2.1

Ticket retargeted after milestone closed

comment:4 by martinl, 8 years ago

Milestone: 7.2.17.2.2

comment:5 by neteler, 7 years ago

Milestone: 7.2.27.2.3

Ticket retargeted after milestone closed

comment:6 by martinl, 7 years ago

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:7 by martinl, 7 years ago

Milestone: 7.2.4

comment:8 by martinl, 6 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.