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