GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <grass/gis.h> 00002 00003 void c_maxx(DCELL * result, DCELL * values, int n, const void *closure) 00004 { 00005 DCELL max, maxx; 00006 int i; 00007 00008 G_set_d_null_value(&max, 1); 00009 G_set_d_null_value(&maxx, 1); 00010 00011 for (i = 0; i < n; i++) { 00012 if (G_is_d_null_value(&values[i])) 00013 continue; 00014 00015 if (G_is_d_null_value(&max) || max < values[i]) { 00016 max = values[i]; 00017 maxx = i; 00018 } 00019 } 00020 00021 if (G_is_d_null_value(&maxx)) 00022 G_set_d_null_value(result, 1); 00023 else 00024 *result = maxx; 00025 }