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