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);
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);
DCELL G_get_raster_sample_nearest(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc)
DCELL G_interp_bicubic(double u, double v, DCELL c00, DCELL c01, DCELL c02, DCELL c03, DCELL c10, DCELL c11, DCELL c12, DCELL c13, DCELL c20, DCELL c21, DCELL c22, DCELL c23, DCELL c30, DCELL c31, DCELL c32, DCELL c33)
int G_get_d_raster_row(int fd, DCELL *buf, int row)
Get raster row (DCELL type)
void G_free(void *buf)
Free allocated memory.
double G_easting_to_col(double east, const struct Cell_head *window)
Easting to column.
void G_set_d_null_value(DCELL *dcellVals, int numVals)
DCELL G_get_raster_sample_bilinear(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc)
DCELL G_interp_bilinear(double u, double v, DCELL c00, DCELL c01, DCELL c10, DCELL c11)
DCELL G_get_raster_sample_cubic(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc)
char * G_get_cat(CELL num, struct Categories *pcats)
get a category label
int G_is_d_null_value(const DCELL *dcellVal)
Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in G_is_f_null_value().
int G_window_cols(void)
Number of columns in active window.
DCELL G_get_raster_sample(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc, INTERP_TYPE itype)
Extract a cell value from raster map.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int G_debug(int level, const char *msg,...)
Print debugging message.
double G_northing_to_row(double north, const struct Cell_head *window)
Northing to row.
char * G_squeeze(char *line)
Remove superfluous white space.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int G_window_rows(void)
Number of rows in active window.
DCELL * G_allocate_d_raster_buf(void)
Allocates memory for a raster map of type DCELL.