[GRASS-SVN] r50119 - in grass/branches/releasebranch_6_4:
raster/r.external raster/r.in.gdal vector/v.in.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jan 10 00:34:37 EST 2012
Author: hamish
Date: 2012-01-09 21:34:37 -0800 (Mon, 09 Jan 2012)
New Revision: 50119
Modified:
grass/branches/releasebranch_6_4/raster/r.external/main.c
grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c
grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c
Log:
Modules are only allowed to modify the current mapset. (#1507, merge r49734 and r49799 from devbr6)
Modified: grass/branches/releasebranch_6_4/raster/r.external/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.external/main.c 2012-01-10 03:44:25 UTC (rev 50118)
+++ grass/branches/releasebranch_6_4/raster/r.external/main.c 2012-01-10 05:34:37 UTC (rev 50119)
@@ -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,34 @@
/* Extend current window based on dataset. */
/* -------------------------------------------------------------------- */
- struct Cell_head def_wind;
+ struct Cell_head cur_wind;
- G_get_default_window(&def_wind);
+ if (strcmp(G_mapset(), "PERMANENT") == 0)
+ /* fixme: expand WIND and DEFAULT_WIND independently. (currently
+ WIND gets forgotten and DEFAULT_WIND is expanded for both) */
+ G_get_default_window(&cur_wind);
+ else
+ G_get_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");
+ if (strcmp(G_mapset(), "PERMANENT") == 0) {
+ G__put_window(&cur_wind, "", "DEFAULT_WIND");
+ G_message(_("Default region for this location updated"));
+ }
+ G_put_window(&cur_wind);
+ G_message(_("Region for the current mapset updated"));
}
static void query_band(GDALRasterBandH hBand, const char *output, int exact_range,
@@ -547,7 +557,9 @@
flag_e = G_define_flag();
flag_e->key = 'e';
- flag_e->description = _("Extend location extents based on new dataset");
+ flag_e->label = _("Extend region extents based on new dataset");
+ flag_e->description =
+ _("Also updates the default region if in the PERMANENT mapset");
flag_r = G_define_flag();
flag_r->key = 'r';
Modified: grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c 2012-01-10 03:44:25 UTC (rev 50118)
+++ grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c 2012-01-10 05:34:37 UTC (rev 50119)
@@ -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,9 @@
flag_e = G_define_flag();
flag_e->key = 'e';
- flag_e->description = _("Extend location extents based on new dataset");
+ flag_e->label = _("Extend region extents based on new dataset");
+ flag_e->description =
+ _("Also updates the default region if in the PERMANENT mapset");
flag_f = G_define_flag();
flag_f->key = 'f';
@@ -343,7 +345,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 +360,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 +596,32 @@
/* Extend current window based on dataset. */
/* -------------------------------------------------------------------- */
if (flag_e->answer) {
- G_get_default_window(&def_wind);
+ if (strcmp(G_mapset(), "PERMANENT") == 0)
+ /* fixme: expand WIND and DEFAULT_WIND independently. (currently
+ WIND gets forgotten and DEFAULT_WIND is expanded for both) */
+ G_get_default_window(&cur_wind);
+ else
+ G_get_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");
+ if (strcmp(G_mapset(), "PERMANENT") == 0) {
+ G__put_window(&cur_wind, "", "DEFAULT_WIND");
+ G_message(_("Default region for this location updated"));
+ }
+ G_put_window(&cur_wind);
+ G_message(_("Region for the current mapset updated"));
}
exit(EXIT_SUCCESS);
Modified: grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c 2012-01-10 03:44:25 UTC (rev 50118)
+++ grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c 2012-01-10 05:34:37 UTC (rev 50119)
@@ -227,8 +227,10 @@
extend_flag = G_define_flag();
extend_flag->key = 'e';
+ extend_flag->label =
+ _("Extend region extents based on new dataset");
extend_flag->description =
- _("Extend location extents based on new dataset");
+ _("Also updates the default region if in the PERMANENT mapset");
tolower_flag = G_define_flag();
tolower_flag->key = 'w';
@@ -496,7 +498,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();
@@ -695,30 +697,18 @@
}
/** Simple 32bit integer OFTInteger = 0 **/
-
/** List of 32bit integers OFTIntegerList = 1 **/
-
/** Double Precision floating point OFTReal = 2 **/
-
/** List of doubles OFTRealList = 3 **/
-
/** String of ASCII chars OFTString = 4 **/
-
/** Array of strings OFTStringList = 5 **/
-
/** Double byte string (unsupported) OFTWideString = 6 **/
-
/** List of wide strings (unsupported) OFTWideStringList = 7 **/
-
/** Raw Binary data (unsupported) OFTBinary = 8 **/
-
/** OFTDate = 9 **/
-
/** OFTTime = 10 **/
-
/** OFTDateTime = 11 **/
-
if (Ogr_ftype == OFTInteger) {
sprintf(buf, ", %s integer", Ogr_fieldname);
}
@@ -1186,22 +1176,32 @@
/* Extend current window based on dataset. */
/* -------------------------------------------------------------------- */
if (extend_flag->answer) {
- G_get_default_window(&loc_wind);
+ if (strcmp(G_mapset(), "PERMANENT") == 0)
+ /* fixme: expand WIND and DEFAULT_WIND independently. (currently
+ WIND gets forgotten and DEFAULT_WIND is expanded for both) */
+ G_get_default_window(&cur_wind);
+ else
+ G_get_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");
+ if (strcmp(G_mapset(), "PERMANENT") == 0) {
+ G__put_window(&cur_wind, "", "DEFAULT_WIND");
+ G_message(_("Default region for this location updated"));
+ }
+ G_put_window(&cur_wind);
+ G_message(_("Region for the current mapset updated"));
}
if (with_z && !z_flag->answer)
More information about the grass-commit
mailing list