GRASS Programmer's Manual
6.4.1(2011)
|
00001 #include <math.h> 00002 #include <grass/gis.h> 00003 00004 int G_set_color_range(CELL min, CELL max, struct Colors *colors) 00005 { 00006 if (min < max) { 00007 colors->cmin = (DCELL) min; 00008 colors->cmax = (DCELL) max; 00009 } 00010 else { 00011 colors->cmin = (DCELL) max; 00012 colors->cmax = (DCELL) min; 00013 } 00014 00015 return 0; 00016 } 00017 00018 int G_set_d_color_range(DCELL min, DCELL max, struct Colors *colors) 00019 { 00020 if (min < max) { 00021 colors->cmin = min; 00022 colors->cmax = max; 00023 } 00024 else { 00025 colors->cmin = max; 00026 colors->cmax = min; 00027 } 00028 00029 return 0; 00030 } 00031 00032 /* returns min and max category in the range or huge numbers 00033 if the co,lor table is defined on floating cell values and 00034 not on categories */ 00035 00036 00044 int G_get_color_range(CELL * min, CELL * max, const struct Colors *colors) 00045 { 00046 if (!colors->is_float) { 00047 *min = (CELL) floor(colors->cmin); 00048 *max = (CELL) ceil(colors->cmax); 00049 } 00050 else { 00051 *min = -255 * 255 * 255; 00052 *max = 255 * 255 * 255; 00053 } 00054 00055 return 0; 00056 } 00057 00058 /* returns min and max values in the range */ 00059 int G_get_d_color_range(DCELL * min, DCELL * max, const struct Colors *colors) 00060 { 00061 *min = colors->cmin; 00062 *max = colors->cmax; 00063 00064 return 0; 00065 }