[GRASS-SVN] r38520 - in grass/trunk: include lib/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 25 06:26:30 EDT 2009


Author: glynn
Date: 2009-07-25 06:26:29 -0400 (Sat, 25 Jul 2009)
New Revision: 38520

Modified:
   grass/trunk/include/rasterdefs.h
   grass/trunk/lib/raster/R.h
   grass/trunk/lib/raster/gdal.c
   grass/trunk/lib/raster/get_row.c
   grass/trunk/lib/raster/init.c
   grass/trunk/lib/raster/opencell.c
   grass/trunk/lib/raster/put_row.c
   grass/trunk/lib/raster/set_window.c
   grass/trunk/lib/raster/window_map.c
Log:
Remove R__.window[_set], Rast__init_window



Modified: grass/trunk/include/rasterdefs.h
===================================================================
--- grass/trunk/include/rasterdefs.h	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/include/rasterdefs.h	2009-07-25 10:26:29 UTC (rev 38520)
@@ -503,7 +503,6 @@
 int Rast_set_window(struct Cell_head *);
 
 /* window_map.c */
-void Rast__init_window(void);
 void Rast__create_window_mapping(int);
 int Rast_row_repeat_nomask(int, int);
 

Modified: grass/trunk/lib/raster/R.h
===================================================================
--- grass/trunk/lib/raster/R.h	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/R.h	2009-07-25 10:26:29 UTC (rev 38520)
@@ -73,8 +73,6 @@
 struct R__			/*  Structure of library globals */
 {
     RASTER_MAP_TYPE fp_type;	/* type for writing floating maps */
-    struct Cell_head window;	/* Contains the current window          */
-    int window_set;		/* Flag: window set?                    */
     int mask_fd;		/* File descriptor for automatic mask   */
     int auto_mask;		/* Flag denoting automatic masking      */
     int want_histogram;

Modified: grass/trunk/lib/raster/gdal.c
===================================================================
--- grass/trunk/lib/raster/gdal.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/gdal.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -8,6 +8,7 @@
 #include <grass/raster.h>
 #include <grass/glocale.h>
 
+#include "../gis/G.h"
 #include "R.h"
 
 #ifndef HAVE_GDAL
@@ -418,8 +419,8 @@
     /* Does driver support GDALCreate ? */
     if ((*pGDALGetMetadataItem) (driver, GDAL_DCAP_CREATE, NULL)) {
 	gdal->data =
-	    (*pGDALCreate) (driver, gdal->filename, R__.window.cols,
-			    R__.window.rows, 1, gdal->type, st->opts.options);
+	    (*pGDALCreate) (driver, gdal->filename, G__.window.cols,
+			    G__.window.rows, 1, gdal->type, st->opts.options);
 	if (!gdal->data)
 	    G_fatal_error(_("Unable to create <%s> dataset using <%s> driver"),
 			  name, st->opts.format);
@@ -438,7 +439,7 @@
 	    G_fatal_error(_("Unable to get in-memory raster driver"));
 
 	gdal->data =
-	    (*pGDALCreate) (mem_driver, "", R__.window.cols, R__.window.rows,
+	    (*pGDALCreate) (mem_driver, "", G__.window.cols, G__.window.rows,
 			    1, gdal->type, st->opts.options);
 	if (!gdal->data)
 	    G_fatal_error(_("Unable to create <%s> dataset using memory driver"),
@@ -453,12 +454,12 @@
     (*pGDALSetRasterNoDataValue) (gdal->band, gdal->null_val);
 
     /* Set Geo Transform  */
-    transform[0] = R__.window.west;
-    transform[1] = R__.window.ew_res;
+    transform[0] = G__.window.west;
+    transform[1] = G__.window.ew_res;
     transform[2] = 0.0;
-    transform[3] = R__.window.north;
+    transform[3] = G__.window.north;
     transform[4] = 0.0;
-    transform[5] = -R__.window.ns_res;
+    transform[5] = -G__.window.ns_res;
 
     if ((*pGDALSetGeoTransform) (gdal->data, transform) >= CE_Failure)
 	G_warning(_("Unable to set geo transform"));

Modified: grass/trunk/lib/raster/get_row.c
===================================================================
--- grass/trunk/lib/raster/get_row.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/get_row.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -22,6 +22,7 @@
 #include <grass/raster.h>
 #include <grass/glocale.h>
 
+#include "../gis/G.h"
 #include "R.h"
 
 #define NULL_FILE   "null"
@@ -35,7 +36,7 @@
     int r;
 
     /* check for row in window */
-    if (row < 0 || row >= R__.window.rows) {
+    if (row < 0 || row >= G__.window.rows) {
 	G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
 		  fcb->name, fcb->mapset, row);
 
@@ -65,7 +66,7 @@
     CELL max = fcb->reclass.max;
     int i;
 
-    for (i = 0; i < R__.window.cols; i++) {
+    for (i = 0; i < G__.window.cols; i++) {
 	if (Rast_is_c_null_value(&c[i])) {
 	    if (null_is_zero)
 		c[i] = 0;
@@ -487,23 +488,23 @@
     if (fcb->gdal)
 	(gdal_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
 					   fcb->cur_nbytes, cell,
-					   R__.window.cols);
+					   G__.window.cols);
     else
 #endif
 	(cell_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
 					   fcb->cur_nbytes, cell,
-					   R__.window.cols);
+					   G__.window.cols);
 }
 
 static void transfer_to_cell_fi(int fd, void *cell)
 {
     struct fileinfo *fcb = &R__.fileinfo[fd];
-    FCELL *work_buf = G__alloca(R__.window.cols * sizeof(FCELL));
+    FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
     int i;
 
     transfer_to_cell_XX(fd, work_buf);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	((CELL *) cell)[i] = (fcb->col_map[i] == 0)
 	    ? 0 : Rast_quant_get_cell_value(&fcb->quant, work_buf[i]);
 
@@ -513,12 +514,12 @@
 static void transfer_to_cell_di(int fd, void *cell)
 {
     struct fileinfo *fcb = &R__.fileinfo[fd];
-    DCELL *work_buf = G__alloca(R__.window.cols * sizeof(DCELL));
+    DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
     int i;
 
     transfer_to_cell_XX(fd, work_buf);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	((CELL *) cell)[i] = (fcb->col_map[i] == 0)
 	    ? 0 : Rast_quant_get_cell_value(&fcb->quant, work_buf[i]);
 
@@ -527,12 +528,12 @@
 
 static void transfer_to_cell_if(int fd, void *cell)
 {
-    CELL *work_buf = G__alloca(R__.window.cols * sizeof(CELL));
+    CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
     int i;
 
     transfer_to_cell_XX(fd, work_buf);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	((FCELL *) cell)[i] = work_buf[i];
 
     G__freea(work_buf);
@@ -540,12 +541,12 @@
 
 static void transfer_to_cell_df(int fd, void *cell)
 {
-    DCELL *work_buf = G__alloca(R__.window.cols * sizeof(DCELL));
+    DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
     int i;
 
     transfer_to_cell_XX(fd, work_buf);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	((FCELL *) cell)[i] = work_buf[i];
 
     G__freea(work_buf);
@@ -553,12 +554,12 @@
 
 static void transfer_to_cell_id(int fd, void *cell)
 {
-    CELL *work_buf = G__alloca(R__.window.cols * sizeof(CELL));
+    CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
     int i;
 
     transfer_to_cell_XX(fd, work_buf);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	((DCELL *) cell)[i] = work_buf[i];
 
     G__freea(work_buf);
@@ -566,12 +567,12 @@
 
 static void transfer_to_cell_fd(int fd, void *cell)
 {
-    FCELL *work_buf = G__alloca(R__.window.cols * sizeof(FCELL));
+    FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
     int i;
 
     transfer_to_cell_XX(fd, work_buf);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	((DCELL *) cell)[i] = work_buf[i];
 
     G__freea(work_buf);
@@ -657,7 +658,7 @@
     int i;
 
     if (fcb->reclass_flag && data_type != CELL_TYPE) {
-	temp_buf = G__alloca(R__.window.cols * sizeof(CELL));
+	temp_buf = G__alloca(G__.window.cols * sizeof(CELL));
 	buf = temp_buf;
 	type = CELL_TYPE;
     }
@@ -685,7 +686,7 @@
     if (data_type == CELL_TYPE)
 	return 1;
 
-    for (i = 0; i < R__.window.cols; i++) {
+    for (i = 0; i < G__.window.cols; i++) {
 	Rast_set_c_value(rast, temp_buf[i], data_type);
 	rast = G_incr_void_ptr(rast, size);
     }
@@ -971,7 +972,7 @@
     struct fileinfo *fcb = &R__.fileinfo[fd];
     int i, j, null_fd;
 
-    if (row > R__.window.rows || row < 0) {
+    if (row > G__.window.rows || row < 0) {
 	G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
 		  fcb->name, fcb->mapset, row);
     }
@@ -992,8 +993,8 @@
 	null_fd = open_null_read(fd);
 
 	for (i = 0; i < NULL_ROWS_INMEM; i++) {
-	    /* R__.window.rows doesn't have to be a multiple of NULL_ROWS_INMEM */
-	    if (i + fcb->min_null_row >= R__.window.rows)
+	    /* G__.window.rows doesn't have to be a multiple of NULL_ROWS_INMEM */
+	    if (i + fcb->min_null_row >= G__.window.rows)
 		break;
 
 	    if (read_null_bits(null_fd, null_work_buf,
@@ -1002,11 +1003,11 @@
 		if (fcb->map_type == CELL_TYPE) {
 		    /* If can't read null row, assume  that all map 0's are nulls */
 		    CELL *mask_buf =
-			G__alloca(R__.window.cols * sizeof(CELL));
+			G__alloca(G__.window.cols * sizeof(CELL));
 
 		    get_map_row_nomask(fd, mask_buf, i + fcb->min_null_row,
 				       CELL_TYPE);
-		    for (j = 0; j < R__.window.cols; j++)
+		    for (j = 0; j < G__.window.cols; j++)
 			flags[j] = (mask_buf[j] == 0);
 
 		    G__freea(mask_buf);
@@ -1014,15 +1015,15 @@
 		else {		/* fp map */
 
 		    /* if can't read null row, assume  that all data is valid */
-		    G_zero(flags, sizeof(char) * R__.window.cols);
+		    G_zero(flags, sizeof(char) * G__.window.cols);
 		    /* the flags row is ready now */
 		}
 	    }			/*if no null file */
 	    else {
 		/* copy null row to flags row translated by window column mapping */
-		/* the fcb->NULL_ROWS[row-fcb->min_null_row] has R__.window.cols bits, */
+		/* the fcb->NULL_ROWS[row-fcb->min_null_row] has G__.window.cols bits, */
 		/* the null_work_buf has size fcb->cellhd.cols */
-		for (j = 0; j < R__.window.cols; j++) {
+		for (j = 0; j < G__.window.cols; j++) {
 		    if (!fcb->col_map[j])
 			flags[j] = 1;
 		    else
@@ -1036,15 +1037,12 @@
 	    /*bf-We should take of the size - or we get 
 	       zeros running on their own after flags convertions -A.Sh. */
 	    fcb->NULL_ROWS[i] = G_realloc(fcb->NULL_ROWS[i],
-					  Rast__null_bitstream_size(R__.
-								    window.
-								    cols) +
-					  1);
+					  Rast__null_bitstream_size(G__.window.cols) +1);
 	    if (fcb->NULL_ROWS[i] == NULL)
 		G_fatal_error("get_null_value_row_nomask: %s",
 			      _("Unable to realloc buffer"));
 
-	    Rast__convert_01_flags(flags, fcb->NULL_ROWS[i], R__.window.cols);
+	    Rast__convert_01_flags(flags, fcb->NULL_ROWS[i], G__.window.cols);
 
 	}			/* for loop */
 
@@ -1055,9 +1053,9 @@
     }				/* row is not in memory */
 
     /* copy null file data translated by column mapping to user null row */
-    /* the user requested flags row is of size R__.window.cols */
+    /* the user requested flags row is of size G__.window.cols */
     Rast__convert_flags_01(flags, fcb->NULL_ROWS[row - fcb->min_null_row],
-			   R__.window.cols);
+			   G__.window.cols);
 }
 
 /*--------------------------------------------------------------------------*/
@@ -1071,12 +1069,12 @@
     int i;
 
     if (get_map_row_nomask(fd, tmp_buf, row, DCELL_TYPE) <= 0) {
-	memset(flags, 1, R__.window.cols);
+	memset(flags, 1, G__.window.cols);
 	G_free(tmp_buf);
 	return;
     }
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	/* note: using == won't work if the null value is NaN */
 	flags[i] =
 	    memcmp(&tmp_buf[i], &fcb->gdal->null_val, sizeof(DCELL)) == 0;
@@ -1092,7 +1090,7 @@
 
 static void embed_mask(char *flags, int row)
 {
-    CELL *mask_buf = G__alloca(R__.window.cols * sizeof(CELL));
+    CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
     int i;
 
     if (R__.auto_mask <= 0)
@@ -1106,7 +1104,7 @@
     if (R__.fileinfo[R__.mask_fd].reclass_flag)
 	do_reclass_int(R__.mask_fd, mask_buf, 1);
 
-    for (i = 0; i < R__.window.cols; i++)
+    for (i = 0; i < G__.window.cols; i++)
 	if (mask_buf[i] == 0)
 	    flags[i] = 1;
 
@@ -1141,11 +1139,11 @@
 	&& (R__.auto_mask <= 0 || !with_mask))
 	return 1;
 
-    null_buf = G__alloca(R__.window.cols);
+    null_buf = G__alloca(G__.window.cols);
 
     get_null_value_row(fd, null_buf, row, with_mask);
 
-    for (i = 0; i < R__.window.cols; i++) {
+    for (i = 0; i < G__.window.cols; i++) {
 	/* also check for nulls which might be already embedded by quant
 	   rules in case of fp map. */
 	if (null_buf[i] || Rast_is_null_value(buf, map_type)) {

Modified: grass/trunk/lib/raster/init.c
===================================================================
--- grass/trunk/lib/raster/init.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/init.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -73,6 +73,8 @@
 
 static int init(void)
 {
+    G__init_window();
+
     /* no histograms */
     R__.want_histogram = 0;
 

Modified: grass/trunk/lib/raster/opencell.c
===================================================================
--- grass/trunk/lib/raster/opencell.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/opencell.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -25,6 +25,7 @@
 #include <grass/raster.h>
 #include <grass/glocale.h>
 
+#include "../gis/G.h"
 #include "R.h"
 #define FORMAT_FILE "f_format"
 
@@ -170,9 +171,6 @@
 
     Rast__init();
 
-    /* make sure window is set    */
-    Rast__init_window();
-
     G__unqualified_name(name, mapset, xname, xmapset);
     name = xname;
     mapset = xmapset;
@@ -224,16 +222,16 @@
 	}
     }
 
-    if (cellhd.proj != R__.window.proj) {
+    if (cellhd.proj != G__.window.proj) {
 	G_warning(_("Raster map <%s@%s> is in different projection than current region. "
 		   "Found raster map <%s@%s>, should be <%s>."), name, mapset,
 		  name, G__projection_name(cellhd.proj),
-		  G__projection_name(R__.window.proj));
+		  G__projection_name(G__.window.proj));
 	return -1;
     }
-    if (cellhd.zone != R__.window.zone) {
+    if (cellhd.zone != G__.window.zone) {
 	G_warning(_("Raster map <%s@%s> is in different zone (%d) than current region (%d)"),
-		  name, mapset, cellhd.zone, R__.window.zone);
+		  name, mapset, cellhd.zone, G__.window.zone);
 	return -1;
     }
 
@@ -289,7 +287,7 @@
 
     /* allocate null bitstream buffers for reading null rows */
     for (i = 0; i < NULL_ROWS_INMEM; i++)
-	fcb->NULL_ROWS[i] = Rast__allocate_null_bits(R__.window.cols);
+	fcb->NULL_ROWS[i] = Rast__allocate_null_bits(G__.window.cols);
     /* initialize : no NULL rows in memory */
     fcb->min_null_row = (-1) * NULL_ROWS_INMEM;
 
@@ -512,12 +510,12 @@
     if (!fcb->gdal)
 	return -1;
 
-    fcb->cellhd = R__.window;
+    fcb->cellhd = G__.window;
     fcb->cellhd.compressed = 0;
     fcb->nbytes = Rast_cell_size(fcb->map_type);
-    /* for writing fcb->data is allocated to be R__.window.cols * 
+    /* for writing fcb->data is allocated to be G__.window.cols * 
        sizeof(CELL or DCELL or FCELL)  */
-    fcb->data = G_calloc(R__.window.cols, fcb->nbytes);
+    fcb->data = G_calloc(G__.window.cols, fcb->nbytes);
 
     fcb->name = map;
     fcb->mapset = mapset;
@@ -598,9 +596,6 @@
 	return -1;
     }
 
-    /* make sure window is set */
-    Rast__init_window();
-
 #ifdef HAVE_GDAL
     if (G_find_file2("", "GDAL", G_mapset()))
 	return G__open_raster_new_gdal(map, mapset, map_type);
@@ -629,9 +624,9 @@
     fcb->open_mode = -1;
     fcb->gdal = NULL;
 
-    /* for writing fcb->data is allocated to be R__.window.cols * 
+    /* for writing fcb->data is allocated to be G__.window.cols * 
        sizeof(CELL or DCELL or FCELL)  */
-    fcb->data = (unsigned char *)G_calloc(R__.window.cols,
+    fcb->data = (unsigned char *)G_calloc(G__.window.cols,
 					  Rast_cell_size(fcb->map_type));
 
     /*
@@ -640,7 +635,7 @@
      * for compressed writing
      *   allocate space to hold the row address array
      */
-    G_copy((char *)&fcb->cellhd, (char *)&R__.window, sizeof(fcb->cellhd));
+    G_copy((char *)&fcb->cellhd, (char *)&G__.window, sizeof(fcb->cellhd));
 
     if (open_mode == OPEN_NEW_COMPRESSED && fcb->map_type == CELL_TYPE) {
 	fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));

Modified: grass/trunk/lib/raster/put_row.c
===================================================================
--- grass/trunk/lib/raster/put_row.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/put_row.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -26,6 +26,7 @@
 #include <grass/raster.h>
 #include <grass/glocale.h>
 
+#include "../gis/G.h"
 #include "R.h"
 
 static int put_raster_data(int, char *, const void *, int, int, int,
@@ -278,7 +279,7 @@
     if (n <= 0)
 	return 0;
 
-    work_buf = G__alloca(R__.window.cols * fcb->nbytes + 1);
+    work_buf = G__alloca(G__.window.cols * fcb->nbytes + 1);
 
     if (compressed)
 	set_file_pointer(fd, row);
@@ -455,7 +456,7 @@
     if (n <= 0)
 	return 0;
 
-    work_buf = G__alloca(R__.window.cols * sizeof(CELL) + 1);
+    work_buf = G__alloca(G__.window.cols * sizeof(CELL) + 1);
     wk = work_buf;
 
     if (compressed)

Modified: grass/trunk/lib/raster/set_window.c
===================================================================
--- grass/trunk/lib/raster/set_window.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/set_window.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -74,10 +74,8 @@
     }
 
     /* copy the window to the current window */
-    G_copy((char *)&R__.window, (char *)window, sizeof(*window));
+    G_set_window(window);
 
-    R__.window_set = 1;
-
     /* now for each possible open cell file, recreate the window mapping */
     /*
      * also the memory for reading and writing must be reallocated for all opened
@@ -98,7 +96,7 @@
 	else {
 	    /* opened for writing */
 	    G_free(fcb->data);
-	    fcb->data = (unsigned char *)G_calloc(R__.window.cols,
+	    fcb->data = (unsigned char *)G_calloc(G__.window.cols,
 						  Rast_cell_size(fcb->
 								 map_type));
 	}
@@ -106,7 +104,7 @@
 	/* allocate null bitstream buffers for reading/writing null rows */
 	for (j = 0; j < NULL_ROWS_INMEM; j++) {
 	    G_free(fcb->NULL_ROWS[j]);
-	    fcb->NULL_ROWS[j] = (R__.window.cols);
+	    fcb->NULL_ROWS[j] = (G__.window.cols);
 	}
 
 

Modified: grass/trunk/lib/raster/window_map.c
===================================================================
--- grass/trunk/lib/raster/window_map.c	2009-07-24 11:18:42 UTC (rev 38519)
+++ grass/trunk/lib/raster/window_map.c	2009-07-25 10:26:29 UTC (rev 38520)
@@ -15,6 +15,7 @@
 #include <grass/gis.h>
 #include <grass/raster.h>
 
+#include "../gis/G.h"
 #include "R.h"
 
 
@@ -39,14 +40,12 @@
     double C1, C2;
     double west;
 
-    Rast__init_window();
-
     if (fcb->open_mode >= 0 && fcb->open_mode != OPEN_OLD)	/* open for write? */
 	return;
     if (fcb->open_mode == OPEN_OLD)	/* already open ? */
 	G_free(fcb->col_map);
 
-    col = fcb->col_map = alloc_index(R__.window.cols);
+    col = fcb->col_map = alloc_index(G__.window.cols);
 
     /*
      * for each column in the window, go to center of the cell,
@@ -56,18 +55,18 @@
      * for lat/lon move window so that west is bigger than
      * cellhd west.
      */
-    west = R__.window.west;
-    if (R__.window.proj == PROJECTION_LL) {
+    west = G__.window.west;
+    if (G__.window.proj == PROJECTION_LL) {
 	while (west > fcb->cellhd.west + 360.0)
 	    west -= 360.0;
 	while (west < fcb->cellhd.west)
 	    west += 360.0;
     }
 
-    C1 = R__.window.ew_res / fcb->cellhd.ew_res;
+    C1 = G__.window.ew_res / fcb->cellhd.ew_res;
     C2 = (west - fcb->cellhd.west +
-	  R__.window.ew_res / 2.0) / fcb->cellhd.ew_res;
-    for (i = 0; i < R__.window.cols; i++) {
+	  G__.window.ew_res / 2.0) / fcb->cellhd.ew_res;
+    for (i = 0; i < G__.window.cols; i++) {
 	x = C2;
 	if (C2 < x)		/* adjust for rounding of negatives */
 	    x--;
@@ -78,11 +77,11 @@
     }
 
     /* do wrap around for lat/lon */
-    if (R__.window.proj == PROJECTION_LL) {
+    if (G__.window.proj == PROJECTION_LL) {
 	col = fcb->col_map;
 	C2 = (west - 360.0 - fcb->cellhd.west +
-	      R__.window.ew_res / 2.0) / fcb->cellhd.ew_res;
-	for (i = 0; i < R__.window.cols; i++) {
+	      G__.window.ew_res / 2.0) / fcb->cellhd.ew_res;
+	for (i = 0; i < G__.window.cols; i++) {
 	    x = C2;
 	    if (C2 < x)		/* adjust for rounding of negatives */
 		x--;
@@ -95,39 +94,21 @@
 	}
     }
 
-    G_debug(3, "create window mapping (%d columns)", R__.window.cols);
-    /*  for (i = 0; i < R__.window.cols; i++)
+    G_debug(3, "create window mapping (%d columns)", G__.window.cols);
+    /*  for (i = 0; i < G__.window.cols; i++)
        fprintf(stderr, "%s%ld", i % 15 ? " " : "\n", (long)fcb->col_map[i]);
        fprintf(stderr, "\n");
      */
 
     /* compute C1,C2 for row window mapping */
-    fcb->C1 = R__.window.ns_res / fcb->cellhd.ns_res;
+    fcb->C1 = G__.window.ns_res / fcb->cellhd.ns_res;
     fcb->C2 =
-	(fcb->cellhd.north - R__.window.north +
-	 R__.window.ns_res / 2.0) / fcb->cellhd.ns_res;
+	(fcb->cellhd.north - G__.window.north +
+	 G__.window.ns_res / 2.0) / fcb->cellhd.ns_res;
 }
 
 
 /*!
- * \brief Initialize window.
- *
- */
-void Rast__init_window(void)
-{
-    Rast__init();
-
-    if (G_is_initialized(&R__.window_set))
-	return;
-
-    G__init_window();
-
-    G_get_window(&R__.window);
-
-    G_initialize_done(&R__.window_set);
-}
-
-/*!
  * \brief Loops rows until mismatch?.
  *
  * This routine works fine if the mask is not set. It may give
@@ -158,7 +139,7 @@
     if (f < r1)
 	r1--;
 
-    while (++row < R__.window.rows) {
+    while (++row < G__.window.rows) {
 	f = row * fcb->C1 + fcb->C2;
 	r2 = f;
 	if (f < r2)



More information about the grass-commit mailing list