[GRASS-SVN] r72621 - grass/branches/releasebranch_7_4/raster/r.in.gdal

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 16 02:27:51 PDT 2018


Author: mmetz
Date: 2018-04-16 02:27:51 -0700 (Mon, 16 Apr 2018)
New Revision: 72621

Modified:
   grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c
Log:
r.in.gdal: fix column offset and column mapping when limiting import to the current region (backport trunk r72620)

Modified: grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c	2018-04-16 09:26:53 UTC (rev 72620)
+++ grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c	2018-04-16 09:27:51 UTC (rev 72621)
@@ -514,9 +514,12 @@
 	if (first == -1)
 	    G_fatal_error(_("Input raster does not overlap current "
 			    "computational region. Nothing to import."));
+
+	G_debug(1, "first row in cur wind %d, first row in source %d", first, rowmapall[first]);
 	rowmap = &rowmapall[first];
 	/* crop window */
 	if (first != 0 || last != cur_wind.rows - 1) {
+	    G_debug(1, "Cropping NS extents");
 	    cur_wind.north -= first * cur_wind.ns_res;
 	    cur_wind.south += (cur_wind.rows - 1 - last) * cur_wind.ns_res;
 	    cur_wind.rows = last - first + 1;
@@ -541,10 +544,13 @@
 	if (first == -1)
 	    G_fatal_error(_("Input raster does not overlap current "
 			    "computational region. Nothing to import."));
-	col_offset = first;
+
+	G_debug(1, "first col in cur wind %d, first col in source %d", first, colmapall[first]);
+	col_offset = colmapall[first];
 	colmap = &colmapall[first];
 	/* crop window */
 	if (first != 0 || last != cur_wind.cols - 1) {
+	    G_debug(1, "Cropping EW extents");
 	    cur_wind.west += first * cur_wind.ew_res;
 	    cur_wind.east -= (cur_wind.cols - 1 - last) * cur_wind.ew_res;
 	    cur_wind.cols = last - first + 1;
@@ -1022,8 +1028,8 @@
     map_cols = 0;
     use_cell_gdal = 1;
 
-    for (indx = col_offset; indx < ncols; indx++) {
-	if (indx > 0 && colmap[indx] != colmap[indx - 1] + 1) {
+    for (indx = 0; indx < ncols; indx++) {
+	if (indx != colmap[indx] - col_offset) {
 	    map_cols = 1;
 	    use_cell_gdal = 0;
 	}
@@ -1035,6 +1041,8 @@
 	    break;
 	}
     }
+    G_debug(1, "column mapping: %d", map_cols);
+    G_debug(1, "use cell_gdal: %d", use_cell_gdal);
     dfNoData = GDALGetRasterNoDataValue(hBand, &bNoDataEnabled);
     if (bNoDataEnabled && !nullFlags) {
 	nullFlags = (char *)G_malloc(sizeof(char) * ncols);



More information about the grass-commit mailing list