GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <grass/gis.h> 00002 00003 void c_max(DCELL * result, DCELL * values, int n, const void *closure) 00004 { 00005 DCELL max; 00006 int i; 00007 00008 G_set_d_null_value(&max, 1); 00009 00010 for (i = 0; i < n; i++) { 00011 if (G_is_d_null_value(&values[i])) 00012 continue; 00013 00014 if (G_is_d_null_value(&max) || max < values[i]) 00015 max = values[i]; 00016 } 00017 00018 if (G_is_d_null_value(&max)) 00019 G_set_d_null_value(result, 1); 00020 else 00021 *result = max; 00022 } 00023 00024 void w_max(DCELL * result, DCELL(*values)[2], int n, const void *closure) 00025 { 00026 DCELL max; 00027 int i; 00028 00029 G_set_d_null_value(&max, 1); 00030 00031 for (i = 0; i < n; i++) { 00032 if (G_is_d_null_value(&values[i][0])) 00033 continue; 00034 00035 if (G_is_d_null_value(&max) || max < values[i][0]) 00036 max = values[i][0]; 00037 } 00038 00039 if (G_is_d_null_value(&max)) 00040 G_set_d_null_value(result, 1); 00041 else 00042 *result = max; 00043 }