File: fpreclass.c

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (705 lines) | stat: -rw-r--r-- 21,573 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
/**********************************************************************
 *
 *  Rast_fpreclass_init (r)
 *
 *       struct FPReclass *r;
 *
 *  initializes new reclassification structure. calls
 *  Rast_fpreclass_clear() before it returns.
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_reset (r)
 *
 *       struct FPReclass *r;
 *
 *  resets the number of defined rules to 0 and free's space allocated
 *  for rules. calls Rast_fpreclass_clear ().
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_clear (r)
 *
 *       struct FPReclass *r;
 *
 *  resets the number of defined rules to 0. Resets default Min and Max
 *  to be unknown. (see Rast_fpreclass_set_domain (), Rast_fpreclass_set_range
 *()). deactivates default mapping.
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_set_domain (r, dLow, dHigh)
 *
 *       struct FPReclass *r;
 *       DCELL dLow, dHigh;
 *
 *  defines the domain for the default mapping and
 *  activates default mapping. (see G_fpreclass_perform_d ()).
 *
 *  note: dHigh < dLow is valid.
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_set_range (r, low, high)
 *
 *       struct FPReclass *r;
 *       DCELL low, high;
 *
 *  defines the range for the default mapping. does NOT
 *  activate default mapping. (see G_fpreclass_perform_d ()).
 *
 **********************************************************************
 *
 *  int
 *  Rast_fpreclass_get_limits (r, dMin, dMax, rMin, rmax)
 *
 *       const struct FPReclass *r;
 *       DCELL *dMin, *dMax;
 *       DCELL *rMin, *rmax;
 *
 *  returns the minimum and maximum values of all the rules defined.
 *
 *  returns: -1 if after Rast_fpreclass_init (), or any call to
 *                 Rast_fpreclass_clear () or Rast_fpreclass_reset () neither
 *                 Rast_fpreclass_add_rule () nor Rast_fpreclass_set_domain ()
 *is used. in this case the returned minimum and maximum range and domain values
 *are undefined. 0 if the default rule values are returned.domain values are
 *identical to those set with Rast_fpreclass_set_domain (). range values are
 *either reclassification internal default, or the values set with
 *Rast_fpreclass_set_range (). 1 otherwise. in this case the values returned
 *correspond to the extreme values of the defined rules (they need not be
 *identical to the values set with Rast_fpreclass_set_domain ()).
 *
 **********************************************************************
 *
 *  int
 *  Rast_fpreclass_nof_rules (r)
 *
 *       const struct FPReclass *r;
 *
 *  returns the number of reclassification rules defined. This number does
 *  not include the 2 infinite intervals.
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_get_ith_rule (r, i, dLow, dHigh, rLow, rHigh)
 *
 *       const struct FPReclass *r;
 *       int i;
 *       DCELL *dLow, *dHigh;
 *       DCELL *rLow, *rHigh;
 *
 *  returns the i'th reclassification rule, for
 *  0 <= i < Rast_fpreclass_nof_rules().
 *  a larger value for i means that the rule has been added later.
 *
 **********************************************************************
 *   void
 *   Rast_fpreclass_set_neg_infinite_rule (r, dLeft, c)
 *
 *       struct FPReclass *r;
 *       DCELL dLeft;
 *       DCELL c;
 *
 *   defines a rule for values "dLeft" and smaller. values in this range
 *   are mapped to "c" if none of the "finite" reclassification rules applies.
 *
 * **********************************************************************
 *
 *  int
 *  Rast_fpreclass_get_neg_infinite_rule (r, dLeft, c)
 *
 *       const struct FPReclass *r;
 *       DCELL *dLeft;
 *       DCELL *c;
 *
 *  returns in "dLeft" and "c" the rule values for the negative infinite
 *  interval (see Rast_fpreclass_set_neg_infinite_rule ()).
 *
 *  returns: 0 if this rule is not defined
 *           1 otherwise.
 *
 **********************************************************************
 *   void
 *   Rast_fpreclass_set_pos_infinite_rule (r, dRight, c)
 *
 *       struct FPReclass *r;
 *       DCELL dRight;
 *       DCELL c;
 *
 *   defines a rule for values "dRight" and larger. values in this range
 *   are mapped to "c" if neither any of the "finite" reclassification
 *   rules nor the negative infinite rule applies.
 *
 * **********************************************************************
 *
 *  int
 *  Rast_fpreclass_get_pos_infinite_rule (r, dRight, c)
 *
 *       const struct FPReclass *r;
 *       DCELL *dRight;
 *       DCELL *c;
 *
 *  returns in "dRight" and "c" the rule values for the positive infinite
 *  interval (see Rast_fpreclass_set_pos_infinite_rule ()).
 *
 *  returns: 0 if this rule is not defined
 *           1 otherwise.
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_reverse_rule_order (r)
 *
 *        struct FPReclass *r;
 *
 *  reverses the order in which the reclassification rules are stored. (see
 *  also Rast_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
 *
 **********************************************************************
 *
 *  void
 *  Rast_fpreclass_add_rule (r, dLow, dHigh, rLow, rHigh)
 *
 *       struct FPReclass *r;
 *       DCELL dLow, dHigh;
 *       DCELL rLow, rHigh;
 *
 *  adds a new rule to the set of reclassification rules. if dLow > dHigh
 *  the rule will be stored with the low and high values interchanged.
 *
 *  Note: currently no cleanup of rules is performed, i.e. redundant
 *        rules are not removed.
 *
 **********************************************************************
 *
 *  DCELL
 *  Rast_fpreclass_get_cell_value (r, cellValue)
 *
 *       const struct FPReclass *r;
 *       DCELL *cellValue;
 *
 *  returns the reclassified value corresponding to "cellValue".
 *
 *  if several reclassification rules apply for cellValue, the one which has
 *  been inserted latest (i.e. the one of them which is returned by
 *  Rast_fpreclass_get_ith_rule() for the largest i) is used. if no such rule
 *  applies the cellValue is first tested against the negative infinite
 *  rule, and finally against the positive infinite rule. if none of
 *  these rules apply, NO_DATA is returned. the actual value of NO_DATA
 *  is found by calling Rast_set_d_null_value()
 *
 *  if after Rast_fpreclass_init (), or any call to Rast_fpreclass_clear () or
 *  Rast_fpreclass_reset () neither Rast_fpreclass_add_rule (),
 *  Rast_fpreclass_set_neg_infinite_rule (),
 *  Rast_fpreclass_set_pos_infinite_rule (), *  nor  Rast_fpreclass_set_domain
 *() is used NO_DATA is returned independently of the cellValue.
 *
 *  if Rast_fpreclass_set_domain () is called but no explicit reclassification
 *  rule is set, the default mapping to the cell range set with
 *  Rast_fpreclass_set_range () or, if the cell range is not set,
 *  to the default CELL range [0,256 - 1] is applied.
 *
 **********************************************************************
 *
 *  void
 *  G_fpreclass_perform_XY (r, xcell, ycell, n)
 *
 *       const struct FPReclass *r;
 *       XCELL *xcell;
 *       YCELL *ycell;
 *       int n;
 *
 *  "X" and "Y" in the function name can be any of "d", "f", or "i". These
 *  correspond to "DCELL", "FCELL", and "CELL", respectively, and denote
 *  the type of the domain and range values.
 *
 *  returns in "ycell" the reclassified YCELL values corresponding to the
 *  XCELL values stored in "xcell". the number of elements reclassified
 *  is n. reclassification is performed by repeated application of
 *  Rast_fpreclass_get_cell_value ().
 *
 **********************************************************************/

