21 #include <grass/gis.h> 22 #include <grass/raster.h> 23 #include <grass/glocale.h> 26 static double scancatlabel(
const char *);
51 double north,
double east,
70 G_fatal_error(
"Rast_get_sample: %s",
_(
"Unknown interpolation type"));
94 double north,
double east,
int usedesc)
121 result = scancatlabel(buf);
124 result = maprow[col];
151 double north,
double east,
int usedesc)
157 double frow, fcol, trow, tcol;
164 row = (int)floor(frow - 0.5);
165 col = (int)floor(fcol - 0.5);
167 trow = frow - row - 0.5;
168 tcol = fcol - col - 0.5;
197 grid[0][0] = scancatlabel(buf);
199 grid[0][1] = scancatlabel(buf);
201 grid[1][0] = scancatlabel(buf);
203 grid[1][1] = scancatlabel(buf);
206 grid[0][0] = arow[col];
207 grid[0][1] = arow[col + 1];
208 grid[1][0] = brow[col];
209 grid[1][1] = brow[col + 1];
213 grid[0][0], grid[0][1], grid[1][0],
241 double north,
double east,
int usedesc)
246 double frow, fcol, trow, tcol;
249 for (i = 0; i < 4; i++)
256 row = (int)floor(frow - 1.5);
257 col = (int)floor(fcol - 1.5);
259 trow = frow - row - 1.5;
260 tcol = fcol - col - 1.5;
268 for (i = 0; i < 4; i++)
271 for (i = 0; i < 4; i++)
272 for (j = 0; j < 4; j++)
289 for (i = 0; i < 4; i++) {
290 for (j = 0; j < 4; j++) {
294 grid[i][j] = scancatlabel(buf);
299 for (i = 0; i < 4; i++)
300 for (j = 0; j < 4; j++)
301 grid[i][j] = rows[i][col + j];
305 grid[0][0], grid[0][1], grid[0][2],
306 grid[0][3], grid[1][0], grid[1][1],
307 grid[1][2], grid[1][3], grid[2][0],
308 grid[2][1], grid[2][2], grid[2][3],
309 grid[3][0], grid[3][1], grid[3][2],
313 for (i = 0; i < 4; i++)
320 static double scancatlabel(
const char *str)
324 if (strcmp(str,
"no data") != 0)
325 sscanf(str,
"%lf", &val);
327 G_warning(
_(
"\"no data\" label found; setting to zero"));
void G_free(void *buf)
Free allocated memory.
DCELL Rast_get_sample_cubic(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc)
Extract a cell value from raster map (cubic interpolation).
2D/3D raster map header (used also for region)
int Rast_window_rows(void)
Number of rows in active window.
char * Rast_get_c_cat(CELL *rast, struct Categories *pcats)
Get a raster category label (CELL)
DCELL Rast_get_sample_nearest(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc)
Extract a cell value from raster map (neighbor interpolation)
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
DCELL Rast_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)
DCELL Rast_interp_bilinear(double u, double v, DCELL c00, DCELL c01, DCELL c10, DCELL c11)
void Rast_get_d_row(int fd, DCELL *buf, int row)
Get raster row (DCELL type)
void G_squeeze(char *line)
Remove superfluous white space.
int Rast_window_cols(void)
Number of columns in active window.
void Rast_set_d_null_value(DCELL *dcellVals, int numVals)
To set a number of DCELL raster values to NULL.
DCELL * Rast_allocate_d_buf(void)
Allocates memory for a raster map of type DCELL.
double Rast_northing_to_row(double north, const struct Cell_head *window)
Northing to row.
DCELL Rast_get_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.
double Rast_easting_to_col(double east, const struct Cell_head *window)
Easting to column.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int Rast_is_d_null_value(const DCELL *dcellVal)
To check if a DCELL raster value is set to NULL.
DCELL Rast_get_sample_bilinear(int fd, const struct Cell_head *window, struct Categories *cats, double north, double east, int usedesc)
Extract a cell value from raster map (bilinear interpolation).