~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/gis/color_range.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <math.h>
2
 
#include <grass/gis.h>
3
 
 
4
 
int G_set_color_range(CELL min, CELL max, struct Colors *colors)
5
 
{
6
 
    if (min < max) {
7
 
        colors->cmin = (DCELL) min;
8
 
        colors->cmax = (DCELL) max;
9
 
    }
10
 
    else {
11
 
        colors->cmin = (DCELL) max;
12
 
        colors->cmax = (DCELL) min;
13
 
    }
14
 
 
15
 
    return 0;
16
 
}
17
 
 
18
 
int G_set_d_color_range(DCELL min, DCELL max, struct Colors *colors)
19
 
{
20
 
    if (min < max) {
21
 
        colors->cmin = min;
22
 
        colors->cmax = max;
23
 
    }
24
 
    else {
25
 
        colors->cmin = max;
26
 
        colors->cmax = min;
27
 
    }
28
 
 
29
 
    return 0;
30
 
}
31
 
 
32
 
/* returns min and max category in the range or huge numbers
33
 
   if the co,lor table is defined on floating cell values and
34
 
   not on categories */
35
 
 
36
 
 
37
 
/*!
38
 
 * \brief
39
 
 *
40
 
 *  \param G_get_color_range
41
 
 *  \return int
42
 
 */
43
 
 
44
 
int G_get_color_range(CELL * min, CELL * max, const struct Colors *colors)
45
 
{
46
 
    if (!colors->is_float) {
47
 
        *min = (CELL) floor(colors->cmin);
48
 
        *max = (CELL) ceil(colors->cmax);
49
 
    }
50
 
    else {
51
 
        *min = -255 * 255 * 255;
52
 
        *max = 255 * 255 * 255;
53
 
    }
54
 
 
55
 
    return 0;
56
 
}
57
 
 
58
 
/* returns min and max values in the range */
59
 
int G_get_d_color_range(DCELL * min, DCELL * max, const struct Colors *colors)
60
 
{
61
 
    *min = colors->cmin;
62
 
    *max = colors->cmax;
63
 
 
64
 
    return 0;
65
 
}