[GRASS-dev] from v6 to v7: G_get_cellhd -> Rast_get_cellhd ?

Yann Chemin yann.chemin at gmail.com
Wed Oct 13 00:14:22 EDT 2010


Hello list,

some confusion you may clarify.

Looking into some v6 to v7 coding translation, how would you test for
readability of raster cell header in v7

<from grass-addons: i.landsat.toar>

	    mapset = G_find_cell2(band_in, "");
	    if (mapset == NULL) {
		G_warning(_("Raster map <%s> not found"), band_in);
		continue;
	    }
	    if ((infd = G_open_cell_old(band_in, mapset)) < 0)
		G_fatal_error(_("Unable to open raster map <%s>"), band_in);
	    if (G_get_cellhd(band_in, mapset, &cellhd) < 0)
		G_fatal_error(_("Unable to read header of raster map <%s>"), band_in);
	    if (G_set_window(&cellhd) < 0)
		G_fatal_error(_("Cannot reset current region"));

The Last 4 lines I am trying to see if Rast_get_cellhd should be used...

            if (Rast_get_cellhd(band_in, "", &cellhd) < 0)
                G_fatal_error(_("Unable to read header of raster map
<%s>"), band_in);
            if (G_set_window(&cellhd) < 0)
                G_fatal_error(_("Cannot reset current region"));

These 4 lines above are returning errors because the two functions
Rast_get_cellhd and G_set_window both return void, and they are tested
for a return value.

How would you rewrite that initial code within version 7?
Thank you,
Yann

-- 
Yann Chemin
Senior Spatial Hydrologist
www.csu.edu.au/research/icwater
M +61-4-3740 7019


More information about the grass-dev mailing list