GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
Loading...
Searching...
No Matches
gsget.c
Go to the documentation of this file.
1/*!
2 \file lib/ogsf/gsget.c
3
4 \brief OGSF library - get map attribute (lower level functions)
5
6 GRASS OpenGL gsurf OGSF Library
7
8 (C) 1999-2008 by the GRASS Development Team
9
10 This program is free software under the
11 GNU General Public License (>=v2).
12 Read the file COPYING that comes with GRASS
13 for details.
14
15 \author Bill Brown USACERL (January 1993)
16 \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
17 */
18
19#include <grass/ogsf.h>
20
21/*!
22 \brief Get map attributes
23
24 \param buff
25 \param offset
26 \param[out] att
27
28 \return 0 on failure
29 \return 1 on success
30 */
31int get_mapatt(typbuff *buff, int offset, float *att)
32{
33 if (buff->nm) {
34 if (BM_get(buff->nm, (offset % buff->nm->cols),
35 (offset / buff->nm->cols))) {
36 return (0);
37 }
38 }
39
40 *att = (buff->ib ? (float)buff->ib[offset]
41 : buff->sb ? (float)buff->sb[offset]
42 : buff->cb ? (float)buff->cb[offset]
43 : buff->fb ? (float)buff->fb[offset]
44 : buff->k);
45
46 if (buff->tfunc) {
47 *att = (buff->tfunc)(*att, offset);
48 }
49
50 return (1);
51}
int BM_get(struct BM *map, int x, int y)
Gets 'val' from the bitmap.
Definition bitmap.c:217
int get_mapatt(typbuff *buff, int offset, float *att)
Get map attributes.
Definition gsget.c:31