/* * r.in.xyz support fns. * Copyright 2006 by M. Hamish Bowman, and The GRASS Development Team * Author: M. Hamish Bowman, University of Otago, Dunedin, New Zealand * * This program is free software licensed under the GPL (>=v2). * Read the COPYING file that comes with GRASS for details. * */ #include #include "local_proto.h" int blank_array(void *array, int nrows, int ncols, RASTER_MAP_TYPE map_type, int value) { /* flood fill initialize the array to either 0 or NULL */ /* "value" can be either 0 (for 0.0) or -1 (for NULL) */ int row, col; void *ptr; ptr = array; switch(value) { case 0: /* fill with 0 */ /* simpler to use G_raster_cpy() or similar ?? */ for(row=0; row old_val ) G_set_raster_value_d(ptr, (DCELL)value, map_type); } return 0; } int update_sum(void *array, int cols, int row, int col, RASTER_MAP_TYPE map_type, double value) { void *ptr; DCELL old_val; ptr = array; ptr = G_incr_void_ptr(ptr, ((row*cols)+col)*G_raster_size(map_type)); old_val = G_get_raster_value_d(ptr, map_type); G_set_raster_value_d(ptr, value+old_val, map_type); return 0; } int update_sumsq(void *array, int cols, int row, int col, RASTER_MAP_TYPE map_type, double value) { void *ptr; DCELL old_val; ptr = array; ptr = G_incr_void_ptr(ptr, ((row*cols)+col)*G_raster_size(map_type)); old_val = G_get_raster_value_d(ptr, map_type); G_set_raster_value_d(ptr, (value*value)+old_val, map_type); return 0; }