GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
Loading...
Searching...
No Matches
resample.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <grass/gis.h>
3#include "raster3d_intern.h"
4
5/*--------------------------------------------------------------------------*/
6
7/*!
8 * \brief
9 *
10 * The default resampling function which uses nearest
11 * neighbor resampling. This method converts the window coordinates
12 * x, y, and z into region coordinates and returned the nearest neighbor.
13 *
14 * \param map
15 * \param x
16 * \param y
17 * \param z
18 * \param value
19 * \param type
20 * \return void
21 */
22void Rast3d_nearest_neighbor(RASTER3D_Map *map, int x, int y, int z,
23 void *value, int type)
24{
25 double north, east, top;
26 int row, col, depth;
27
28 /* convert (x, y, z) window coordinates into (north, east, top) */
29 Rast3d_coord2location(&(map->window), (double)x + 0.5, (double)y + 0.5,
30 (double)z + 0.5, &north, &east, &top);
31
32 /* convert (north, east, top) into map region coordinates (row, col, depth)
33 */
34 Rast3d_location2coord(&(map->region), north, east, top, &col, &row, &depth);
35
36 /* Get the value from the map in map-region resolution */
37 Rast3d_get_value_region(map, col, row, depth, value, type);
38}
39
40/*--------------------------------------------------------------------------*/
41
42/*!
43 * \brief
44 *
45 * Sets the resampling function to be used by
46 * Rast3d_get_value () (cf.{g3d:G3d.getValue}). This function is defined
47 * as follows:
48 * \param map
49 * \param resampleFun
50 * \return void
51 */
53 void (*resampleFun)(RASTER3D_Map *, int, int,
54 int, void *, int))
55{
56 map->resampleFun = resampleFun;
57}
58
59/*--------------------------------------------------------------------------*/
60
61/*!
62 * \brief
63 *
64 *
65 * Returns in <em>resampleFun</em> a pointer to the resampling function used by
66 * <em>map</em>.
67 *
68 * \return void
69 */
71 void (**resampleFun)(RASTER3D_Map *, int, int,
72 int, void *, int))
73{
74 *resampleFun = map->resampleFun;
75}
76
77/*--------------------------------------------------------------------------*/
78
79/*!
80 * \brief
81 *
82 * Returns
83 * in <em>nnFunPtr</em> a pointer to Rast3d_nearest_neighbor ()
84 * (cf.{g3d:G3d.nearestNeighbor}).
85 *
86 * \return void
87 */
89 int, int, void *,
90 int))
91{
93}
void Rast3d_location2coord(RASTER3D_Region *, double, double, double, int *, int *, int *)
Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).
Definition region.c:275
void Rast3d_get_value_region(RASTER3D_Map *, int, int, int, void *, int)
Returns in *value the cell-value of the cell with region-coordinate (x, y, z). The value returned is ...
Definition getvalue.c:249
void Rast3d_coord2location(RASTER3D_Region *, double, double, double, double *, double *, double *)
Converts cell-coordinates (x, y, z) into region-coordinates (north, east, top).
Definition region.c:374
void Rast3d_set_resampling_fun(RASTER3D_Map *map, void(*resampleFun)(RASTER3D_Map *, int, int, int, void *, int))
Sets the resampling function to be used by Rast3d_get_value () (cf.{g3d:G3d.getValue})....
Definition resample.c:52
void Rast3d_get_nearest_neighbor_fun_ptr(void(**nnFunPtr)(RASTER3D_Map *, int, int, int, void *, int))
Returns in nnFunPtr a pointer to Rast3d_nearest_neighbor () (cf.{g3d:G3d.nearestNeighbor}).
Definition resample.c:88
void Rast3d_nearest_neighbor(RASTER3D_Map *map, int x, int y, int z, void *value, int type)
The default resampling function which uses nearest neighbor resampling. This method converts the wind...
Definition resample.c:22
void Rast3d_get_resampling_fun(RASTER3D_Map *map, void(**resampleFun)(RASTER3D_Map *, int, int, int, void *, int))
Returns in resampleFun a pointer to the resampling function used by map.
Definition resample.c:70
resample_fn * resampleFun
Definition raster3d.h:88
RASTER3D_Region window
Definition raster3d.h:85
RASTER3D_Region region
Definition raster3d.h:82
#define x