Browse Source

Modules are only allowed to modify the current mapset. (https://trac.osgeo.org/grass/ticket/1507)
Checking projection against DEFAULT_WIND is more reliable.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49733 15284696-431f-4ddb-bdfa-cd5b030d7da7

Hamish Bowman 13 năm trước cách đây
mục cha
commit
cbc8a32901

+ 1 - 1
raster/r.external/main.c

@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
 
     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';

+ 1 - 1
raster/r.external/proj.c

@@ -22,7 +22,7 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int override)
 	/*      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();

+ 13 - 13
raster/r.external/window.c

@@ -66,22 +66,22 @@ void update_default_window(struct Cell_head *cellhd)
     /*      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);
 }

+ 16 - 17
raster/r.in.gdal/main.c

@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
     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;
@@ -141,7 +141,7 @@ int main(int argc, char *argv[])
 
     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';
@@ -358,7 +358,7 @@ int main(int argc, char *argv[])
 	    /*      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();
@@ -373,8 +373,7 @@ int main(int argc, char *argv[])
 		     || (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,
@@ -609,22 +608,22 @@ int main(int argc, char *argv[])
     /*      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);

+ 14 - 14
vector/v.in.ogr/main.c

@@ -256,7 +256,7 @@ int main(int argc, char *argv[])
     flag.extend = G_define_flag();
     flag.extend->key = 'e';
     flag.extend->description =
-	_("Extend location extents based on new dataset");
+	_("Extend region extents based on new dataset");
 
     flag.tolower = G_define_flag();
     flag.tolower->key = 'w';
@@ -538,7 +538,7 @@ int main(int argc, char *argv[])
 
 	/* 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();
@@ -1242,22 +1242,22 @@ int main(int argc, char *argv[])
     /*      Extend current window based on dataset.                         */
     /* -------------------------------------------------------------------- */
     if (flag.extend->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 && !flag.z->answer)