fpreclass.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /**********************************************************************
  2. *
  3. * G_fpreclass_init (r)
  4. *
  5. * struct FPReclass *r;
  6. *
  7. * initializes new reclassification structure. calls
  8. * G_fpreclass_clear() before it returns.
  9. *
  10. **********************************************************************
  11. *
  12. * void
  13. * G_fpreclass_reset (r)
  14. *
  15. * struct FPReclass *r;
  16. *
  17. * resets the number of defined rules to 0 and free's space allocated
  18. * for rules. calls G_fpreclass_clear ().
  19. *
  20. **********************************************************************
  21. *
  22. * void
  23. * G_fpreclass_clear (r)
  24. *
  25. * struct FPReclass *r;
  26. *
  27. * resets the number of defined rules to 0. Resets default Min and Max
  28. * to be unknown. (see G_fpreclass_set_domain (), G_fpreclass_set_range ()).
  29. * deactivates default mapping.
  30. *
  31. **********************************************************************
  32. *
  33. * void
  34. * G_fpreclass_set_domain (r, dLow, dHigh)
  35. *
  36. * struct FPReclass *r;
  37. * DCELL dLow, dHigh;
  38. *
  39. * defines the domain for the default mapping and
  40. * activates default mapping. (see G_fpreclass_perform_d ()).
  41. *
  42. * note: dHigh < dLow is valid.
  43. *
  44. **********************************************************************
  45. *
  46. * void
  47. * G_fpreclass_set_range (r, low, high)
  48. *
  49. * struct FPReclass *r;
  50. * DCELL low, high;
  51. *
  52. * defines the range for the default mapping. does NOT
  53. * activate default mapping. (see G_fpreclass_perform_d ()).
  54. *
  55. **********************************************************************
  56. *
  57. * int
  58. * G_fpreclass_get_limits (r, dMin, dMax, rMin, rmax)
  59. *
  60. * const struct FPReclass *r;
  61. * DCELL *dMin, *dMax;
  62. * DCELL *rMin, *rmax;
  63. *
  64. * returns the minimum and maximum values of all the rules defined.
  65. *
  66. * returns: -1 if after G_fpreclass_init (), or any call to
  67. * G_fpreclass_clear () or G_fpreclass_reset () neither
  68. * G_fpreclass_add_rule () nor G_fpreclass_set_domain () is
  69. * used. in this case the returned minimum and maximum
  70. * range and domain values are undefined.
  71. * 0 if the default rule values are returned.domain values
  72. * are identical to those set with G_fpreclass_set_domain ().
  73. * range values are either reclassification internal default,
  74. * or the values set with G_fpreclass_set_range ().
  75. * 1 otherwise. in this case the values returned correspond
  76. * to the extreme values of the defined rules (they need
  77. * not be identical to the values set with
  78. * G_fpreclass_set_domain ()).
  79. *
  80. **********************************************************************
  81. *
  82. * int
  83. * G_fpreclass_nof_rules (r)
  84. *
  85. * const struct FPReclass *r;
  86. *
  87. * returns the number of reclassification rules defined. This number does
  88. * not include the 2 infinite intervals.
  89. *
  90. **********************************************************************
  91. *
  92. * void
  93. * G_fpreclass_get_ith_rule (r, i, dLow, dHigh, rLow, rHigh)
  94. *
  95. * const struct FPReclass *r;
  96. * int i;
  97. * DCELL *dLow, *dHigh;
  98. * DCELL *rLow, *rHigh;
  99. *
  100. * returns the i'th reclassification rule, for
  101. * 0 <= i < G_fpreclass_nof_rules().
  102. * a larger value for i means that the rule has been added later.
  103. *
  104. **********************************************************************
  105. * void
  106. * G_fpreclass_set_neg_infinite_rule (r, dLeft, c)
  107. *
  108. * struct FPReclass *r;
  109. * DCELL dLeft;
  110. * DCELL c;
  111. *
  112. * defines a rule for values "dLeft" and smaller. values in this range
  113. * are mapped to "c" if none of the "finite" reclassification rules applies.
  114. *
  115. * **********************************************************************
  116. *
  117. * int
  118. * G_fpreclass_get_neg_infinite_rule (r, dLeft, c)
  119. *
  120. * const struct FPReclass *r;
  121. * DCELL *dLeft;
  122. * DCELL *c;
  123. *
  124. * returns in "dLeft" and "c" the rule values for the negative infinite
  125. * interval (see G_fpreclass_set_neg_infinite_rule ()).
  126. *
  127. * returns: 0 if this rule is not defined
  128. * 1 otherwise.
  129. *
  130. **********************************************************************
  131. * void
  132. * G_fpreclass_set_pos_infinite_rule (r, dRight, c)
  133. *
  134. * struct FPReclass *r;
  135. * DCELL dRight;
  136. * DCELL c;
  137. *
  138. * defines a rule for values "dRight" and larger. values in this range
  139. * are mapped to "c" if neither any of the "finite" reclassification
  140. * rules nor the negative infinite rule applies.
  141. *
  142. * **********************************************************************
  143. *
  144. * int
  145. * G_fpreclass_get_pos_infinite_rule (r, dRight, c)
  146. *
  147. * const struct FPReclass *r;
  148. * DCELL *dRight;
  149. * DCELL *c;
  150. *
  151. * returns in "dRight" and "c" the rule values for the positive infinite
  152. * interval (see G_fpreclass_set_pos_infinite_rule ()).
  153. *
  154. * returns: 0 if this rule is not defined
  155. * 1 otherwise.
  156. *
  157. **********************************************************************
  158. *
  159. * void
  160. * G_fpreclass_reverse_rule_order (r)
  161. *
  162. * struct FPReclass *r;
  163. *
  164. * reverses the order in which the reclassification rules are stored. (see
  165. * also G_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
  166. *
  167. **********************************************************************
  168. *
  169. * void
  170. * G_fpreclass_add_rule (r, dLow, dHigh, rLow, rHigh)
  171. *
  172. * struct FPReclass *r;
  173. * DCELL dLow, dHigh;
  174. * DCELL rLow, rHigh;
  175. *
  176. * adds a new rule to the set of reclassification rules. if dLow > dHigh
  177. * the rule will be stored with the low and high values interchanged.
  178. *
  179. * Note: currently no cleanup of rules is performed, i.e. redundant
  180. * rules are not removed.
  181. *
  182. **********************************************************************
  183. *
  184. * DCELL
  185. * G_fpreclass_get_cell_value (r, cellValue)
  186. *
  187. * const struct FPReclass *r;
  188. * DCELL *cellValue;
  189. *
  190. * returns the reclassified value corresponding to "cellValue".
  191. *
  192. * if several reclassification rules apply for cellValue, the one which has
  193. * been inserted latest (i.e. the one of them which is returned by
  194. * G_fpreclass_get_ith_rule() for the largest i) is used. if no such rule
  195. * applies the cellValue is first tested against the negative infinite
  196. * rule, and finally against the positive infinite rule. if none of
  197. * these rules apply, NO_DATA is returned. the actual value of NO_DATA
  198. * is found by calling G_set_d_null_value()
  199. *
  200. * if after G_fpreclass_init (), or any call to G_fpreclass_clear () or
  201. * G_fpreclass_reset () neither G_fpreclass_add_rule (),
  202. * G_fpreclass_set_neg_infinite_rule (),
  203. * G_fpreclass_set_pos_infinite_rule (), * nor G_fpreclass_set_domain ()
  204. * is used NO_DATA is returned independently of the cellValue.
  205. *
  206. * if G_fpreclass_set_domain () is called but no explicit reclassification
  207. * rule is set, the default mapping to the cell range set with
  208. * G_fpreclass_set_range () or, if the cell range is not set,
  209. * to the default CELL range [0,256 - 1] is applied.
  210. *
  211. **********************************************************************
  212. *
  213. * void
  214. * G_fpreclass_perform_XY (r, xcell, ycell, n)
  215. *
  216. * const struct FPReclass *r;
  217. * XCELL *xcell;
  218. * YCELL *ycell;
  219. * int n;
  220. *
  221. * "X" and "Y" in the function name can be any of "d", "f", or "i". These
  222. * correspond to "DCELL", "FCELL", and "CELL", respectively, and denote
  223. * the type of the domain and range values.
  224. *
  225. * returns in "ycell" the reclassified YCELL values corresponding to the
  226. * XCELL values stored in "xcell". the number of elements reclassified
  227. * is n. reclassification is performed by repeated application of
  228. * G_fpreclass_get_cell_value ().
  229. *
  230. **********************************************************************/
  231. /*--------------------------------------------------------------------------*/
  232. /*
  233. the reclassification table is stored as a linear array. rules are added
  234. starting from index 0. redundant rules are not eliminated. rules are tested
  235. from the highest index downto 0. there are two "infinite" rules. support is
  236. provided to reverse the order of the rules.
  237. */
  238. /*--------------------------------------------------------------------------*/
  239. #include <grass/gis.h>
  240. /*--------------------------------------------------------------------------*/
  241. #undef MIN
  242. #undef MAX
  243. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  244. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  245. #define NO_DEFAULT_RULE (! r->defaultDRuleSet)
  246. #define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
  247. #define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
  248. #define NO_FINITE_RULE (r->nofRules <= 0)
  249. #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
  250. NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
  251. #define DEFAULT_MIN ((DCELL) 1)
  252. #define DEFAULT_MAX ((DCELL) 255)
  253. /*--------------------------------------------------------------------------*/
  254. void G_fpreclass_clear(struct FPReclass *r)
  255. {
  256. r->nofRules = 0;
  257. r->defaultDRuleSet = 0;
  258. r->defaultRRuleSet = 0;
  259. r->infiniteRightSet = r->infiniteLeftSet = 0;
  260. }
  261. /*--------------------------------------------------------------------------*/
  262. void G_fpreclass_reset(struct FPReclass *r)
  263. {
  264. G_fpreclass_clear(r);
  265. if (r->maxNofRules > 0)
  266. G_free(r->table);
  267. r->maxNofRules = 0;
  268. }
  269. /*--------------------------------------------------------------------------*/
  270. void G_fpreclass_init(struct FPReclass *r)
  271. {
  272. r->maxNofRules = 0;
  273. G_fpreclass_reset(r);
  274. }
  275. /*--------------------------------------------------------------------------*/
  276. void G_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
  277. {
  278. r->defaultDMin = dLow;
  279. r->defaultDMax = dHigh;
  280. r->defaultDRuleSet = 1;
  281. }
  282. /*--------------------------------------------------------------------------*/
  283. void G_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
  284. {
  285. r->defaultRMin = low;
  286. r->defaultRMax = high;
  287. r->defaultRRuleSet = 1;
  288. }
  289. /*--------------------------------------------------------------------------*/
  290. static void fpreclass_set_limits(struct FPReclass *r,
  291. DCELL dLow, DCELL dHigh,
  292. DCELL rLow, DCELL rHigh)
  293. {
  294. r->dMin = dLow;
  295. r->dMax = dHigh;
  296. r->rMin = rLow;
  297. r->rMax = rHigh;
  298. }
  299. /*--------------------------------------------------------------------------*/
  300. static void fpreclass_update_limits(struct FPReclass *r,
  301. DCELL dLow, DCELL dHigh,
  302. DCELL rLow, DCELL rHigh)
  303. {
  304. if (NO_EXPLICIT_RULE) {
  305. fpreclass_set_limits(r, dLow, dHigh, rLow, rHigh);
  306. return;
  307. }
  308. r->dMin = MIN(r->dMin, MIN(dLow, dHigh));
  309. r->dMax = MAX(r->dMax, MAX(dLow, dHigh));
  310. r->rMin = MIN(r->rMin, MIN(rLow, rHigh));
  311. r->rMax = MAX(r->rMax, MAX(rLow, rHigh));
  312. }
  313. /*--------------------------------------------------------------------------*/
  314. int G_fpreclass_get_limits(const struct FPReclass *r,
  315. DCELL * dMin, DCELL * dMax,
  316. DCELL * rMin, DCELL * rMax)
  317. {
  318. if (NO_EXPLICIT_RULE) {
  319. if (NO_DEFAULT_RULE)
  320. return -1;
  321. *dMin = r->defaultDMin;
  322. *dMax = r->defaultDMax;
  323. if (r->defaultRRuleSet) {
  324. *rMin = r->defaultRMin;
  325. *rMax = r->defaultRMax;
  326. }
  327. else {
  328. *rMin = DEFAULT_MIN;
  329. *rMax = DEFAULT_MAX;
  330. }
  331. return 0;
  332. }
  333. *dMin = r->dMin;
  334. *dMax = r->dMax;
  335. *rMin = r->rMin;
  336. *rMax = r->rMax;
  337. return 1;
  338. }
  339. /*--------------------------------------------------------------------------*/
  340. int G_fpreclass_nof_rules(const struct FPReclass *r)
  341. {
  342. return r->nofRules;
  343. }
  344. /*--------------------------------------------------------------------------*/
  345. void G_fpreclass_get_ith_rule(const struct FPReclass *r, int i,
  346. DCELL *dLow, DCELL *dHigh,
  347. DCELL *rLow, DCELL *rHigh)
  348. {
  349. *dLow = r->table[i].dLow;
  350. *dHigh = r->table[i].dHigh;
  351. *rLow = r->table[i].rLow;
  352. *rHigh = r->table[i].rHigh;
  353. }
  354. /*--------------------------------------------------------------------------*/
  355. static void fpreclass_table_increase(struct FPReclass *r)
  356. {
  357. if (r->nofRules < r->maxNofRules)
  358. return;
  359. if (r->maxNofRules == 0) {
  360. r->maxNofRules = 50;
  361. r->table = (struct FPReclass_table *)
  362. G_malloc(r->maxNofRules * sizeof(struct FPReclass_table));
  363. }
  364. else {
  365. r->maxNofRules += 50;
  366. r->table = (struct FPReclass_table *)
  367. G_realloc((char *)r->table,
  368. r->maxNofRules * sizeof(struct FPReclass_table));
  369. }
  370. }
  371. /*--------------------------------------------------------------------------*/
  372. void
  373. G_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft, DCELL c)
  374. {
  375. r->infiniteDLeft = dLeft;
  376. r->infiniteRLeft = c;
  377. fpreclass_update_limits(r, dLeft, dLeft, c, c);
  378. r->infiniteLeftSet = 1;
  379. }
  380. /*--------------------------------------------------------------------------*/
  381. int G_fpreclass_get_neg_infinite_rule(const struct FPReclass *r,
  382. DCELL *dLeft, DCELL *c)
  383. {
  384. if (r->infiniteLeftSet == 0)
  385. return 0;
  386. *dLeft = r->infiniteDLeft;
  387. *c = r->infiniteRLeft;
  388. return 1;
  389. }
  390. /*--------------------------------------------------------------------------*/
  391. void G_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight, DCELL c)
  392. {
  393. r->infiniteDRight = dRight;
  394. r->infiniteRRight = c;
  395. fpreclass_update_limits(r, dRight, dRight, c, c);
  396. r->infiniteRightSet = 1;
  397. }
  398. /*--------------------------------------------------------------------------*/
  399. int G_fpreclass_get_pos_infinite_rule(const struct FPReclass *r,
  400. DCELL *dRight, DCELL *c)
  401. {
  402. if (r->infiniteRightSet == 0)
  403. return 0;
  404. *dRight = r->infiniteDRight;
  405. *c = r->infiniteRRight;
  406. return 1;
  407. }
  408. /*--------------------------------------------------------------------------*/
  409. void G_fpreclass_add_rule(struct FPReclass *r,
  410. DCELL dLow, DCELL dHigh,
  411. DCELL rLow, DCELL rHigh)
  412. {
  413. int i;
  414. struct FPReclass_table *p;
  415. fpreclass_table_increase(r);
  416. i = r->nofRules;
  417. p = &(r->table[i]);
  418. if (dHigh >= dLow) {
  419. p->dLow = dLow;
  420. p->dHigh = dHigh;
  421. p->rLow = rLow;
  422. p->rHigh = rHigh;
  423. }
  424. else {
  425. p->dLow = dHigh;
  426. p->dHigh = dLow;
  427. p->rLow = rHigh;
  428. p->rHigh = rLow;
  429. }
  430. fpreclass_update_limits(r, dLow, dHigh, rLow, rHigh);
  431. r->nofRules++;
  432. }
  433. /*--------------------------------------------------------------------------*/
  434. void G_fpreclass_reverse_rule_order(struct FPReclass *r)
  435. {
  436. struct FPReclass_table tmp;
  437. struct FPReclass_table *pLeft, *pRight;
  438. pLeft = r->table;
  439. pRight = &(r->table[r->nofRules - 1]);
  440. while (pLeft < pRight) {
  441. tmp.dLow = pLeft->dLow;
  442. tmp.dHigh = pLeft->dHigh;
  443. tmp.rLow = pLeft->rLow;
  444. tmp.rHigh = pLeft->rHigh;
  445. pLeft->dLow = pRight->dLow;
  446. pLeft->dHigh = pRight->dHigh;
  447. pLeft->rLow = pRight->rLow;
  448. pLeft->rHigh = pRight->rHigh;
  449. pRight->dLow = tmp.dLow;
  450. pRight->dHigh = tmp.dHigh;
  451. pRight->rLow = tmp.rLow;
  452. pRight->rHigh = tmp.rHigh;
  453. pLeft++;
  454. pRight--;
  455. }
  456. }
  457. /*--------------------------------------------------------------------------*/
  458. static DCELL fpreclass_interpolate(
  459. DCELL dLow, DCELL dHigh,
  460. DCELL rLow, DCELL rHigh,
  461. DCELL dValue)
  462. {
  463. if (rLow == rHigh)
  464. return rLow;
  465. if (dLow == dHigh)
  466. return rLow;
  467. return ((dValue - dLow) / (dHigh - dLow) * (rHigh - rLow) + rLow);
  468. }
  469. /*--------------------------------------------------------------------------*/
  470. static DCELL fpreclass_get_default_cell_value(const struct FPReclass *r, DCELL cellVal)
  471. {
  472. DCELL tmp;
  473. G_set_d_null_value(&tmp, 1);
  474. if ((cellVal < MIN(r->defaultDMin, r->defaultDMax)) ||
  475. (cellVal > MAX(r->defaultDMin, r->defaultDMax)))
  476. return tmp;
  477. if (r->defaultRRuleSet)
  478. return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
  479. r->defaultRMin, r->defaultRMax, cellVal);
  480. else
  481. return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
  482. DEFAULT_MIN, DEFAULT_MAX, cellVal);
  483. }
  484. /*--------------------------------------------------------------------------*/
  485. DCELL G_fpreclass_get_cell_value(const struct FPReclass * r, DCELL cellVal)
  486. {
  487. DCELL tmp;
  488. const struct FPReclass_table *p;
  489. G_set_d_null_value(&tmp, 1);
  490. if (NO_EXPLICIT_RULE) {
  491. if (NO_DEFAULT_RULE)
  492. return tmp;
  493. return fpreclass_get_default_cell_value(r, cellVal);
  494. }
  495. if (!NO_FINITE_RULE)
  496. for (p = &(r->table[r->nofRules - 1]); p >= r->table; p--)
  497. if ((cellVal >= p->dLow) && (cellVal <= p->dHigh))
  498. return fpreclass_interpolate(p->dLow, p->dHigh, p->rLow,
  499. p->rHigh, cellVal);
  500. if ((!NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
  501. return r->infiniteRLeft;
  502. if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight))
  503. return tmp;
  504. return r->infiniteRRight;
  505. }
  506. /*--------------------------------------------------------------------------*/
  507. void G_fpreclass_perform_di(const struct FPReclass *r,
  508. const DCELL *dcell, CELL *cell, int n)
  509. {
  510. int i;
  511. for (i = 0; i < n; i++, dcell++)
  512. if (!G_is_d_null_value(dcell))
  513. *cell++ = G_fpreclass_get_cell_value(r, *dcell);
  514. else
  515. G_set_c_null_value(cell++, 1);
  516. }
  517. /*--------------------------------------------------------------------------*/
  518. void G_fpreclass_perform_df(const struct FPReclass *r,
  519. const DCELL *dcell, FCELL *cell, int n)
  520. {
  521. int i;
  522. for (i = 0; i < n; i++, dcell++)
  523. if (!G_is_d_null_value(dcell))
  524. *cell++ = G_fpreclass_get_cell_value(r, *dcell);
  525. else
  526. G_set_f_null_value(cell++, 1);
  527. }
  528. /*--------------------------------------------------------------------------*/
  529. void G_fpreclass_perform_dd(const struct FPReclass *r,
  530. const DCELL *dcell, DCELL *cell, int n)
  531. {
  532. int i;
  533. for (i = 0; i < n; i++, dcell++)
  534. if (!G_is_d_null_value(dcell))
  535. *cell++ = G_fpreclass_get_cell_value(r, *dcell);
  536. else
  537. G_set_d_null_value(cell++, 1);
  538. }
  539. /*--------------------------------------------------------------------------*/
  540. void G_fpreclass_perform_fi(const struct FPReclass *r,
  541. const FCELL *fcell, CELL *cell, int n)
  542. {
  543. int i;
  544. for (i = 0; i < n; i++, fcell++)
  545. if (!G_is_f_null_value(fcell))
  546. *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
  547. else
  548. G_set_c_null_value(cell++, 1);
  549. }
  550. /*--------------------------------------------------------------------------*/
  551. void G_fpreclass_perform_ff(const struct FPReclass *r,
  552. const FCELL *fcell, FCELL *cell, int n)
  553. {
  554. int i;
  555. for (i = 0; i < n; i++, fcell++)
  556. if (!G_is_f_null_value(fcell))
  557. *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
  558. else
  559. G_set_f_null_value(cell++, 1);
  560. }
  561. /*--------------------------------------------------------------------------*/
  562. void G_fpreclass_perform_fd(const struct FPReclass *r,
  563. const FCELL *fcell, DCELL *cell, int n)
  564. {
  565. int i;
  566. for (i = 0; i < n; i++, fcell++)
  567. if (!G_is_f_null_value(fcell))
  568. *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
  569. else
  570. G_set_d_null_value(cell++, 1);
  571. }
  572. /*--------------------------------------------------------------------------*/
  573. void G_fpreclass_perform_ii(const struct FPReclass *r,
  574. const CELL *icell, CELL *cell, int n)
  575. {
  576. int i;
  577. for (i = 0; i < n; i++, icell++)
  578. if (!G_is_c_null_value(icell))
  579. *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
  580. else
  581. G_set_c_null_value(cell++, 1);
  582. }
  583. /*--------------------------------------------------------------------------*/
  584. void G_fpreclass_perform_if(const struct FPReclass *r,
  585. const CELL *icell, FCELL *cell, int n)
  586. {
  587. int i;
  588. for (i = 0; i < n; i++, icell++)
  589. if (!G_is_c_null_value(icell))
  590. *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
  591. else
  592. G_set_f_null_value(cell++, 1);
  593. }
  594. /*--------------------------------------------------------------------------*/
  595. void G_fpreclass_perform_id(const struct FPReclass *r,
  596. const CELL *icell, DCELL *cell, int n)
  597. {
  598. int i;
  599. for (i = 0; i < n; i++, icell++)
  600. if (!G_is_c_null_value(icell))
  601. *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
  602. else
  603. G_set_d_null_value(cell++, 1);
  604. }
  605. /*--------------------------------------------------------------------------*/
  606. /*--------------------------------------------------------------------------*/
  607. /*--------------------------------------------------------------------------*/