[GRASS-SVN] r40559 - grass/branches/develbranch_6/raster/r.proj.seg

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 19 18:45:13 EST 2010


Author: hamish
Date: 2010-01-19 18:45:12 -0500 (Tue, 19 Jan 2010)
New Revision: 40559

Modified:
   grass/branches/develbranch_6/raster/r.proj.seg/main.c
Log:
new flag to show reprojected bounds and exit (trac #845)

Modified: grass/branches/develbranch_6/raster/r.proj.seg/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.proj.seg/main.c	2010-01-19 23:25:23 UTC (rev 40558)
+++ grass/branches/develbranch_6/raster/r.proj.seg/main.c	2010-01-19 23:45:12 UTC (rev 40559)
@@ -89,7 +89,8 @@
       row, col,			/* counters                     */
       irows, icols,		/* original rows, cols          */
       orows, ocols, have_colors,	/* Input map has a colour table */
-      overwrite;		/* Overwrite                    */
+      overwrite,		/* Overwrite                    */
+      curr_proj;		/* output projection (see gis.h) */
 
     void *obuffer,		/* buffer that holds one output row     */
      *obufptr;			/* column ptr in output buffer  */
@@ -102,6 +103,7 @@
       row_idx,			/* row index in input matrix    */
       onorth, osouth,		/* save original border coords  */
       oeast, owest, inorth, isouth, ieast, iwest;
+    char north_str[30], south_str[30], east_str[30], west_str[30];
 
     struct Colors colr;		/* Input map colour table       */
     struct History history;
@@ -116,7 +118,9 @@
     struct GModule *module;
 
     struct Flag *list,		/* list files in source location */
-     *nocrop;			/* don't crop output map        */
+     *nocrop,			/* don't crop output map        */
+     *print_bounds,		/* print output bounds and exit */
+     *gprint_bounds;		/* same but print shell style	*/
 
     struct Option *imapset,	/* name of input mapset         */
      *inmap,			/* name of input layer          */
@@ -194,6 +198,17 @@
     nocrop->key = 'n';
     nocrop->description = _("Do not perform region cropping optimization");
 
+    print_bounds = G_define_flag();
+    print_bounds->key = 'p';
+    print_bounds->description =
+	_("Print input map's bounds in the current projection and exit");
+
+    gprint_bounds = G_define_flag();
+    gprint_bounds->key = 'g';
+    gprint_bounds->description =
+	_("Print bounds and exit (shell style)");
+
+
     /* The parser checks if the map already exists in current mapset,
        we switch out the check and do it
        in the module after the parser */
@@ -202,6 +217,7 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+
     /* get the method */
     for (method = 0; (ipolname = menu[method].name); method++)
 	if (strcmp(ipolname, interpol->answer) == 0)
@@ -224,6 +240,10 @@
 
     G_get_window(&outcellhd);
 
+    if(gprint_bounds->answer && !print_bounds->answer)
+	print_bounds->answer = gprint_bounds->answer;
+    curr_proj = G_projection();
+
     /* Get projection info for output mapset */
     if ((out_proj_info = G_get_projinfo()) == NULL)
 	G_fatal_error(_("Unable to get projection info of output raster map"));
@@ -304,6 +324,35 @@
     orows = outcellhd.rows;
     ocols = outcellhd.cols;
 
+
+    if (print_bounds->answer) {
+	G_message(_("Input map <%s@%s> in location <%s>:"),
+	    inmap->answer, setname, inlocation->answer);
+
+	G_format_northing(onorth, north_str, curr_proj);
+	G_format_northing(osouth, south_str, curr_proj);
+	G_format_easting(oeast, east_str, curr_proj);
+	G_format_easting(owest, west_str, curr_proj);
+
+	if(gprint_bounds->answer) {
+	    fprintf(stdout, "n=%s s=%s w=%s e=%s\n",
+		north_str, south_str, west_str, east_str);
+	}
+	else {
+	    fprintf(stdout, "Source cols: %d\n", icols);
+	    fprintf(stdout, "Source rows: %d\n", irows);
+	    fprintf(stdout, "Local north: %s\n",  north_str);
+	    fprintf(stdout, "Local south: %s\n", south_str);
+	    fprintf(stdout, "Local west: %s\n", west_str);
+	    fprintf(stdout, "Local east: %s\n", east_str);
+	}
+
+	/* somehow approximate local ewres, nsres ?? (use 'g.region -m' on lat/lon side) */
+
+	exit(EXIT_SUCCESS);
+    }
+
+
     /* Cut non-overlapping parts of input map */
     if (!nocrop->answer)
 	bordwalk(&outcellhd, &incellhd, &oproj, &iproj);



More information about the grass-commit mailing list