Skip to content

Commit 1e66aa7

Browse files
author
rblazek
committedFeb 5, 2010
get null outside map
git-svn-id: http://svn.osgeo.org/qgis/trunk@12888 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e363dbf commit 1e66aa7

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed
 

‎src/providers/grass/qgis.g.info.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,36 @@ int main(int argc, char **argv)
101101
if (col == window.cols) col--;
102102
if (row == window.rows) row--;
103103

104-
rast_type = G_get_raster_map_type(fd);
105-
cell = G_allocate_c_raster_buf();
106-
dcell = G_allocate_d_raster_buf();
107-
108-
if (rast_type == CELL_TYPE)
104+
if ( col < 0 || col > window.cols || row < 0 || row > window.rows )
109105
{
110-
if (G_get_c_raster_row(fd, cell, row) < 0)
111-
{
112-
G_fatal_error(("Unable to read raster map <%s> row %d"),
113-
rast_opt->answer, row);
114-
}
115-
fprintf (stdout, "value:%d\n", cell[col] );
116-
}
106+
fprintf (stdout, "value:null\n");
107+
}
117108
else
118-
{
119-
if (G_get_d_raster_row(fd, dcell, row) < 0)
109+
{
110+
rast_type = G_get_raster_map_type(fd);
111+
cell = G_allocate_c_raster_buf();
112+
dcell = G_allocate_d_raster_buf();
113+
114+
if (rast_type == CELL_TYPE)
120115
{
121-
G_fatal_error(("Unable to read raster map <%s> row %d"),
122-
rast_opt->answer, row);
116+
if (G_get_c_raster_row(fd, cell, row) < 0)
117+
{
118+
G_fatal_error(("Unable to read raster map <%s> row %d"),
119+
rast_opt->answer, row);
120+
}
121+
fprintf (stdout, "value:%d\n", cell[col] );
122+
}
123+
else
124+
{
125+
if (G_get_d_raster_row(fd, dcell, row) < 0)
126+
{
127+
G_fatal_error(("Unable to read raster map <%s> row %d"),
128+
rast_opt->answer, row);
129+
}
130+
fprintf (stdout, "value:%f\n", dcell[col] );
123131
}
124-
fprintf (stdout, "value:%f\n", dcell[col] );
125132
}
133+
G_close_cell( fd );
126134
}
127135
else if ( vect_opt->answer )
128136
{

0 commit comments

Comments
 (0)