[GRASS-SVN] r51714 - in grass/trunk/lib/raster3d: . test
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 24 12:53:14 EDT 2012
Author: huhabla
Date: 2012-05-24 09:53:13 -0700 (Thu, 24 May 2012)
New Revision: 51714
Modified:
grass/trunk/lib/raster3d/cachehash.c
grass/trunk/lib/raster3d/test/test_put_get_value.c
Log:
Hunting cache hash 3D raster bug
Modified: grass/trunk/lib/raster3d/cachehash.c
===================================================================
--- grass/trunk/lib/raster3d/cachehash.c 2012-05-24 16:47:45 UTC (rev 51713)
+++ grass/trunk/lib/raster3d/cachehash.c 2012-05-24 16:53:13 UTC (rev 51714)
@@ -52,15 +52,15 @@
{
Rast3d_cache_hash *tmp;
- tmp = Rast3d_malloc(sizeof(Rast3d_cache_hash));
+ tmp = (Rast3d_cache_hash *)Rast3d_malloc(sizeof(Rast3d_cache_hash));
if (tmp == NULL) {
Rast3d_error("Rast3d_cache_hash_new: error in Rast3d_malloc");
return (void *)NULL;
}
-
+
tmp->nofNames = nofNames;
- tmp->index = Rast3d_malloc(sizeof(int) * tmp->nofNames);
- tmp->active = Rast3d_malloc(sizeof(char) * tmp->nofNames);
+ tmp->index = (int*) Rast3d_malloc(tmp->nofNames * sizeof(int));
+ tmp->active = (char*) Rast3d_malloc(tmp->nofNames * sizeof(char));
if ((tmp->index == NULL) || (tmp->active == NULL)) {
Rast3d_cache_hash_dispose(tmp);
Rast3d_error("Rast3d_cache_hash_new: error in Rast3d_malloc");
@@ -77,10 +77,10 @@
void Rast3d_cache_hash_remove_name(Rast3d_cache_hash * h, int name)
{
if (name >= h->nofNames)
- Rast3d_fatal_error("Rast3d_cache_hash_remove_name: name out of range");
+ Rast3d_fatal_error("Rast3d_cache_hash_remove_name: name %i out of range", name);
if (h->active[name] == 0)
- Rast3d_fatal_error("Rast3d_cache_hash_remove_name: name not in hashtable");
+ Rast3d_fatal_error("Rast3d_cache_hash_remove_name: name %i not in hashtable", name);
h->active[name] = 0;
if (name == h->lastName)
Modified: grass/trunk/lib/raster3d/test/test_put_get_value.c
===================================================================
--- grass/trunk/lib/raster3d/test/test_put_get_value.c 2012-05-24 16:47:45 UTC (rev 51713)
+++ grass/trunk/lib/raster3d/test/test_put_get_value.c 2012-05-24 16:53:13 UTC (rev 51714)
@@ -19,9 +19,11 @@
#include "test_g3d_lib.h"
#include "grass/interpf.h"
+static int test_large_file(void);
static int test_put_get_value_dcell(void);
static int test_put_get_value_fcell(void);
static int test_put_get_value_resampling(void);
+static int test_get_value_region(RASTER3D_Map *map, int cols, int rows, int depths);
static int test_resampling_dcell(RASTER3D_Map *map, double north, double east, double
top, int col, int row, int depth, int fact);
static int test_resampling_fcell(RASTER3D_Map *map, double north, double east, double
@@ -39,6 +41,7 @@
sum += test_put_get_value_dcell();
sum += test_put_get_value_fcell();
sum += test_put_get_value_resampling();
+ sum += test_large_file();
if (sum > 0)
@@ -551,4 +554,60 @@
}
return sum;
-}
\ No newline at end of file
+}
+
+
+/* *************************************************************** */
+
+int test_large_file(void)
+{
+ int sum = 0;
+ int x, y, z;
+ FCELL value;
+ FCELL value_ref;
+
+ G_message("Testing FCELL put function for large files");
+
+ RASTER3D_Region region;
+ RASTER3D_Map *map = NULL;
+
+ /* We need to set up a specific region for the new g3d map.
+ * First we safe the default region. */
+ Rast3d_get_window(®ion);
+
+ region.bottom = 0.0;
+ region.top = 1000;
+ region.south = 1000;
+ region.north = 8500;
+ region.west = 5000;
+ region.east = 10000;
+ region.rows = 100;
+ region.cols = 100;
+ region.depths = 100;
+
+ Rast3d_adjust_region(®ion);
+
+ map = Rast3d_open_new_opt_tile_size("test_put_get_value_fcell_large", RASTER3D_USE_CACHE_XY, ®ion, FCELL_TYPE, 1);
+
+ /* The window is the same as the map region ... of course */
+ Rast3d_set_window_map(map, ®ion);
+
+ for(z = 0; z < region.depths; z++) {
+ for(y = 0; y < region.rows; y++) {
+ for(x = 0; x < region.cols; x++) {
+ /* Add cols, rows and depths and put this in the map */
+ value = x + y + z;
+ Rast3d_put_value(map, x, y, z, &value, FCELL_TYPE);
+ }
+ }
+ }
+ /* Write everything to the disk */
+ Rast3d_flush_all_tiles(map);
+ Rast3d_close(map);
+
+ //G_remove("grid3", "test_put_get_value_dcell_large");
+
+ return sum;
+}
+
+
More information about the grass-commit
mailing list