gsget.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*!
  2. \file lib/ogsf/gsget.c
  3. \brief OGSF library - get map attribute (lower level functions)
  4. GRASS OpenGL gsurf OGSF Library
  5. (C) 1999-2008 by the GRASS Development Team
  6. This program is free software under the
  7. GNU General Public License (>=v2).
  8. Read the file COPYING that comes with GRASS
  9. for details.
  10. \author Bill Brown USACERL (January 1993)
  11. \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
  12. */
  13. #include <grass/ogsf.h>
  14. /*!
  15. \brief Get map attributes
  16. \param buff
  17. \param offset
  18. \param[out] att
  19. \return 0 on failure
  20. \return 1 on success
  21. */
  22. int get_mapatt(typbuff * buff, int offset, float *att)
  23. {
  24. if (buff->nm) {
  25. if (BM_get
  26. (buff->nm, (offset % buff->nm->cols),
  27. (offset / buff->nm->cols))) {
  28. return (0);
  29. }
  30. }
  31. *att = (buff->ib ? (float)buff->ib[offset] :
  32. buff->sb ? (float)buff->sb[offset] :
  33. buff->cb ? (float)buff->cb[offset] :
  34. buff->fb ? (float)buff->fb[offset] : buff->k);
  35. if (buff->tfunc) {
  36. *att = (buff->tfunc) (*att, offset);
  37. }
  38. return (1);
  39. }