@@ -101,28 +101,36 @@ int main(int argc, char **argv)
101
101
if (col == window .cols ) col -- ;
102
102
if (row == window .rows ) row -- ;
103
103
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 )
109
105
{
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
+ }
117
108
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 )
120
115
{
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 ] );
123
131
}
124
- fprintf (stdout , "value:%f\n" , dcell [col ] );
125
132
}
133
+ G_close_cell ( fd );
126
134
}
127
135
else if ( vect_opt -> answer )
128
136
{
0 commit comments