24 #include <grass/gis.h>
25 #include <grass/glocale.h>
28 static double scancatlabel(
const char *);
29 static void raster_row_error(
const struct Cell_head *
window,
double north,
52 const struct Cell_head *
window,
53 struct Categories *cats,
54 double north,
double east,
55 int usedesc, INTERP_TYPE itype)
71 _(
"Unknown interpolation type"));
80 const struct Cell_head *
window,
81 struct Categories *cats,
82 double north,
double east,
int usedesc)
99 raster_row_error(window, north, east);
107 char *buf =
G_get_cat(maprow[col], cats);
110 result = scancatlabel(buf);
113 result = maprow[col];
124 const struct Cell_head *
window,
125 struct Categories *cats,
126 double north,
double east,
int usedesc)
132 double frow, fcol, trow, tcol;
139 row = (int)floor(frow - 0.5);
140 col = (int)floor(fcol - 0.5);
142 trow = frow - row - 0.5;
143 tcol = fcol - col - 0.5;
152 raster_row_error(window, north, east);
154 raster_row_error(window, north, east);
172 grid[0][0] = scancatlabel(buf);
174 grid[0][1] = scancatlabel(buf);
176 grid[1][0] = scancatlabel(buf);
178 grid[1][1] = scancatlabel(buf);
181 grid[0][0] = arow[col];
182 grid[0][1] = arow[col + 1];
183 grid[1][0] = brow[col];
184 grid[1][1] = brow[col + 1];
188 grid[0][0], grid[0][1], grid[1][0], grid[1][1]);
199 const struct Cell_head *
window,
200 struct Categories *cats,
201 double north,
double east,
int usedesc)
206 double frow, fcol, trow, tcol;
209 for (i = 0; i < 4; i++)
216 row = (int)floor(frow - 1.5);
217 col = (int)floor(fcol - 1.5);
219 trow = frow - row - 1.5;
220 tcol = fcol - col - 1.5;
228 for (i = 0; i < 4; i++)
230 raster_row_error(window, north, east);
232 for (i = 0; i < 4; i++)
233 for (j = 0; j < 4; j++)
250 for (i = 0; i < 4; i++) {
251 for (j = 0; j < 4; j++) {
253 grid[i][j] = scancatlabel(buf);
258 for (i = 0; i < 4; i++)
259 for (j = 0; j < 4; j++)
260 grid[i][j] = rows[i][col + j];
264 grid[0][0], grid[0][1], grid[0][2], grid[0][3],
265 grid[1][0], grid[1][1], grid[1][2], grid[1][3],
266 grid[2][0], grid[2][1], grid[2][2], grid[2][3],
267 grid[3][0], grid[3][1], grid[3][2], grid[3][3]);
270 for (i = 0; i < 4; i++)
277 static double scancatlabel(
const char *str)
281 if (strcmp(str,
"no data") != 0)
282 sscanf(str,
"%lf", &val);
284 G_warning(_(
"\"no data\" label found; setting to zero"));
292 static void raster_row_error(
const struct Cell_head *
window,
double north,
295 G_debug(3,
"DIAG: \tRegion is: n=%g s=%g e=%g w=%g",
296 window->north, window->south, window->east, window->west);
297 G_debug(3,
" \tData point is north=%g east=%g", north, east);