[GRASS-SVN] r33901 - grass/branches/develbranch_6/imagery/i.ortho.photo/photo.target

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 16 05:40:30 EDT 2008


Author: hamish
Date: 2008-10-16 05:40:30 -0400 (Thu, 16 Oct 2008)
New Revision: 33901

Modified:
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.target/main.c
Log:
update to use G_parser and modern ways

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.target/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.target/main.c	2008-10-16 09:39:32 UTC (rev 33900)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.target/main.c	2008-10-16 09:40:30 UTC (rev 33901)
@@ -7,44 +7,63 @@
  *               Roberto Flor <flor itc.it>, 
  *               Bernhard Reiter <bernhard intevation.de>, 
  *               Glynn Clements <glynn gclements.plus.com>
+ *               Hamish Bowman
  * PURPOSE:      select target location and mapset
- * COPYRIGHT:    (C) 1999-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 1999-2008 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
  *               for details.
  *
  *****************************************************************************/
-/* main.c */
+
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
+#include <grass/gis.h>
 #include <grass/imagery.h>
+#include <grass/glocale.h>
 #include "orthophoto.h"
 #include "local_proto.h"
 
 int main(int argc, char *argv[])
 {
-    char *group, *location, *mapset;
+    struct GModule *module;
+    struct Option *group_opt;
 
-    location = (char *)G_malloc(80 * sizeof(char));
-    mapset = (char *)G_malloc(80 * sizeof(char));
-    group = (char *)G_malloc(80 * sizeof(char));
+    char location[GMAPSET_MAX];
+    char mapset[GMAPSET_MAX];
+    char group[GNAME_MAX];
 
-    if (argc != 2) {
-	fprintf(stderr, "Usage: %s group\n", argv[0]);
-	exit(1);
-    }
 
+    /* must run in a term window */
+    G_putenv("GRASS_UI_TERM", "1");
+
     G_gisinit(argv[0]);
-    group = argv[1];
 
+    module = G_define_module();
+    module->keywords = _("imagery, orthorectify");
+    module->description =
+	_("Interactively select or modify the imagery group target.");
+
+    group_opt = G_define_standard_option(G_OPT_I_GROUP);
+    group_opt->description =
+	_("Name of imagery group for ortho-rectification");
+
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+
+    strcpy(group, group_opt->answer);
+
     I_get_target(group, location, mapset);
     G__create_alt_env();
     ask_target(group, location, mapset);
     G__switch_env();
     I_put_target(group, location, mapset);
 
-    fprintf(stderr, "Group [%s] targeted for location [%s], mapset [%s]\n",
+    G_message(_("Group [%s] targeted for location [%s], mapset [%s]"),
 	    group, location, mapset);
-    exit(0);
+
+    exit(EXIT_SUCCESS);
 }



More information about the grass-commit mailing list