Browse Source

trap if current region resolution is higher than map resolution

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36813 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 16 years ago
parent
commit
82f24e1aa3
2 changed files with 7 additions and 1 deletions
  1. 6 1
      raster/r.topidx/file_io.c
  2. 1 0
      raster/r.topidx/main.c

+ 6 - 1
raster/r.topidx/file_io.c

@@ -10,12 +10,14 @@ void getcells(void)
     RASTER_MAP_TYPE data_type;
     CELL *ccell = NULL;
     FCELL *fcell = NULL;
-
+    struct Cell_head inhead;
 
     if ((fd = G_open_cell_old(iname, "")) < 0)
 	G_fatal_error(_("Cannot open raster map <%s>"), iname);
 
     data_type = G_get_raster_map_type(fd);
+    if (G_get_cellhd(iname, "", &inhead) < 0 )
+	G_fatal_error(_("Unable to read header of raster map <%s>"), iname);
 
     if (data_type == CELL_TYPE)
 	ccell = (CELL *) G_malloc(sizeof(CELL) * window.cols);
@@ -26,6 +28,9 @@ void getcells(void)
     atb = (DCELL **) G_malloc(sizeof(DCELL *) * window.rows);
     a = (DCELL **) G_malloc(sizeof(DCELL *) * window.rows);
 
+    if ((window.ew_res < inhead.ew_res) || (window.ns_res < inhead.ns_res))
+        G_fatal_error(_("Current region resolution [%.2fx%.2f] lower than input map resolution [%.2fx%.2f]! Needs to be at least identical or the current region resolution lower than the input map resolution"),window.ew_res, window.ns_res, inhead.ew_res, inhead.ns_res);
+
     G_important_message(_("Reading elevation map..."));
 
     for (i = 0; i < window.rows; i++) {

+ 1 - 0
raster/r.topidx/main.c

@@ -18,6 +18,7 @@
  *
  *****************************************************************************/
 
+#include <grass/gis.h>
 #include <grass/glocale.h>
 #include "global.h"