[GRASS-SVN] r49734 - in grass/branches/develbranch_6: raster/r.external raster/r.in.gdal vector/v.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 14 04:55:01 EST 2011


Author: hamish
Date: 2011-12-14 01:55:01 -0800 (Wed, 14 Dec 2011)
New Revision: 49734

Modified:
   grass/branches/develbranch_6/raster/r.external/main.c
   grass/branches/develbranch_6/raster/r.in.gdal/main.c
   grass/branches/develbranch_6/vector/v.in.ogr/main.c
Log:
Modules are only allowed to modify the current mapset. (#1507)
Checking projection against DEFAULT_WIND is more reliable.
 (merge from trunk)


Modified: grass/branches/develbranch_6/raster/r.external/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.external/main.c	2011-12-14 09:33:15 UTC (rev 49733)
+++ grass/branches/develbranch_6/raster/r.external/main.c	2011-12-14 09:55:01 UTC (rev 49734)
@@ -87,7 +87,7 @@
 	/*      Does the projection of the current location match the           */
 	/*      dataset?                                                        */
 	/* -------------------------------------------------------------------- */
-	G_get_window(&loc_wind);
+	G_get_default_window(&loc_wind);
 	if (loc_wind.proj != PROJECTION_XY) {
 	    loc_proj_info = G_get_projinfo();
 	    loc_proj_units = G_get_projunits();
@@ -237,24 +237,24 @@
     /*      Extend current window based on dataset.                         */
     /* -------------------------------------------------------------------- */
 
-    struct Cell_head def_wind;
+    struct Cell_head cur_wind;
 
-    G_get_default_window(&def_wind);
+    G_get_set_window(&cur_wind);
 
-    def_wind.north = MAX(def_wind.north, cellhd->north);
-    def_wind.south = MIN(def_wind.south, cellhd->south);
-    def_wind.west = MIN(def_wind.west, cellhd->west);
-    def_wind.east = MAX(def_wind.east, cellhd->east);
+    cur_wind.north = MAX(cur_wind.north, cellhd->north);
+    cur_wind.south = MIN(cur_wind.south, cellhd->south);
+    cur_wind.west = MIN(cur_wind.west, cellhd->west);
+    cur_wind.east = MAX(cur_wind.east, cellhd->east);
 
-    def_wind.rows = (int)ceil((def_wind.north - def_wind.south)
-			      / def_wind.ns_res);
-    def_wind.south = def_wind.north - def_wind.rows * def_wind.ns_res;
+    cur_wind.rows = (int)ceil((cur_wind.north - cur_wind.south)
+			      / cur_wind.ns_res);
+    cur_wind.south = cur_wind.north - cur_wind.rows * cur_wind.ns_res;
 
-    def_wind.cols = (int)ceil((def_wind.east - def_wind.west)
-			      / def_wind.ew_res);
-    def_wind.east = def_wind.west + def_wind.cols * def_wind.ew_res;
+    cur_wind.cols = (int)ceil((cur_wind.east - cur_wind.west)
+			      / cur_wind.ew_res);
+    cur_wind.east = cur_wind.west + cur_wind.cols * cur_wind.ew_res;
 
-    G__put_window(&def_wind, "../PERMANENT", "DEFAULT_WIND");
+    G_put_window(&cur_wind);
 }
 
 static void query_band(GDALRasterBandH hBand, const char *output, int exact_range,
@@ -547,7 +547,7 @@
 
     flag_e = G_define_flag();
     flag_e->key = 'e';
-    flag_e->description = _("Extend location extents based on new dataset");
+    flag_e->description = _("Extend region extents based on new dataset");
 
     flag_r = G_define_flag();
     flag_r->key = 'r';

Modified: grass/branches/develbranch_6/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.in.gdal/main.c	2011-12-14 09:33:15 UTC (rev 49733)
+++ grass/branches/develbranch_6/raster/r.in.gdal/main.c	2011-12-14 09:55:01 UTC (rev 49734)
@@ -51,7 +51,7 @@
     char *input;
     char *output;
     char *title;
-    struct Cell_head cellhd, loc_wind, def_wind;
+    struct Cell_head cellhd, loc_wind, cur_wind;
     struct Key_Value *proj_info = NULL, *proj_units = NULL;
     struct Key_Value *loc_proj_info = NULL, *loc_proj_units = NULL;
     GDALDatasetH hDS;
@@ -135,7 +135,7 @@
 
     flag_e = G_define_flag();
     flag_e->key = 'e';
-    flag_e->description = _("Extend location extents based on new dataset");
+    flag_e->description = _("Extend region extents based on new dataset");
 
     flag_f = G_define_flag();
     flag_f->key = 'f';
@@ -343,7 +343,7 @@
 	    /*      Does the projection of the current location match the           */
 	    /*      dataset?                                                        */
 	    /* -------------------------------------------------------------------- */
-	    G_get_window(&loc_wind);
+	    G_get_default_window(&loc_wind);
 	    if (loc_wind.proj != PROJECTION_XY) {
 		loc_proj_info = G_get_projinfo();
 		loc_proj_units = G_get_projunits();
@@ -358,8 +358,7 @@
 		     || (projcomp_error = G_compare_projections(loc_proj_info,
 								loc_proj_units,
 								proj_info,
-								proj_units)) <
-		     0) {
+								proj_units)) < 0) {
 		int i_value;
 
 		strcpy(error_msg,
@@ -595,22 +594,22 @@
     /*      Extend current window based on dataset.                         */
     /* -------------------------------------------------------------------- */
     if (flag_e->answer) {
-	G_get_default_window(&def_wind);
+	G_get_set_window(&cur_wind);
 
-	def_wind.north = MAX(def_wind.north, cellhd.north);
-	def_wind.south = MIN(def_wind.south, cellhd.south);
-	def_wind.west = MIN(def_wind.west, cellhd.west);
-	def_wind.east = MAX(def_wind.east, cellhd.east);
+	cur_wind.north = MAX(cur_wind.north, cellhd.north);
+	cur_wind.south = MIN(cur_wind.south, cellhd.south);
+	cur_wind.west = MIN(cur_wind.west, cellhd.west);
+	cur_wind.east = MAX(cur_wind.east, cellhd.east);
 
-	def_wind.rows = (int)ceil((def_wind.north - def_wind.south)
-				  / def_wind.ns_res);
-	def_wind.south = def_wind.north - def_wind.rows * def_wind.ns_res;
+	cur_wind.rows = (int)ceil((cur_wind.north - cur_wind.south)
+				  / cur_wind.ns_res);
+	cur_wind.south = cur_wind.north - cur_wind.rows * cur_wind.ns_res;
 
-	def_wind.cols = (int)ceil((def_wind.east - def_wind.west)
-				  / def_wind.ew_res);
-	def_wind.east = def_wind.west + def_wind.cols * def_wind.ew_res;
+	cur_wind.cols = (int)ceil((cur_wind.east - cur_wind.west)
+				  / cur_wind.ew_res);
+	cur_wind.east = cur_wind.west + cur_wind.cols * cur_wind.ew_res;
 
-	G__put_window(&def_wind, "../PERMANENT", "DEFAULT_WIND");
+	G_put_window(&cur_wind);
     }
 
     exit(EXIT_SUCCESS);

Modified: grass/branches/develbranch_6/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.ogr/main.c	2011-12-14 09:33:15 UTC (rev 49733)
+++ grass/branches/develbranch_6/vector/v.in.ogr/main.c	2011-12-14 09:55:01 UTC (rev 49734)
@@ -228,7 +228,7 @@
     extend_flag = G_define_flag();
     extend_flag->key = 'e';
     extend_flag->description =
-	_("Extend location extents based on new dataset");
+	_("Extend region extents based on new dataset");
 
     tolower_flag = G_define_flag();
     tolower_flag->key = 'w';
@@ -496,7 +496,7 @@
 
 	/* Does the projection of the current location match the dataset? */
 	/* G_get_window seems to be unreliable if the location has been changed */
-	G__get_window(&loc_wind, "", "DEFAULT_WIND", "PERMANENT");
+	G_get_default_window(&loc_wind);
 	/* fetch LOCATION PROJ info */
 	if (loc_wind.proj != PROJECTION_XY) {
 	    loc_proj_info = G_get_projinfo();
@@ -1186,22 +1186,22 @@
     /*      Extend current window based on dataset.                         */
     /* -------------------------------------------------------------------- */
     if (extend_flag->answer) {
-	G_get_default_window(&loc_wind);
+	G_get_set_window(&cur_wind);
 
-	loc_wind.north = MAX(loc_wind.north, cellhd.north);
-	loc_wind.south = MIN(loc_wind.south, cellhd.south);
-	loc_wind.west = MIN(loc_wind.west, cellhd.west);
-	loc_wind.east = MAX(loc_wind.east, cellhd.east);
+	cur_wind.north = MAX(cur_wind.north, cellhd.north);
+	cur_wind.south = MIN(cur_wind.south, cellhd.south);
+	cur_wind.west = MIN(cur_wind.west, cellhd.west);
+	cur_wind.east = MAX(cur_wind.east, cellhd.east);
 
-	loc_wind.rows = (int)ceil((loc_wind.north - loc_wind.south)
-				  / loc_wind.ns_res);
-	loc_wind.south = loc_wind.north - loc_wind.rows * loc_wind.ns_res;
+	cur_wind.rows = (int)ceil((cur_wind.north - cur_wind.south)
+				  / cur_wind.ns_res);
+	cur_wind.south = cur_wind.north - cur_wind.rows * cur_wind.ns_res;
 
-	loc_wind.cols = (int)ceil((loc_wind.east - loc_wind.west)
-				  / loc_wind.ew_res);
-	loc_wind.east = loc_wind.west + loc_wind.cols * loc_wind.ew_res;
+	cur_wind.cols = (int)ceil((cur_wind.east - cur_wind.west)
+				  / cur_wind.ew_res);
+	cur_wind.east = cur_wind.west + cur_wind.cols * cur_wind.ew_res;
 
-	G__put_window(&loc_wind, "../PERMANENT", "DEFAULT_WIND");
+	G_put_window(&cur_wind);
     }
 
     if (with_z && !z_flag->answer)



More information about the grass-commit mailing list