GRASS GIS 7 Programmer's Manual  7.0.2(2015)-r00000
gvl3.c
Go to the documentation of this file.
1 
19 #include <grass/gis.h>
20 #include <grass/raster.h>
21 #include <grass/raster3d.h>
22 #include <grass/ogsf.h>
23 #include <grass/glocale.h>
24 
34 int Gvl_load_colors_data(void **color_data, const char *name)
35 {
36  const char *mapset;
37  struct Colors *colors;
38 
39  if (NULL == (mapset = G_find_raster3d(name, ""))) {
40  G_warning(_("3D raster map <%s> not found"), name);
41  return (-1);
42  }
43 
44  if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))
45  return (-1);
46 
47  if (0 > Rast3d_read_colors(name, mapset, colors)) {
48  G_free(colors);
49  return (-1);
50  }
51 
52  *color_data = colors;
53 
54  return (1);
55 }
56 
65 int Gvl_unload_colors_data(void *color_data)
66 {
67  Rast_free_colors(color_data);
68 
69  G_free(color_data);
70 
71  return (1);
72 }
73 
82 int Gvl_get_color_for_value(void *color_data, float *value)
83 {
84  int r, g, b;
85 
86  Rast_get_f_color((FCELL *) value, &r, &g, &b, color_data);
87  return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
88 }
int Gvl_unload_colors_data(void *color_data)
Unload color table.
Definition: gvl3.c:65
#define NULL
Definition: ccmath.h:32
double b
int Gvl_get_color_for_value(void *color_data, float *value)
Get color for value.
Definition: gvl3.c:82
int Gvl_load_colors_data(void **color_data, const char *name)
Load color table.
Definition: gvl3.c:34
float g
Definition: named_colr.c:8
const char * G_find_raster3d(const char *name, const char *mapset)
Search for a 3D raster map in current search path or in a specified mapset.
Definition: find_rast3d.c:28
const char * name
Definition: named_colr.c:7
double r
void G_free(void *buf)
Free allocated memory.
Definition: alloc.c:149
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: gis/error.c:203