[GRASS-SVN] r70664 - in grass/trunk/raster: r.external r.in.gdal r.region

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 22 08:54:36 PST 2017


Author: mmetz
Date: 2017-02-22 08:54:36 -0800 (Wed, 22 Feb 2017)
New Revision: 70664

Modified:
   grass/trunk/raster/r.external/main.c
   grass/trunk/raster/r.in.gdal/main.c
   grass/trunk/raster/r.region/main.c
Log:
r.in.gdal, r.external, r.region: add flag to auto-adjust cell header in lat/lon

Modified: grass/trunk/raster/r.external/main.c
===================================================================
--- grass/trunk/raster/r.external/main.c	2017-02-22 16:50:39 UTC (rev 70663)
+++ grass/trunk/raster/r.external/main.c	2017-02-22 16:54:36 UTC (rev 70664)
@@ -44,7 +44,7 @@
 	struct Option *input, *source, *output, *band, *title;
     } parm;
     struct {
-	struct Flag *o, *f, *e, *h, *v, *t;
+	struct Flag *o, *f, *e, *h, *v, *t, *a;
     } flag;
     int min_band, max_band, band;
     struct band_info info;
@@ -108,6 +108,11 @@
     flag.e->label = _("Extend region extents based on new dataset");
     flag.e->description = _("Also updates the default region if in the PERMANENT mapset");
 
+    flag.a = G_define_flag();
+    flag.a->key = 'a';
+    flag.a->label = _("Auto-adjustment for lat/lon");
+    flag.a->description = _("Attempt to fix small precision errors in resolution and extents");
+
     flag.h = G_define_flag();
     flag.h->key = 'h';
     flag.h->description = _("Flip horizontally");
@@ -188,6 +193,11 @@
 
     check_projection(&cellhd, hDS, flag.o->answer);
 
+    if (flag.a->answer && cellhd.proj == PROJECTION_LL) {
+	G_adjust_Cell_head(&cellhd, 1, 1);
+	G_adjust_window_ll(&cellhd);
+    }
+
     Rast_set_window(&cellhd);
 
     if (parm.band->answer)

Modified: grass/trunk/raster/r.in.gdal/main.c
===================================================================
--- grass/trunk/raster/r.in.gdal/main.c	2017-02-22 16:50:39 UTC (rev 70663)
+++ grass/trunk/raster/r.in.gdal/main.c	2017-02-22 16:54:36 UTC (rev 70664)
@@ -79,7 +79,7 @@
 	              *rat;
     } parm;
     struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l, *flag_c, *flag_p,
-        *flag_j;
+        *flag_j, *flag_a;
 
     /* -------------------------------------------------------------------- */
     /*      Initialize.                                                     */
@@ -208,6 +208,11 @@
     flag_l->description =
 	_("Force Lat/Lon maps to fit into geographic coordinates (90N,S; 180E,W)");
 
+    flag_a = G_define_flag();
+    flag_a->key = 'a';
+    flag_a->label = _("Auto-adjustment for lat/lon");
+    flag_a->description = _("Attempt to fix small precision errors in resolution and extents");
+
     flag_k = G_define_flag();
     flag_k->key = 'k';
     flag_k->description =
@@ -379,10 +384,12 @@
 	cellhd.ns_res = fabs(adfGeoTransform[5]);
 	cellhd.ns_res3 = fabs(adfGeoTransform[5]);
 	cellhd.south = cellhd.north - cellhd.ns_res * cellhd.rows;
+
 	cellhd.west = adfGeoTransform[0];
 	cellhd.ew_res = fabs(adfGeoTransform[1]);
 	cellhd.ew_res3 = fabs(adfGeoTransform[1]);
 	cellhd.east = cellhd.west + cellhd.cols * cellhd.ew_res;
+
 	cellhd.top = 1.;
 	cellhd.bottom = 0.;
 	cellhd.tb_res = 1.;
@@ -581,12 +588,17 @@
 	}
     }
 
-    G_message(_("Proceeding with import of %d raster bands..."),
-              GDALGetRasterCount(hDS));
+    if (GDALGetRasterCount(hDS) > 1)
+	G_message(_("Importing %d raster bands..."),
+		  GDALGetRasterCount(hDS));
 
     /* -------------------------------------------------------------------- */
     /*      Set the active window to match the available data.              */
     /* -------------------------------------------------------------------- */
+    if (flag_a->answer && cellhd.proj == PROJECTION_LL) {
+	G_adjust_Cell_head(&cellhd, 1, 1);
+	G_adjust_window_ll(&cellhd);
+    }
     Rast_set_window(&cellhd);
 
     /* -------------------------------------------------------------------- */

Modified: grass/trunk/raster/r.region/main.c
===================================================================
--- grass/trunk/raster/r.region/main.c	2017-02-22 16:50:39 UTC (rev 70663)
+++ grass/trunk/raster/r.region/main.c	2017-02-22 16:54:36 UTC (rev 70664)
@@ -35,7 +35,7 @@
     struct GModule *module;
     struct
     {
-	struct Flag *dflt, *cur;
+	struct Flag *dflt, *cur, *llauto;
     } flag;
     struct
     {
@@ -65,6 +65,12 @@
     flag.dflt->description = _("Set from default region");
     flag.dflt->guisection = _("Existing");
 
+    flag.llauto = G_define_flag();
+    flag.llauto->key = 'a';
+    flag.llauto->label = _("Auto-adjustment for lat/lon");
+    flag.llauto->description = _("Attempt to fix small precision errors in resolution and extents");
+    flag.llauto->guisection = _("Existing");
+
     /* parameters */
 
     parm.map = G_define_standard_option(G_OPT_R_MAP);
@@ -281,10 +287,16 @@
 
     G_adjust_Cell_head(&window, 1, 1);
 
+    if (flag.llauto->answer && cellhd.proj == PROJECTION_LL) {
+	G_adjust_window_ll(&window);
+    }
+
     cellhd.north = window.north;
     cellhd.south = window.south;
     cellhd.east = window.east;
     cellhd.west = window.west;
+    cellhd.ns_res = window.ns_res;
+    cellhd.ew_res = window.ew_res;
 
     Rast_put_cellhd(parm.map->answer, &cellhd);
 



More information about the grass-commit mailing list