/*--------------------------------------------------------------------------*/

/*
   the reclassification table is stored as a linear array. rules are added
   starting from index 0. redundant rules are not eliminated. rules are tested
   from the highest index downto 0. there are two "infinite" rules. support is
   provided to reverse the order of the rules.
 */

/*--------------------------------------------------------------------------*/

#include <grass/gis.h>
#include <grass/raster.h>

/*--------------------------------------------------------------------------*/

#define NO_DEFAULT_RULE        (!r->defaultDRuleSet)
#define NO_LEFT_INFINITE_RULE  (!r->infiniteLeftSet)
#define NO_RIGHT_INFINITE_RULE (!r->infiniteRightSet)
#define NO_FINITE_RULE         (r->nofRules <= 0)
#define NO_EXPLICIT_RULE \
    (NO_FINITE_RULE && NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)

#define DEFAULT_MIN ((DCELL)1)
#define DEFAULT_MAX ((DCELL)255)

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_clear(struct FPReclass *r)
{
    r->nofRules = 0;
    r->defaultDRuleSet = 0;
    r->defaultRRuleSet = 0;
    r->infiniteRightSet = r->infiniteLeftSet = 0;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_reset(struct FPReclass *r)
{
    Rast_fpreclass_clear(r);

    if (r->maxNofRules > 0)
        G_free(r->table);

    r->maxNofRules = 0;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_init(struct FPReclass *r)
{
    r->maxNofRules = 0;
    Rast_fpreclass_reset(r);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
{
    r->defaultDMin = dLow;
    r->defaultDMax = dHigh;
    r->defaultDRuleSet = 1;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
{
    r->defaultRMin = low;
    r->defaultRMax = high;
    r->defaultRRuleSet = 1;
}

/*--------------------------------------------------------------------------*/

static void fpreclass_set_limits(struct FPReclass *r, DCELL dLow, DCELL dHigh,
                                 DCELL rLow, DCELL rHigh)
{
    r->dMin = dLow;
    r->dMax = dHigh;
    r->rMin = rLow;
    r->rMax = rHigh;
}

/*--------------------------------------------------------------------------*/

static void fpreclass_update_limits(struct FPReclass *r, DCELL dLow,
                                    DCELL dHigh, DCELL rLow, DCELL rHigh)
{
    if (NO_EXPLICIT_RULE) {
        fpreclass_set_limits(r, dLow, dHigh, rLow, rHigh);
        return;
    }

    r->dMin = MIN(r->dMin, MIN(dLow, dHigh));
    r->dMax = MAX(r->dMax, MAX(dLow, dHigh));
    r->rMin = MIN(r->rMin, MIN(rLow, rHigh));
    r->rMax = MAX(r->rMax, MAX(rLow, rHigh));
}

/*--------------------------------------------------------------------------*/

int Rast_fpreclass_get_limits(const struct FPReclass *r, DCELL *dMin,
                              DCELL *dMax, DCELL *rMin, DCELL *rMax)
{
    if (NO_EXPLICIT_RULE) {
        if (NO_DEFAULT_RULE)
            return -1;

        *dMin = r->defaultDMin;
        *dMax = r->defaultDMax;

        if (r->defaultRRuleSet) {
            *rMin = r->defaultRMin;
            *rMax = r->defaultRMax;
        }
        else {
            *rMin = DEFAULT_MIN;
            *rMax = DEFAULT_MAX;
        }

        return 0;
    }

    *dMin = r->dMin;
    *dMax = r->dMax;
    *rMin = r->rMin;
    *rMax = r->rMax;

    return 1;
}

/*--------------------------------------------------------------------------*/

int Rast_fpreclass_nof_rules(const struct FPReclass *r)
{
    return r->nofRules;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_get_ith_rule(const struct FPReclass *r, int i, DCELL *dLow,
                                 DCELL *dHigh, DCELL *rLow, DCELL *rHigh)
{
    *dLow = r->table[i].dLow;
    *dHigh = r->table[i].dHigh;
    *rLow = r->table[i].rLow;
    *rHigh = r->table[i].rHigh;
}

/*--------------------------------------------------------------------------*/

static void fpreclass_table_increase(struct FPReclass *r)
{
    if (r->nofRules < r->maxNofRules)
        return;

    if (r->maxNofRules == 0) {
        r->maxNofRules = 50;
        r->table = (struct FPReclass_table *)G_malloc(
            r->maxNofRules * sizeof(struct FPReclass_table));
    }
    else {
        r->maxNofRules += 50;
        r->table = (struct FPReclass_table *)G_realloc(
            (char *)r->table, r->maxNofRules * sizeof(struct FPReclass_table));
    }
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft,
                                          DCELL c)
{
    r->infiniteDLeft = dLeft;
    r->infiniteRLeft = c;
    fpreclass_update_limits(r, dLeft, dLeft, c, c);
    r->infiniteLeftSet = 1;
}

/*--------------------------------------------------------------------------*/

int Rast_fpreclass_get_neg_infinite_rule(const struct FPReclass *r,
                                         DCELL *dLeft, DCELL *c)
{
    if (r->infiniteLeftSet == 0)
        return 0;

    *dLeft = r->infiniteDLeft;
    *c = r->infiniteRLeft;

    return 1;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight,
                                          DCELL c)
{
    r->infiniteDRight = dRight;
    r->infiniteRRight = c;
    fpreclass_update_limits(r, dRight, dRight, c, c);
    r->infiniteRightSet = 1;
}

/*--------------------------------------------------------------------------*/

int Rast_fpreclass_get_pos_infinite_rule(const struct FPReclass *r,
                                         DCELL *dRight, DCELL *c)
{
    if (r->infiniteRightSet == 0)
        return 0;

    *dRight = r->infiniteDRight;
    *c = r->infiniteRRight;

    return 1;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_add_rule(struct FPReclass *r, DCELL dLow, DCELL dHigh,
                             DCELL rLow, DCELL rHigh)
{
    int i;
    struct FPReclass_table *p;

    fpreclass_table_increase(r);

    i = r->nofRules;

    p = &(r->table[i]);
    if (dHigh >= dLow) {
        p->dLow = dLow;
        p->dHigh = dHigh;
        p->rLow = rLow;
        p->rHigh = rHigh;
    }
    else {
        p->dLow = dHigh;
        p->dHigh = dLow;
        p->rLow = rHigh;
        p->rHigh = rLow;
    }

    fpreclass_update_limits(r, dLow, dHigh, rLow, rHigh);

    r->nofRules++;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_reverse_rule_order(struct FPReclass *r)
{
    struct FPReclass_table tmp;
    struct FPReclass_table *pLeft, *pRight;

    pLeft = r->table;
    pRight = &(r->table[r->nofRules - 1]);

    while (pLeft < pRight) {
        tmp.dLow = pLeft->dLow;
        tmp.dHigh = pLeft->dHigh;
        tmp.rLow = pLeft->rLow;
        tmp.rHigh = pLeft->rHigh;

        pLeft->dLow = pRight->dLow;
        pLeft->dHigh = pRight->dHigh;
        pLeft->rLow = pRight->rLow;
        pLeft->rHigh = pRight->rHigh;

        pRight->dLow = tmp.dLow;
        pRight->dHigh = tmp.dHigh;
        pRight->rLow = tmp.rLow;
        pRight->rHigh = tmp.rHigh;

        pLeft++;
        pRight--;
    }
}

/*--------------------------------------------------------------------------*/

static DCELL fpreclass_interpolate(DCELL dLow, DCELL dHigh, DCELL rLow,
                                   DCELL rHigh, DCELL dValue)
{
    if (rLow == rHigh)
        return rLow;
    if (dLow == dHigh)
        return rLow;

    return ((dValue - dLow) / (dHigh - dLow) * (rHigh - rLow) + rLow);
}

/*--------------------------------------------------------------------------*/

static DCELL fpreclass_get_default_cell_value(const struct FPReclass *r,
                                              DCELL cellVal)
{
    DCELL tmp;

    Rast_set_d_null_value(&tmp, 1);

    if ((cellVal < MIN(r->defaultDMin, r->defaultDMax)) ||
        (cellVal > MAX(r->defaultDMin, r->defaultDMax)))
        return tmp;

    if (r->defaultRRuleSet)
        return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
                                     r->defaultRMin, r->defaultRMax, cellVal);
    else
        return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
                                     DEFAULT_MIN, DEFAULT_MAX, cellVal);
}

/*--------------------------------------------------------------------------*/

DCELL Rast_fpreclass_get_cell_value(const struct FPReclass *r, DCELL cellVal)
{
    DCELL tmp;
    const struct FPReclass_table *p;

    Rast_set_d_null_value(&tmp, 1);
    if (NO_EXPLICIT_RULE) {

        if (NO_DEFAULT_RULE)
            return tmp;
        return fpreclass_get_default_cell_value(r, cellVal);
    }

    if (!NO_FINITE_RULE)
        for (p = &(r->table[r->nofRules - 1]); p >= r->table; p--)
            if ((cellVal >= p->dLow) && (cellVal <= p->dHigh))
                return fpreclass_interpolate(p->dLow, p->dHigh, p->rLow,
                                             p->rHigh, cellVal);

    if ((!NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
        return r->infiniteRLeft;

    if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight))
        return tmp;

    return r->infiniteRRight;
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_di(const struct FPReclass *r, const DCELL *dcell,
                               CELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, dcell++)
        if (!Rast_is_d_null_value(dcell))
            *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
        else
            Rast_set_c_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_df(const struct FPReclass *r, const DCELL *dcell,
                               FCELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, dcell++)
        if (!Rast_is_d_null_value(dcell))
            *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
        else
            Rast_set_f_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_dd(const struct FPReclass *r, const DCELL *dcell,
                               DCELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, dcell++)
        if (!Rast_is_d_null_value(dcell))
            *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
        else
            Rast_set_d_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_fi(const struct FPReclass *r, const FCELL *fcell,
                               CELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, fcell++)
        if (!Rast_is_f_null_value(fcell))
            *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL)*fcell);
        else
            Rast_set_c_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_ff(const struct FPReclass *r, const FCELL *fcell,
                               FCELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, fcell++)
        if (!Rast_is_f_null_value(fcell))
            *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL)*fcell);
        else
            Rast_set_f_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_fd(const struct FPReclass *r, const FCELL *fcell,
                               DCELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, fcell++)
        if (!Rast_is_f_null_value(fcell))
            *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL)*fcell);
        else
            Rast_set_d_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_ii(const struct FPReclass *r, const CELL *icell,
                               CELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, icell++)
        if (!Rast_is_c_null_value(icell))
            *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL)*icell);
        else
            Rast_set_c_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_if(const struct FPReclass *r, const CELL *icell,
                               FCELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, icell++)
        if (!Rast_is_c_null_value(icell))
            *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL)*icell);
        else
            Rast_set_f_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

void Rast_fpreclass_perform_id(const struct FPReclass *r, const CELL *icell,
                               DCELL *cell, int n)
{
    int i;

    for (i = 0; i < n; i++, icell++)
        if (!Rast_is_c_null_value(icell))
            *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL)*icell);
        else
            Rast_set_d_null_value(cell++, 1);
}

/*--------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------*/