GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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  */
31 int get_mapatt(typbuff * buff, int offset, float *att)
32 {
33  if (buff->nm) {
34  if (BM_get
35  (buff->nm, (offset % buff->nm->cols),
36  (offset / buff->nm->cols))) {
37  return (0);
38  }
39  }
40 
41  *att = (buff->ib ? (float)buff->ib[offset] :
42  buff->sb ? (float)buff->sb[offset] :
43  buff->cb ? (float)buff->cb[offset] :
44  buff->fb ? (float)buff->fb[offset] : buff->k);
45 
46  if (buff->tfunc) {
47  *att = (buff->tfunc) (*att, offset);
48  }
49 
50  return (1);
51 }
short * sb
Definition: ogsf.h:208
float k
Definition: ogsf.h:213
int * ib
Definition: ogsf.h:207
int get_mapatt(typbuff *buff, int offset, float *att)
Get map attributes.
Definition: gsget.c:31
int BM_get(struct BM *, int, int)
Gets &#39;val&#39; from the bitmap.
Definition: bitmap.c:220
float(* tfunc)(float, int)
Definition: ogsf.h:212
int cols
Definition: bitmap.h:20
Definition: ogsf.h:204
struct BM * nm
Definition: ogsf.h:211
float * fb
Definition: ogsf.h:206
unsigned char * cb
Definition: ogsf.h:209