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

« back to all changes in this revision

Viewing changes to raster/r.li/r.li.mpa/mpa.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:
15
15
 *
16
16
 *****************************************************************************/
17
17
 
18
 
#include <grass/gis.h>
19
 
#include <grass/glocale.h>
20
 
 
21
18
#include <stdlib.h>
22
19
#include <fcntl.h>
23
20
#include <math.h>
24
21
 
 
22
#include <grass/gis.h>
 
23
#include <grass/raster.h>
 
24
#include <grass/glocale.h>
25
25
 
26
26
#include "../r.li.daemon/defs.h"
27
27
#include "../r.li.daemon/daemon.h"
40
40
    module = G_define_module();
41
41
    module->description =
42
42
        _("Calculates mean pixel attribute index on a raster map");
43
 
    module->keywords = _("raster, landscape structure analysis, patch index");
 
43
    G_add_keyword(_("raster"));
 
44
    G_add_keyword(_("landscape structure analysis"));
 
45
    G_add_keyword(_("patch index"));
44
46
    /* define options */
45
47
 
46
 
    raster = G_define_standard_option(G_OPT_R_MAP);
 
48
    raster = G_define_standard_option(G_OPT_R_INPUT);
47
49
 
48
50
    conf = G_define_standard_option(G_OPT_F_INPUT);
49
 
    conf->key = "conf";
 
51
    conf->key = "config";
50
52
    conf->description = _("Configuration file");
51
53
    conf->required = YES;
52
54
 
136
138
 
137
139
        for (i = 0; i < ad->cl; i++) {
138
140
            if (masked && mask_buf[i] == 0) {
139
 
                G_set_c_null_value(&buf[i + ad->x], 1);
 
141
                Rast_set_c_null_value(&buf[i + ad->x], 1);
140
142
            }
141
 
            if (!(G_is_c_null_value(&buf[i + ad->x]))) {
 
143
            if (!(Rast_is_c_null_value(&buf[i + ad->x]))) {
142
144
                area++;
143
145
                somma = somma + buf[i + ad->x];
144
146
            }
148
150
    if (area > 0)
149
151
        *result = somma / area;
150
152
    else
151
 
        G_set_d_null_value(result, 1);
 
153
        Rast_set_d_null_value(result, 1);
152
154
 
153
155
    if (masked) {
154
156
        close(mask_fd);
196
198
 
197
199
        for (i = 0; i < ad->cl; i++) {
198
200
            if (masked && mask_buf[i] == 0) {
199
 
                G_set_d_null_value(&buf[i + ad->x], 1);
 
201
                Rast_set_d_null_value(&buf[i + ad->x], 1);
200
202
            }
201
 
            if (!(G_is_d_null_value(&buf[i + ad->x]))) {
 
203
            if (!(Rast_is_d_null_value(&buf[i + ad->x]))) {
202
204
                area++;
203
205
                somma = somma + buf[i + ad->x];
204
206
            }
208
210
    if (area > 0)
209
211
        *result = somma / area;
210
212
    else
211
 
        G_set_d_null_value(result, 1);
 
213
        Rast_set_d_null_value(result, 1);
212
214
 
213
215
    if (masked) {
214
216
        close(mask_fd);
255
257
 
256
258
        for (i = 0; i < ad->cl; i++) {
257
259
            if (masked && mask_buf[i] == 0) {
258
 
                G_set_f_null_value(&buf[i + ad->x], 1);
 
260
                Rast_set_f_null_value(&buf[i + ad->x], 1);
259
261
            }
260
 
            if (!(G_is_f_null_value(&buf[i + ad->x]))) {
 
262
            if (!(Rast_is_f_null_value(&buf[i + ad->x]))) {
261
263
                area++;
262
264
                somma = somma + buf[i + ad->x];
263
265
            }
267
269
    if (area > 0)
268
270
        *result = somma / area;
269
271
    else
270
 
        G_set_d_null_value(result, 1);
 
272
        Rast_set_d_null_value(result, 1);
271
273
 
272
274
    if (masked) {
273
275
        close(mask_fd);