c_maxx.c 517 B

123456789101112131415161718192021222324252627
  1. #include <grass/gis.h>
  2. #include <grass/raster.h>
  3. void c_maxx(DCELL * result, DCELL * values, int n, const void *closure)
  4. {
  5. DCELL max, maxx;
  6. int i;
  7. Rast_set_d_null_value(&max, 1);
  8. Rast_set_d_null_value(&maxx, 1);
  9. for (i = 0; i < n; i++) {
  10. if (Rast_is_d_null_value(&values[i]))
  11. continue;
  12. if (Rast_is_d_null_value(&max) || max < values[i]) {
  13. max = values[i];
  14. maxx = i;
  15. }
  16. }
  17. if (Rast_is_d_null_value(&maxx))
  18. Rast_set_d_null_value(result, 1);
  19. else
  20. *result = maxx;
  21. }