fpreclass.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /**********************************************************************
  2. *
  3. * Rast_fpreclass_init (r)
  4. *
  5. * struct FPReclass *r;
  6. *
  7. * initializes new reclassification structure. calls
  8. * Rast_fpreclass_clear() before it returns.
  9. *
  10. **********************************************************************
  11. *
  12. * void
  13. * Rast_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 Rast_fpreclass_clear ().
  19. *
  20. **********************************************************************
  21. *
  22. * void
  23. * Rast_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 Rast_fpreclass_set_domain (), Rast_fpreclass_set_range ()).
  29. * deactivates default mapping.
  30. *
  31. **********************************************************************
  32. *
  33. * void
  34. * Rast_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. * Rast_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. * Rast_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 Rast_fpreclass_init (), or any call to
  67. * Rast_fpreclass_clear () or Rast_fpreclass_reset () neither
  68. * Rast_fpreclass_add_rule () nor Rast_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 Rast_fpreclass_set_domain ().
  73. * range values are either reclassification internal default,
  74. * or the values set with Rast_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. * Rast_fpreclass_set_domain ()).
  79. *
  80. **********************************************************************
  81. *
  82. * int
  83. * Rast_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. * Rast_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 < Rast_fpreclass_nof_rules().
  102. * a larger value for i means that the rule has been added later.
  103. *
  104. **********************************************************************
  105. * void
  106. * Rast_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. * Rast_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 Rast_fpreclass_set_neg_infinite_rule ()).
  126. *
  127. * returns: 0 if this rule is not defined
  128. * 1 otherwise.
  129. *
  130. **********************************************************************
  131. * void
  132. * Rast_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. * Rast_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 Rast_fpreclass_set_pos_infinite_rule ()).
  153. *
  154. * returns: 0 if this rule is not defined
  155. * 1 otherwise.
  156. *
  157. **********************************************************************
  158. *
  159. * void
  160. * Rast_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 Rast_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
  166. *
  167. **********************************************************************
  168. *
  169. * void
  170. * Rast_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. * Rast_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. * Rast_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 Rast_set_d_null_value()
  199. *
  200. * if after Rast_fpreclass_init (), or any call to Rast_fpreclass_clear () or
  201. * Rast_fpreclass_reset () neither Rast_fpreclass_add_rule (),
  202. * Rast_fpreclass_set_neg_infinite_rule (),
  203. * Rast_fpreclass_set_pos_infinite_rule (), * nor Rast_fpreclass_set_domain ()
  204. * is used NO_DATA is returned independently of the cellValue.
  205. *
  206. * if Rast_fpreclass_set_domain () is called but no explicit reclassification
  207. * rule is set, the default mapping to the cell range set with
  208. * Rast_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. * Rast_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. #include <grass/raster.h>
  241. /*--------------------------------------------------------------------------*/
  242. #undef MIN
  243. #undef MAX
  244. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  245. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  246. #define NO_DEFAULT_RULE (! r->defaultDRuleSet)
  247. #define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
  248. #define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
  249. #define NO_FINITE_RULE (r->nofRules <= 0)
  250. #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
  251. NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
  252. #define DEFAULT_MIN ((DCELL) 1)
  253. #define DEFAULT_MAX ((DCELL) 255)
  254. /*--------------------------------------------------------------------------*/
  255. void Rast_fpreclass_clear(struct FPReclass *r)
  256. {
  257. r->nofRules = 0;
  258. r->defaultDRuleSet = 0;
  259. r->defaultRRuleSet = 0;
  260. r->infiniteRightSet = r->infiniteLeftSet = 0;
  261. }
  262. /*--------------------------------------------------------------------------*/
  263. void Rast_fpreclass_reset(struct FPReclass *r)
  264. {
  265. Rast_fpreclass_clear(r);
  266. if (r->maxNofRules > 0)
  267. G_free(r->table);
  268. r->maxNofRules = 0;
  269. }
  270. /*--------------------------------------------------------------------------*/
  271. void Rast_fpreclass_init(struct FPReclass *r)
  272. {
  273. r->maxNofRules = 0;
  274. Rast_fpreclass_reset(r);
  275. }
  276. /*--------------------------------------------------------------------------*/
  277. void Rast_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
  278. {
  279. r->defaultDMin = dLow;
  280. r->defaultDMax = dHigh;
  281. r->defaultDRuleSet = 1;
  282. }
  283. /*--------------------------------------------------------------------------*/
  284. void Rast_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
  285. {
  286. r->defaultRMin = low;
  287. r->defaultRMax = high;
  288. r->defaultRRuleSet = 1;
  289. }
  290. /*--------------------------------------------------------------------------*/
  291. static void fpreclass_set_limits(struct FPReclass *r,
  292. DCELL dLow, DCELL dHigh,
  293. DCELL rLow, DCELL rHigh)
  294. {
  295. r->dMin = dLow;
  296. r->dMax = dHigh;
  297. r->rMin = rLow;
  298. r->rMax = rHigh;
  299. }
  300. /*--------------------------------------------------------------------------*/
  301. static void fpreclass_update_limits(struct FPReclass *r,
  302. DCELL dLow, DCELL dHigh,
  303. DCELL rLow, DCELL rHigh)
  304. {
  305. if (NO_EXPLICIT_RULE) {
  306. fpreclass_set_limits(r, dLow, dHigh, rLow, rHigh);
  307. return;
  308. }
  309. r->dMin = MIN(r->dMin, MIN(dLow, dHigh));
  310. r->dMax = MAX(r->dMax, MAX(dLow, dHigh));
  311. r->rMin = MIN(r->rMin, MIN(rLow, rHigh));
  312. r->rMax = MAX(r->rMax, MAX(rLow, rHigh));
  313. }
  314. /*--------------------------------------------------------------------------*/
  315. int Rast_fpreclass_get_limits(const struct FPReclass *r,
  316. DCELL * dMin, DCELL * dMax,
  317. DCELL * rMin, DCELL * rMax)
  318. {
  319. if (NO_EXPLICIT_RULE) {
  320. if (NO_DEFAULT_RULE)
  321. return -1;
  322. *dMin = r->defaultDMin;
  323. *dMax = r->defaultDMax;
  324. if (r->defaultRRuleSet) {
  325. *rMin = r->defaultRMin;
  326. *rMax = r->defaultRMax;
  327. }
  328. else {
  329. *rMin = DEFAULT_MIN;
  330. *rMax = DEFAULT_MAX;
  331. }
  332. return 0;
  333. }
  334. *dMin = r->dMin;
  335. *dMax = r->dMax;
  336. *rMin = r->rMin;
  337. *rMax = r->rMax;
  338. return 1;
  339. }
  340. /*--------------------------------------------------------------------------*/
  341. int Rast_fpreclass_nof_rules(const struct FPReclass *r)
  342. {
  343. return r->nofRules;
  344. }
  345. /*--------------------------------------------------------------------------*/
  346. void Rast_fpreclass_get_ith_rule(const struct FPReclass *r, int i,
  347. DCELL * dLow, DCELL * dHigh,
  348. DCELL * rLow, DCELL * rHigh)
  349. {
  350. *dLow = r->table[i].dLow;
  351. *dHigh = r->table[i].dHigh;
  352. *rLow = r->table[i].rLow;
  353. *rHigh = r->table[i].rHigh;
  354. }
  355. /*--------------------------------------------------------------------------*/
  356. static void fpreclass_table_increase(struct FPReclass *r)
  357. {
  358. if (r->nofRules < r->maxNofRules)
  359. return;
  360. if (r->maxNofRules == 0) {
  361. r->maxNofRules = 50;
  362. r->table = (struct FPReclass_table *)
  363. G_malloc(r->maxNofRules * sizeof(struct FPReclass_table));
  364. }
  365. else {
  366. r->maxNofRules += 50;
  367. r->table = (struct FPReclass_table *)
  368. G_realloc((char *)r->table,
  369. r->maxNofRules * sizeof(struct FPReclass_table));
  370. }
  371. }
  372. /*--------------------------------------------------------------------------*/
  373. void
  374. Rast_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft,
  375. DCELL c)
  376. {
  377. r->infiniteDLeft = dLeft;
  378. r->infiniteRLeft = c;
  379. fpreclass_update_limits(r, dLeft, dLeft, c, c);
  380. r->infiniteLeftSet = 1;
  381. }
  382. /*--------------------------------------------------------------------------*/
  383. int Rast_fpreclass_get_neg_infinite_rule(const struct FPReclass *r,
  384. DCELL * dLeft, DCELL * c)
  385. {
  386. if (r->infiniteLeftSet == 0)
  387. return 0;
  388. *dLeft = r->infiniteDLeft;
  389. *c = r->infiniteRLeft;
  390. return 1;
  391. }
  392. /*--------------------------------------------------------------------------*/
  393. void Rast_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight,
  394. DCELL c)
  395. {
  396. r->infiniteDRight = dRight;
  397. r->infiniteRRight = c;
  398. fpreclass_update_limits(r, dRight, dRight, c, c);
  399. r->infiniteRightSet = 1;
  400. }
  401. /*--------------------------------------------------------------------------*/
  402. int Rast_fpreclass_get_pos_infinite_rule(const struct FPReclass *r,
  403. DCELL * dRight, DCELL * c)
  404. {
  405. if (r->infiniteRightSet == 0)
  406. return 0;
  407. *dRight = r->infiniteDRight;
  408. *c = r->infiniteRRight;
  409. return 1;
  410. }
  411. /*--------------------------------------------------------------------------*/
  412. void Rast_fpreclass_add_rule(struct FPReclass *r,
  413. DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh)
  414. {
  415. int i;
  416. struct FPReclass_table *p;
  417. fpreclass_table_increase(r);
  418. i = r->nofRules;
  419. p = &(r->table[i]);
  420. if (dHigh >= dLow) {
  421. p->dLow = dLow;
  422. p->dHigh = dHigh;
  423. p->rLow = rLow;
  424. p->rHigh = rHigh;
  425. }
  426. else {
  427. p->dLow = dHigh;
  428. p->dHigh = dLow;
  429. p->rLow = rHigh;
  430. p->rHigh = rLow;
  431. }
  432. fpreclass_update_limits(r, dLow, dHigh, rLow, rHigh);
  433. r->nofRules++;
  434. }
  435. /*--------------------------------------------------------------------------*/
  436. void Rast_fpreclass_reverse_rule_order(struct FPReclass *r)
  437. {
  438. struct FPReclass_table tmp;
  439. struct FPReclass_table *pLeft, *pRight;
  440. pLeft = r->table;
  441. pRight = &(r->table[r->nofRules - 1]);
  442. while (pLeft < pRight) {
  443. tmp.dLow = pLeft->dLow;
  444. tmp.dHigh = pLeft->dHigh;
  445. tmp.rLow = pLeft->rLow;
  446. tmp.rHigh = pLeft->rHigh;
  447. pLeft->dLow = pRight->dLow;
  448. pLeft->dHigh = pRight->dHigh;
  449. pLeft->rLow = pRight->rLow;
  450. pLeft->rHigh = pRight->rHigh;
  451. pRight->dLow = tmp.dLow;
  452. pRight->dHigh = tmp.dHigh;
  453. pRight->rLow = tmp.rLow;
  454. pRight->rHigh = tmp.rHigh;
  455. pLeft++;
  456. pRight--;
  457. }
  458. }
  459. /*--------------------------------------------------------------------------*/
  460. static DCELL fpreclass_interpolate(DCELL dLow, DCELL dHigh,
  461. DCELL rLow, DCELL rHigh, 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,
  471. DCELL cellVal)
  472. {
  473. DCELL tmp;
  474. Rast_set_d_null_value(&tmp, 1);
  475. if ((cellVal < MIN(r->defaultDMin, r->defaultDMax)) ||
  476. (cellVal > MAX(r->defaultDMin, r->defaultDMax)))
  477. return tmp;
  478. if (r->defaultRRuleSet)
  479. return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
  480. r->defaultRMin, r->defaultRMax, cellVal);
  481. else
  482. return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
  483. DEFAULT_MIN, DEFAULT_MAX, cellVal);
  484. }
  485. /*--------------------------------------------------------------------------*/
  486. DCELL Rast_fpreclass_get_cell_value(const struct FPReclass * r, DCELL cellVal)
  487. {
  488. DCELL tmp;
  489. const struct FPReclass_table *p;
  490. Rast_set_d_null_value(&tmp, 1);
  491. if (NO_EXPLICIT_RULE) {
  492. if (NO_DEFAULT_RULE)
  493. return tmp;
  494. return fpreclass_get_default_cell_value(r, cellVal);
  495. }
  496. if (!NO_FINITE_RULE)
  497. for (p = &(r->table[r->nofRules - 1]); p >= r->table; p--)
  498. if ((cellVal >= p->dLow) && (cellVal <= p->dHigh))
  499. return fpreclass_interpolate(p->dLow, p->dHigh, p->rLow,
  500. p->rHigh, cellVal);
  501. if ((!NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
  502. return r->infiniteRLeft;
  503. if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight))
  504. return tmp;
  505. return r->infiniteRRight;
  506. }
  507. /*--------------------------------------------------------------------------*/
  508. void Rast_fpreclass_perform_di(const struct FPReclass *r,
  509. const DCELL * dcell, CELL * cell, int n)
  510. {
  511. int i;
  512. for (i = 0; i < n; i++, dcell++)
  513. if (!Rast_is_d_null_value(dcell))
  514. *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
  515. else
  516. Rast_set_c_null_value(cell++, 1);
  517. }
  518. /*--------------------------------------------------------------------------*/
  519. void Rast_fpreclass_perform_df(const struct FPReclass *r,
  520. const DCELL * dcell, FCELL * cell, int n)
  521. {
  522. int i;
  523. for (i = 0; i < n; i++, dcell++)
  524. if (!Rast_is_d_null_value(dcell))
  525. *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
  526. else
  527. Rast_set_f_null_value(cell++, 1);
  528. }
  529. /*--------------------------------------------------------------------------*/
  530. void Rast_fpreclass_perform_dd(const struct FPReclass *r,
  531. const DCELL * dcell, DCELL * cell, int n)
  532. {
  533. int i;
  534. for (i = 0; i < n; i++, dcell++)
  535. if (!Rast_is_d_null_value(dcell))
  536. *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
  537. else
  538. Rast_set_d_null_value(cell++, 1);
  539. }
  540. /*--------------------------------------------------------------------------*/
  541. void Rast_fpreclass_perform_fi(const struct FPReclass *r,
  542. const FCELL * fcell, CELL * cell, int n)
  543. {
  544. int i;
  545. for (i = 0; i < n; i++, fcell++)
  546. if (!Rast_is_f_null_value(fcell))
  547. *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * fcell);
  548. else
  549. Rast_set_c_null_value(cell++, 1);
  550. }
  551. /*--------------------------------------------------------------------------*/
  552. void Rast_fpreclass_perform_ff(const struct FPReclass *r,
  553. const FCELL * fcell, FCELL * cell, int n)
  554. {
  555. int i;
  556. for (i = 0; i < n; i++, fcell++)
  557. if (!Rast_is_f_null_value(fcell))
  558. *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * fcell);
  559. else
  560. Rast_set_f_null_value(cell++, 1);
  561. }
  562. /*--------------------------------------------------------------------------*/
  563. void Rast_fpreclass_perform_fd(const struct FPReclass *r,
  564. const FCELL * fcell, DCELL * cell, int n)
  565. {
  566. int i;
  567. for (i = 0; i < n; i++, fcell++)
  568. if (!Rast_is_f_null_value(fcell))
  569. *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * fcell);
  570. else
  571. Rast_set_d_null_value(cell++, 1);
  572. }
  573. /*--------------------------------------------------------------------------*/
  574. void Rast_fpreclass_perform_ii(const struct FPReclass *r,
  575. const CELL * icell, CELL * cell, int n)
  576. {
  577. int i;
  578. for (i = 0; i < n; i++, icell++)
  579. if (!Rast_is_c_null_value(icell))
  580. *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * icell);
  581. else
  582. Rast_set_c_null_value(cell++, 1);
  583. }
  584. /*--------------------------------------------------------------------------*/
  585. void Rast_fpreclass_perform_if(const struct FPReclass *r,
  586. const CELL * icell, FCELL * cell, int n)
  587. {
  588. int i;
  589. for (i = 0; i < n; i++, icell++)
  590. if (!Rast_is_c_null_value(icell))
  591. *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * icell);
  592. else
  593. Rast_set_f_null_value(cell++, 1);
  594. }
  595. /*--------------------------------------------------------------------------*/
  596. void Rast_fpreclass_perform_id(const struct FPReclass *r,
  597. const CELL * icell, DCELL * cell, int n)
  598. {
  599. int i;
  600. for (i = 0; i < n; i++, icell++)
  601. if (!Rast_is_c_null_value(icell))
  602. *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * icell);
  603. else
  604. Rast_set_d_null_value(cell++, 1);
  605. }
  606. /*--------------------------------------------------------------------------*/
  607. /*--------------------------------------------------------------------------*/
  608. /*--------------------------------------------------------------------------*/