fpreclass.c

Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  *  G_fpreclass_init (r)
00004  *
00005  *       struct FPReclass *r;
00006  *
00007  *  initializes new reclassification structure. calls
00008  *  G_fpreclass_clear() before it returns.
00009  *  
00010  **********************************************************************
00011  *
00012  *  void
00013  *  G_fpreclass_reset (r)
00014  *  
00015  *       struct FPReclass *r;
00016  *
00017  *  resets the number of defined rules to 0 and free's space allocated
00018  *  for rules. calls G_fpreclass_clear ().
00019  *
00020  **********************************************************************
00021  *
00022  *  void
00023  *  G_fpreclass_clear (r)
00024  *  
00025  *       struct FPReclass *r;
00026  *
00027  *  resets the number of defined rules to 0. Resets default Min and Max
00028  *  to be unknown. (see G_fpreclass_set_domain (), G_fpreclass_set_range ()).
00029  *  deactivates default mapping.
00030  *
00031  **********************************************************************
00032  *
00033  *  void
00034  *  G_fpreclass_set_domain (r, dLow, dHigh)
00035  *
00036  *       struct FPReclass *r;
00037  *       DCELL dLow, dHigh;
00038  *
00039  *  defines the domain for the default mapping and 
00040  *  activates default mapping. (see G_fpreclass_perform_d ()).
00041  *  
00042  *  note: dHigh < dLow is valid.
00043  *
00044  **********************************************************************
00045  *
00046  *  void
00047  *  G_fpreclass_set_range (r, low, high)
00048  *
00049  *       struct FPReclass *r;
00050  *       DCELL low, high;
00051  *
00052  *  defines the range for the default mapping. does NOT
00053  *  activate default mapping. (see G_fpreclass_perform_d ()).
00054  *  
00055  **********************************************************************
00056  *
00057  *  int
00058  *  G_fpreclass_get_limits (r, dMin, dMax, rMin, rmax)
00059  *  
00060  *       struct FPReclass *r;
00061  *       DCELL *dMin, *dMax;
00062  *       DCELL *rMin, *rmax;
00063  *
00064  *  returns the minimum and maximum values of all the rules defined.
00065  *  
00066  *  returns: -1 if after G_fpreclass_init (), or any call to 
00067  *                 G_fpreclass_clear () or G_fpreclass_reset () neither 
00068  *                 G_fpreclass_add_rule () nor G_fpreclass_set_domain () is
00069  *                 used. in this case the returned minimum and maximum 
00070  *                 range and domain values are undefined.
00071  *            0 if the default rule values are returned.domain values
00072  *                 are identical to those set with G_fpreclass_set_domain ().
00073  *                 range values are either reclassification internal default,
00074  *                 or the values set with G_fpreclass_set_range ().
00075  *            1 otherwise. in this case the values returned correspond
00076  *                 to the extreme values of the defined rules (they need 
00077  *                 not be identical to the values set with
00078  *                 G_fpreclass_set_domain ()).
00079  *
00080  **********************************************************************
00081  *  
00082  *  int
00083  *  G_fpreclass_nof_rules (r)
00084  *  
00085  *       struct FPReclass *r;
00086  *  
00087  *  returns the number of reclassification rules defined. This number does
00088  *  not include the 2 infinite intervals.
00089  *  
00090  **********************************************************************
00091  *  
00092  *  void
00093  *  G_fpreclass_get_ith_rule (r, i, dLow, dHigh, rLow, rHigh)
00094  *  
00095  *       struct FPReclass *r;
00096  *       int i;
00097  *       DCELL *dLow, *dHigh;
00098  *       DCELL *rLow, *rHigh;
00099  *  
00100  *  returns the i'th reclassification rule, for 
00101  *  0 <= i < G_fpreclass_nof_rules().
00102  *  a larger value for i means that the rule has been added later.
00103  *  
00104  **********************************************************************
00105  *   void
00106  *   G_fpreclass_set_neg_infinite_rule (r, dLeft, c)
00107  *
00108  *       struct FPReclass *r;
00109  *       DCELL dLeft;
00110  *       DCELL c;
00111  *
00112  *   defines a rule for values "dLeft" and smaller. values in this range
00113  *   are mapped to "c" if none of the "finite" reclassification rules applies.
00114  *
00115  * **********************************************************************
00116  *
00117  *  int
00118  *  G_fpreclass_get_neg_infinite_rule (r, dLeft, c)
00119  *
00120  *       struct FPReclass *r;
00121  *       DCELL *dLeft;
00122  *       DCELL *c;
00123  *
00124  *  returns in "dLeft" and "c" the rule values for the negative infinite
00125  *  interval (see G_fpreclass_set_neg_infinite_rule ()).
00126  *
00127  *  returns: 0 if this rule is not defined
00128  *           1 otherwise.
00129  *
00130  **********************************************************************
00131  *   void
00132  *   G_fpreclass_set_pos_infinite_rule (r, dRight, c)
00133  *
00134  *       struct FPReclass *r;
00135  *       DCELL dRight;
00136  *       DCELL c;
00137  *
00138  *   defines a rule for values "dRight" and larger. values in this range
00139  *   are mapped to "c" if neither any of the "finite" reclassification
00140  *   rules nor the negative infinite rule applies.
00141  *
00142  * **********************************************************************
00143  *
00144  *  int
00145  *  G_fpreclass_get_pos_infinite_rule (r, dRight, c)
00146  *
00147  *       struct FPReclass *r;
00148  *       DCELL *dRight;
00149  *       DCELL *c;
00150  *
00151  *  returns in "dRight" and "c" the rule values for the positive infinite
00152  *  interval (see G_fpreclass_set_pos_infinite_rule ()).
00153  *
00154  *  returns: 0 if this rule is not defined
00155  *           1 otherwise.
00156  *
00157  **********************************************************************
00158  *  
00159  *  void
00160  *  G_fpreclass_reverse_rule_order (r)
00161  *
00162  *        struct FPReclass *r;
00163  *
00164  *  reverses the order in which the reclassification rules are stored. (see
00165  *  also G_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
00166  *  
00167  **********************************************************************
00168  *  
00169  *  void
00170  *  G_fpreclass_add_rule (r, dLow, dHigh, rLow, rHigh)
00171  *  
00172  *       struct FPReclass *r;
00173  *       DCELL dLow, dHigh;
00174  *       DCELL rLow, rHigh;
00175  *  
00176  *  adds a new rule to the set of reclassification rules. if dLow > dHigh
00177  *  the rule will be stored with the low and high values interchanged.
00178  *  
00179  *  Note: currently no cleanup of rules is performed, i.e. redundant
00180  *        rules are not removed.
00181  *  
00182  **********************************************************************
00183  *  
00184  *  DCELL
00185  *  G_fpreclass_get_cell_value (r, cellValue)
00186  *  
00187  *       struct FPReclass *r;
00188  *       DCELL *cellValue;
00189  *  
00190  *  returns the reclassified value corresponding to "cellValue".
00191  *
00192  *  if several reclassification rules apply for cellValue, the one which has 
00193  *  been inserted latest (i.e. the one of them which is returned by 
00194  *  G_fpreclass_get_ith_rule() for the largest i) is used. if no such rule
00195  *  applies the cellValue is first tested against the negative infinite
00196  *  rule, and finally against the positive infinite rule. if none of
00197  *  these rules apply, NO_DATA is returned. the actual value of NO_DATA 
00198  *  is found by calling G_set_d_null_value()
00199  *  
00200  *  if after G_fpreclass_init (), or any call to G_fpreclass_clear () or 
00201  *  G_fpreclass_reset () neither G_fpreclass_add_rule (),
00202  *  G_fpreclass_set_neg_infinite_rule (),  
00203  *  G_fpreclass_set_pos_infinite_rule (), *  nor  G_fpreclass_set_domain () 
00204  *  is used NO_DATA is returned independently of the cellValue.
00205  *
00206  *  if G_fpreclass_set_domain () is called but no explicit reclassification
00207  *  rule is set, the default mapping to the cell range set with 
00208  *  G_fpreclass_set_range () or, if the cell range is not set, 
00209  *  to the default CELL range [0,256 - 1] is applied.
00210  *  
00211  **********************************************************************
00212  *  
00213  *  void
00214  *  G_fpreclass_perform_XY (r, xcell, ycell, n)
00215  *  
00216  *       struct FPReclass *r;
00217  *       XCELL *xcell;
00218  *       YCELL *ycell;
00219  *       int n;
00220  *  
00221  *  "X" and "Y" in the function name can be any of "d", "f", or "i". These
00222  *  correspond to "DCELL", "FCELL", and "CELL", respectively, and denote
00223  *  the type of the domain and range values.
00224  *  
00225  *  returns in "ycell" the reclassified YCELL values corresponding to the
00226  *  XCELL values stored in "xcell". the number of elements reclassified
00227  *  is n. reclassification is performed by repeated application of 
00228  *  G_fpreclass_get_cell_value ().
00229  *  
00230  **********************************************************************/
00231 
00232 /*--------------------------------------------------------------------------*/
00233 
00234 /*
00235  the reclassification table is stored as a linear array. rules are added 
00236  starting from index 0. redundant rules are not eliminated. rules are tested 
00237  from the highest index downto 0. there are two "infinite" rules. support is 
00238  provided to reverse the order of the rules.
00239 */
00240 
00241 /*--------------------------------------------------------------------------*/
00242 
00243 #include <grass/gis.h>
00244 
00245 /*--------------------------------------------------------------------------*/
00246 
00247 #define MIN(a,b) (a < b ? a : b)
00248 #define MAX(a,b) (a > b ? a : b)
00249 
00250 #define NO_DEFAULT_RULE (! r->defaultDRuleSet)
00251 #define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
00252 #define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
00253 #define NO_FINITE_RULE (r->nofRules <= 0)
00254 #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
00255                           NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
00256 
00257 #define DEFAULT_MIN ((DCELL) 1)
00258 #define DEFAULT_MAX ((DCELL) 255)  
00259 
00260 /*--------------------------------------------------------------------------*/
00261 
00262 void
00263 G_fpreclass_clear  (struct FPReclass *r)
00264 
00265 {
00266   r->nofRules = 0;
00267   r->defaultDRuleSet = 0;
00268   r->defaultRRuleSet = 0;
00269   r->infiniteRightSet = r->infiniteLeftSet = 0;
00270 }
00271 
00272 /*--------------------------------------------------------------------------*/
00273 
00274 void
00275 G_fpreclass_reset  (struct FPReclass *r)
00276 
00277 {
00278   G_fpreclass_clear (r);
00279 
00280   if (r->maxNofRules > 0) G_free (r->table);
00281 
00282   r->maxNofRules = 0;
00283 }
00284 
00285 /*--------------------------------------------------------------------------*/
00286 
00287 int G_fpreclass_init  (struct FPReclass *r)
00288 
00289 {
00290   r->maxNofRules = 0;
00291   G_fpreclass_reset (r);
00292   
00293   return 1;
00294 }
00295 
00296 /*--------------------------------------------------------------------------*/
00297 
00298 void
00299 G_fpreclass_set_domain  (struct FPReclass *r, DCELL dLow, DCELL dHigh)
00300 
00301 {
00302   r->defaultDMin = dLow;
00303   r->defaultDMax = dHigh;
00304   r->defaultDRuleSet = 1;
00305 }
00306 
00307 /*--------------------------------------------------------------------------*/
00308 
00309 void
00310 G_fpreclass_set_range  (struct FPReclass *r, DCELL low, DCELL high)
00311 
00312 {
00313   r->defaultRMin = low;
00314   r->defaultRMax = high;
00315   r->defaultRRuleSet = 1;
00316 }
00317 
00318 /*--------------------------------------------------------------------------*/
00319 
00320 static void
00321 fpreclass_set_limits  (struct FPReclass *r, DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh)
00322 
00323 {
00324   r->dMin = dLow;
00325   r->dMax = dHigh;
00326   r->rMin = rLow;
00327   r->rMax = rHigh;
00328 }
00329 
00330 /*--------------------------------------------------------------------------*/
00331 
00332 static void
00333 fpreclass_update_limits  (struct FPReclass *r, DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh)
00334 
00335 {
00336   if (NO_EXPLICIT_RULE) {
00337     fpreclass_set_limits (r, dLow, dHigh, rLow, rHigh);
00338     return;
00339   }
00340 
00341   r->dMin = MIN (r->dMin, MIN (dLow, dHigh));
00342   r->dMax = MAX (r->dMax, MAX (dLow, dHigh));
00343   r->rMin = MIN (r->rMin, MIN (rLow, rHigh));
00344   r->rMax = MAX (r->rMax, MAX (rLow, rHigh));
00345 }
00346 
00347 /*--------------------------------------------------------------------------*/
00348 
00349 int
00350 G_fpreclass_get_limits  (struct FPReclass *r, DCELL *dMin, DCELL *dMax, DCELL *rMin, DCELL *rMax)
00351 
00352 {
00353   if (NO_EXPLICIT_RULE) {
00354     if (NO_DEFAULT_RULE) return -1;
00355 
00356     *dMin = r->defaultDMin; *dMax = r->defaultDMax;
00357 
00358     if (r->defaultRRuleSet) {
00359       *rMin = r->defaultRMin; *rMax = r->defaultRMax;
00360     } else {
00361       *rMin = DEFAULT_MIN; *rMax = DEFAULT_MAX;
00362     }
00363 
00364     return 0;
00365   }
00366 
00367   *dMin = r->dMin; *dMax = r->dMax;
00368   *rMin = r->rMin; *rMax = r->rMax;
00369 
00370   return 1;
00371 }
00372 
00373 /*--------------------------------------------------------------------------*/
00374 
00375 int
00376 G_fpreclass_nof_rules  (struct FPReclass *r)
00377 
00378 {
00379   return r->nofRules;
00380 }
00381 
00382 /*--------------------------------------------------------------------------*/
00383 
00384 void
00385 G_fpreclass_get_ith_rule  (struct FPReclass *r, int i, DCELL *dLow, DCELL *dHigh, DCELL *rLow, DCELL *rHigh)
00386 
00387 {
00388   *dLow = r->table[i].dLow;
00389   *dHigh = r->table[i].dHigh;
00390   *rLow = r->table[i].rLow;
00391   *rHigh = r->table[i].rHigh;
00392 }
00393 
00394 /*--------------------------------------------------------------------------*/
00395 
00396 static void
00397 fpreclass_table_increase  (struct FPReclass *r)
00398 
00399 {
00400   if (r->nofRules < r->maxNofRules) return;
00401 
00402   if (r->maxNofRules == 0) {
00403     r->maxNofRules = 50;
00404     r->table = (struct FPReclass_table *) 
00405                  G_malloc (r->maxNofRules * sizeof (struct FPReclass_table));
00406   } else {
00407     r->maxNofRules += 50;
00408     r->table = (struct FPReclass_table *) 
00409         G_realloc ((char *) r->table, r->maxNofRules * sizeof (struct FPReclass_table));
00410   }
00411 }
00412 
00413 /*--------------------------------------------------------------------------*/
00414 
00415 void
00416 G_fpreclass_set_neg_infinite_rule  (struct FPReclass *r, DCELL dLeft, DCELL c)
00417 
00418 {
00419   r->infiniteDLeft = dLeft;
00420   r->infiniteRLeft = c;
00421   fpreclass_update_limits (r, dLeft, dLeft, c, c); 
00422   r->infiniteLeftSet = 1;
00423 }
00424 
00425 /*--------------------------------------------------------------------------*/
00426 
00427 int
00428 G_fpreclass_get_neg_infinite_rule  (struct FPReclass *r, DCELL *dLeft, DCELL *c)
00429 
00430 {
00431   if (r->infiniteLeftSet == 0) return 0;
00432 
00433   *dLeft = r->infiniteDLeft;
00434   *c = r->infiniteRLeft;
00435 
00436   return 1;
00437 }
00438 
00439 /*--------------------------------------------------------------------------*/
00440 
00441 void
00442 G_fpreclass_set_pos_infinite_rule  (struct FPReclass *r, DCELL dRight, DCELL c)
00443 
00444 {
00445   r->infiniteDRight = dRight;
00446   r->infiniteRRight = c;
00447   fpreclass_update_limits (r, dRight, dRight, c, c); 
00448   r->infiniteRightSet = 1;
00449 }
00450 
00451 /*--------------------------------------------------------------------------*/
00452 
00453 int
00454 G_fpreclass_get_pos_infinite_rule  (struct FPReclass *r, DCELL *dRight, DCELL *c)
00455 
00456 {
00457   if (r->infiniteRightSet == 0) return 0;
00458 
00459   *dRight = r->infiniteDRight;
00460   *c = r->infiniteRRight;
00461 
00462   return 1;
00463 }
00464 
00465 /*--------------------------------------------------------------------------*/
00466 
00467 void
00468 G_fpreclass_add_rule  (struct FPReclass *r, DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh)
00469 
00470 {
00471   int i;
00472   struct FPReclass_table *p;
00473 
00474   fpreclass_table_increase (r);
00475 
00476   i = r->nofRules;
00477 
00478   p = &(r->table[i]);
00479   if (dHigh >= dLow) {
00480     p->dLow = dLow; p->dHigh = dHigh; p->rLow = rLow; p->rHigh = rHigh;  
00481   } else {
00482     p->dLow = dHigh; p->dHigh = dLow; p->rLow = rHigh; p->rHigh = rLow;  
00483   }
00484 
00485   fpreclass_update_limits (r, dLow, dHigh, rLow, rHigh);
00486 
00487   r->nofRules++;
00488 }
00489 
00490 /*--------------------------------------------------------------------------*/
00491 
00492 void
00493 G_fpreclass_reverse_rule_order  (struct FPReclass *r)
00494 
00495 {
00496   struct FPReclass_table tmp;
00497   struct FPReclass_table *pLeft, *pRight;
00498 
00499   pLeft = r->table;
00500   pRight = &(r->table [r->nofRules - 1]);
00501 
00502   while (pLeft < pRight) {
00503     tmp.dLow = pLeft->dLow; tmp.dHigh = pLeft->dHigh;
00504     tmp.rLow = pLeft->rLow; tmp.rHigh = pLeft->rHigh;
00505 
00506     pLeft->dLow = pRight->dLow; pLeft->dHigh = pRight->dHigh;
00507     pLeft->rLow = pRight->rLow; pLeft->rHigh = pRight->rHigh;
00508 
00509     pRight->dLow = tmp.dLow; pRight->dHigh = tmp.dHigh;
00510     pRight->rLow = tmp.rLow; pRight->rHigh = tmp.rHigh;
00511 
00512     pLeft++; pRight--;
00513   }    
00514 }
00515 
00516 /*--------------------------------------------------------------------------*/
00517 
00518 static DCELL
00519 fpreclass_interpolate  (DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh, DCELL dValue)
00520 
00521 {
00522   if (rLow == rHigh) return rLow;
00523   if (dLow == dHigh) return rLow;
00524 
00525   return ((dValue - dLow) / (dHigh - dLow) * (rHigh - rLow) + rLow); 
00526 }
00527 
00528 /*--------------------------------------------------------------------------*/
00529 
00530 static DCELL
00531 fpreclass_get_default_cell_value  (struct FPReclass *r, DCELL cellVal)
00532 
00533 {
00534   DCELL tmp;
00535   G_set_d_null_value(&tmp, 1);
00536 
00537   if ((cellVal < MIN (r->defaultDMin, r->defaultDMax)) ||
00538       (cellVal > MAX (r->defaultDMin, r->defaultDMax))) return tmp;
00539 
00540   if (r->defaultRRuleSet)
00541     return fpreclass_interpolate (r->defaultDMin, r->defaultDMax,
00542                               r->defaultRMin, r->defaultRMax, cellVal);
00543   else
00544     return fpreclass_interpolate (r->defaultDMin, r->defaultDMax,
00545                               DEFAULT_MIN, DEFAULT_MAX, cellVal);
00546 }
00547 
00548 /*--------------------------------------------------------------------------*/
00549 
00550 DCELL
00551 G_fpreclass_get_cell_value  (struct FPReclass *r, DCELL cellVal)
00552 
00553 {
00554   DCELL tmp;
00555   struct FPReclass_table *p;
00556 
00557   G_set_d_null_value(&tmp, 1);
00558   if (NO_EXPLICIT_RULE) {
00559 
00560     if (NO_DEFAULT_RULE) return tmp;
00561     return fpreclass_get_default_cell_value (r, cellVal);
00562   }
00563 
00564   if (! NO_FINITE_RULE)
00565     for (p = &(r->table [r->nofRules - 1]); p >= r->table; p--)
00566       if ((cellVal >= p->dLow) && (cellVal <= p->dHigh)) 
00567         return fpreclass_interpolate (p->dLow, p->dHigh, p->rLow, p->rHigh,
00568                                       cellVal);
00569   
00570   if ((! NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
00571     return r->infiniteRLeft;
00572 
00573   if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight)) 
00574     return tmp;
00575 
00576   return r->infiniteRRight;
00577 }
00578 
00579 /*--------------------------------------------------------------------------*/
00580 
00581 void
00582 G_fpreclass_perform_di  (struct FPReclass *r, DCELL *dcell, CELL *cell, int n)
00583 
00584 {
00585   int i;
00586 
00587   for (i = 0; i < n; i++, dcell++)
00588     if (! G_is_d_null_value (dcell))
00589       *cell++ = G_fpreclass_get_cell_value (r, *dcell);
00590     else
00591       G_set_c_null_value (cell++, 1);
00592 }
00593 
00594 /*--------------------------------------------------------------------------*/
00595 
00596 void
00597 G_fpreclass_perform_df  (struct FPReclass *r, DCELL *dcell, FCELL *cell, int n)
00598 
00599 {
00600   int i;
00601 
00602   for (i = 0; i < n; i++, dcell++)
00603     if (! G_is_d_null_value (dcell))
00604       *cell++ = G_fpreclass_get_cell_value (r, *dcell);
00605     else
00606       G_set_f_null_value (cell++, 1);
00607 }
00608 
00609 /*--------------------------------------------------------------------------*/
00610 
00611 void
00612 G_fpreclass_perform_dd  (struct FPReclass *r, DCELL *dcell, DCELL *cell, int n)
00613 
00614 {
00615   int i;
00616 
00617   for (i = 0; i < n; i++, dcell++)
00618     if (! G_is_d_null_value (dcell))
00619       *cell++ = G_fpreclass_get_cell_value (r, *dcell);
00620     else
00621       G_set_d_null_value (cell++, 1);
00622 }
00623 
00624 /*--------------------------------------------------------------------------*/
00625 
00626 void
00627 G_fpreclass_perform_fi  (struct FPReclass *r, FCELL *fcell, CELL *cell, int n)
00628 
00629 {
00630   int i;
00631 
00632   for (i = 0; i < n; i++, fcell++)
00633     if (! G_is_f_null_value (fcell))
00634       *cell++ = G_fpreclass_get_cell_value (r, (DCELL) *fcell);
00635     else
00636       G_set_c_null_value (cell++, 1);
00637 }
00638 
00639 /*--------------------------------------------------------------------------*/
00640 
00641 void
00642 G_fpreclass_perform_ff  (struct FPReclass *r, FCELL *fcell, FCELL *cell, int n)
00643 
00644 {
00645   int i;
00646 
00647   for (i = 0; i < n; i++, fcell++)
00648     if (! G_is_f_null_value (fcell))
00649       *cell++ = G_fpreclass_get_cell_value (r, (DCELL) *fcell);
00650     else
00651       G_set_f_null_value (cell++, 1);
00652 }
00653 
00654 /*--------------------------------------------------------------------------*/
00655 
00656 void
00657 G_fpreclass_perform_fd  (struct FPReclass *r, FCELL *fcell, DCELL *cell, int n)
00658 
00659 {
00660   int i;
00661 
00662   for (i = 0; i < n; i++, fcell++)
00663     if (! G_is_f_null_value (fcell))
00664       *cell++ = G_fpreclass_get_cell_value (r, (DCELL) *fcell);
00665     else
00666       G_set_d_null_value (cell++, 1);
00667 }
00668 
00669 /*--------------------------------------------------------------------------*/
00670 
00671 void
00672 G_fpreclass_perform_ii  (struct FPReclass *r, CELL *icell, CELL *cell, int n)
00673 
00674 {
00675   int i;
00676 
00677   for (i = 0; i < n; i++, icell++)
00678     if (! G_is_c_null_value (icell))
00679       *cell++ = G_fpreclass_get_cell_value (r, (DCELL) *icell);
00680     else
00681       G_set_c_null_value (cell++, 1);
00682 }
00683 
00684 /*--------------------------------------------------------------------------*/
00685 
00686 void
00687 G_fpreclass_perform_if  (struct FPReclass *r, CELL *icell, FCELL *cell, int n)
00688 
00689 {
00690   int i;
00691 
00692   for (i = 0; i < n; i++, icell++)
00693     if (! G_is_c_null_value (icell))
00694       *cell++ = G_fpreclass_get_cell_value (r, (DCELL) *icell);
00695     else
00696       G_set_f_null_value (cell++, 1);
00697 }
00698 
00699 /*--------------------------------------------------------------------------*/
00700 
00701 void
00702 G_fpreclass_perform_id  (struct FPReclass *r, CELL *icell, DCELL *cell, int n)
00703 
00704 {
00705   int i;
00706 
00707   for (i = 0; i < n; i++, icell++)
00708     if (! G_is_c_null_value (icell))
00709       *cell++ = G_fpreclass_get_cell_value (r, (DCELL) *icell);
00710     else
00711       G_set_d_null_value (cell++, 1);
00712 }
00713 
00714 /*--------------------------------------------------------------------------*/
00715 /*--------------------------------------------------------------------------*/
00716 /*--------------------------------------------------------------------------*/
00717 

Generated on Wed Dec 19 14:59:05 2007 for GRASS by  doxygen 1.5.4