[GRASS-SVN] r54286 - in grass/trunk/imagery/i.ortho.photo: . i.ortho.elev
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 14 14:06:52 PST 2012
Author: mmetz
Date: 2012-12-14 14:06:52 -0800 (Fri, 14 Dec 2012)
New Revision: 54286
Added:
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/
grass/trunk/imagery/i.ortho.photo/i.photo.rectify/
Removed:
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/ask_elev.c
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/elev.h
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/local_proto.h
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/mod_elev.c
Modified:
grass/trunk/imagery/i.ortho.photo/Makefile
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/Makefile
grass/trunk/imagery/i.ortho.photo/i.ortho.elev/main.c
Log:
add i.ortho.elev
Modified: grass/trunk/imagery/i.ortho.photo/Makefile
===================================================================
--- grass/trunk/imagery/i.ortho.photo/Makefile 2012-12-14 22:03:48 UTC (rev 54285)
+++ grass/trunk/imagery/i.ortho.photo/Makefile 2012-12-14 22:06:52 UTC (rev 54286)
@@ -2,20 +2,14 @@
MODULE_TOPDIR = ../..
SUBDIRS1 = \
- menu \
- photo.2image \
- photo.2target \
- photo.camera \
- photo.elev \
- photo.init \
- photo.rectify \
- photo.target
+ i.ortho.elev \
+ i.photo.rectify
-SUBDIRS = libes $(SUBDIRS1)
+SUBDIRS = lib $(SUBDIRS1)
include $(MODULE_TOPDIR)/include/Make/Dir.make
-$(SUBDIRS1): libes
+$(SUBDIRS1): lib
default: parsubdirs
Modified: grass/trunk/imagery/i.ortho.photo/i.ortho.elev/Makefile
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.elev/Makefile 2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/imagery/i.ortho.photo/i.ortho.elev/Makefile 2012-12-14 22:06:52 UTC (rev 54286)
@@ -1,15 +1,12 @@
MODULE_TOPDIR = ../../..
-PGM = i.photo.elev
+PGM = i.ortho.elev
-EXTRA_CFLAGS = -I../libes
+LIBES = $(IMAGERYLIB) $(GISLIB) $(IORTHOLIB) $(GMATHLIB)
+DEPENDENCIES= $(IMAGERYDEP) $(IORTHODEP) $(GISDEP) $(GMATHDEP)
-LIBES = $(IMAGERYLIB) $(GISLIB) $(IORTHOLIB) $(VASKLIB) $(CURSES) $(GMATHLIB)
-DEPENDENCIES= $(IMAGERYDEP) $(IORTHODEP) $(GISDEP) $(VASKDEP) $(GMATHDEP)
+EXTRA_CFLAGS = -I../lib
include $(MODULE_TOPDIR)/include/Make/Module.make
-default: etc
-
-htmletc:
- @echo no docs needed for $(PGM)
+default: cmd
Deleted: grass/trunk/imagery/i.ortho.photo/i.ortho.elev/ask_elev.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.elev/ask_elev.c 2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/imagery/i.ortho.photo/i.ortho.elev/ask_elev.c 2012-12-14 22:06:52 UTC (rev 54286)
@@ -1,50 +0,0 @@
-/* ask_elev .c */
-
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/vask.h>
-#include "elev.h"
-
-int ask_elev(char *group, char *location, char *mapset)
-{
- char buf[100];
- char t1[80];
- char t2[80];
-
- sprintf(t1, "Please select the elevation raster map for group <%s>",
- group);
- sprintf(t2, "Elevation raster map: ");
-
- V_clear();
- V_line(1, t1);
- V_line(4, t2);
- V_line(6, "(enter list for a list of existing raster maps)");
- V_ques(elev_layer, 's', 4, 28, 20);
-
- for (;;) {
- V_intrpt_ok();
- if (!V_call())
- exit(0);
- if (*elev_layer == 0)
- exit(0);
-
- if (strcmp(elev_layer, "list") == 0) {
- G_set_list_hit_return(1);
- G_list_element("cell", "raster", "", 0);
- }
-
- else if ((mapset_elev = G_find_cell(elev_layer, "")) == NULL) {
- sprintf(buf,
- "\n\nraster-file %s not found - select another file\n",
- elev_layer);
- G_warning(buf);
- *elev_layer = 0;
- continue;
- }
- else
- break;
- }
- /* mod_elev_data(); */
- return 0;
-}
Deleted: grass/trunk/imagery/i.ortho.photo/i.ortho.elev/elev.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.elev/elev.h 2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/imagery/i.ortho.photo/i.ortho.elev/elev.h 2012-12-14 22:06:52 UTC (rev 54286)
@@ -1,16 +0,0 @@
-extern char *elev_layer;
-extern char *mapset_elev;
-extern char *tl;
-extern char *math_exp;
-extern char *units;
-extern char *nd;
-
-/* ask_elev.c */
-int ask_elev(char *, char *, char *);
-
-/* main.c */
-int select_current_env(void);
-int select_target_env(void);
-
-/* mod_elev.c */
-int mod_elev_data(void);
Deleted: grass/trunk/imagery/i.ortho.photo/i.ortho.elev/local_proto.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.elev/local_proto.h 2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/imagery/i.ortho.photo/i.ortho.elev/local_proto.h 2012-12-14 22:06:52 UTC (rev 54286)
@@ -1,9 +0,0 @@
-/* ask_elev.c */
-int ask_elev(char *, char *, char *);
-
-/* main.c */
-int select_current_env(void);
-int select_target_env(void);
-
-/* mod_elev.c */
-int mod_elev_data(void);
Modified: grass/trunk/imagery/i.ortho.photo/i.ortho.elev/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.elev/main.c 2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/imagery/i.ortho.photo/i.ortho.elev/main.c 2012-12-14 22:06:52 UTC (rev 54286)
@@ -8,9 +8,10 @@
* Bernhard Reiter <bernhard intevation.de>,
* Glynn Clements <glynn gclements.plus.com>
* Hamish Bowman
+ * Markus Metz
*
* PURPOSE: Select the elevation model
- * COPYRIGHT: (C) 1999-2008 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2012 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
@@ -19,7 +20,7 @@
*****************************************************************************/
/* read the target for the block and cast it into the alternate GRASS env */
-#define MAIN
+
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -28,45 +29,56 @@
#include <grass/imagery.h>
#include <grass/glocale.h>
#include "orthophoto.h"
-#include "elev.h"
static int which_env;
-char *elev_layer;
-char *mapset_elev;
-char *tl;
-char *math_exp;
-char *units;
-char *nd;
+int select_current_env(void);
+int select_target_env(void);
int main(int argc, char *argv[])
{
struct GModule *module;
- struct Option *group_opt;
+ struct Option *group_opt, *elev_opt;
+ struct Flag *list_flag;
char location[GMAPSET_MAX];
char mapset[GMAPSET_MAX];
char group[GNAME_MAX];
+ char *elev_layer;
+ char *mapset_elev;
+ char *tl;
+ char *math_exp;
+ char *units;
+ char *nd;
+
char buf[100];
int stat;
+ int overwrite;
-
- /* must run in a term window */
- G_putenv("GRASS_UI_TERM", "1");
-
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("imagery, orthorectify");
+ G_add_keyword(_("imagery"));
+ G_add_keyword(_("orthorectify"));
module->description =
- _("Interactively select or modify the target elevation model.");
+ _("Select or modify the target elevation model.");
group_opt = G_define_standard_option(G_OPT_I_GROUP);
group_opt->description =
_("Name of imagery group for ortho-rectification");
+ elev_opt = G_define_standard_option(G_OPT_R_ELEV);
+ elev_opt->required = NO;
+ elev_opt->description =
+ _("Name of elevation map to use for ortho-rectification");
+
+ list_flag = G_define_flag();
+ list_flag->key = 'l';
+ list_flag->description =
+ _("List available raster maps in target mapset and exit");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -88,18 +100,15 @@
G_suppress_warnings(1);
if (!I_get_target(group, location, mapset)) {
- sprintf(buf, _("Target information for group [%s] missing\n"), group);
- goto error;
+ G_fatal_error(_("Please select a target for group [%s] first"), group);
}
G_suppress_warnings(0);
sprintf(buf, "%s/%s", G_gisdbase(), location);
if (access(buf, 0) != 0) {
- sprintf(buf, _("Target location [%s] not found\n"), location);
- goto error;
+ G_fatal_error(_("Target location [%s] not found\n"), location);
}
- I_get_group_elev(group, elev_layer, mapset_elev, tl, math_exp, units, nd);
G__create_alt_env();
G__setenv("LOCATION_NAME", location);
@@ -111,27 +120,49 @@
G__switch_search_path();
which_env = 0;
- /* get elevation layer raster map in target location */
select_target_env();
- ask_elev(group, location, mapset);
+
+ if (list_flag->answer) {
+ /* list raster maps in target location */
- /* select current location */
- select_current_env();
+ /* select current location */
+ select_current_env();
+ }
+ else {
+ if (!elev_opt->answer) {
+ /* select current location */
+ select_current_env();
+ G_fatal_error(_("Elevation map name is missing. Please set '%s' option"),
+ elev_opt->key);
+ }
+ /* elevation map exists in target ? */
+
+ if (G_find_raster2(elev_opt->answer, mapset) == NULL) {
+ /* select current location */
+ select_current_env();
+ G_fatal_error(_("Raster map <%s> not found"), elev_opt->answer);
+ }
- I_put_group_elev(group, elev_layer, mapset_elev, tl,
- math_exp, units, nd);
+ I_get_group_elev(group, elev_layer, mapset_elev, tl, math_exp, units, nd);
+ overwrite = G__getenv("OVERWRITE") != NULL;
+
+ if (!overwrite && *elev_layer) {
+ G_warning(_("Elevation for group <%s> is already set to <%s>"),
+ group, elev_layer);
+ }
+ I_put_group_elev(group, elev_opt->answer, mapset_elev, tl,
+ math_exp, units, nd);
+ /* select current location */
+ select_current_env();
+ }
+
exit(EXIT_SUCCESS);
}
- sprintf(buf, _("Mapset [%s] in target location [%s] - "), mapset, location);
- strcat(buf, stat == 0 ? _("permission denied\n") : _("not found\n"));
-
- error:
- strcat(buf, _("Please select a target for group"));
- strcat(buf, group);
- G_suppress_warnings(0);
- G_fatal_error(buf);
+ G_fatal_error(_("Mapset [%s] in target location [%s] - %s "),
+ mapset, location,
+ stat == 0 ? _("permission denied\n") : _("not found\n"));
}
Deleted: grass/trunk/imagery/i.ortho.photo/i.ortho.elev/mod_elev.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.elev/mod_elev.c 2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/imagery/i.ortho.photo/i.ortho.elev/mod_elev.c 2012-12-14 22:06:52 UTC (rev 54286)
@@ -1,47 +0,0 @@
-/* mod_elev.c */
-
-#include <stdlib.h>
-#include <grass/gis.h>
-#include <grass/vask.h>
-#include "elev.h"
-
-#define ZERO_DATA 0
-
-int mod_elev_data(void)
-{
- short ok;
-
- tl = G_location();
- sprintf(units, "METERS");
-
- ok = 0;
- while (!ok) {
- /* List options on the screen for the user to answer */
- ok = 1;
- V_clear();
- V_line(1, "Please check the elevation data convention:");
- V_line(3,
- "ELEV_DATA = CELL FILE [MAPSET in LOCATION] [MATH EXPERSION][UNITS]");
-
- V_line(6, "CELL FILE : ");
- V_line(7, "MAPSET : ");
- V_line(8, "LOCATION : ");
- V_line(9, "MATH EXPRESSION : ");
- V_line(10, "UNITS : ");
- V_line(12, "NO DATA VALUES : ");
-
- V_const(elev_layer, 's', 6, 20, 40);
- V_const(mapset_elev, 's', 7, 20, 40);
- V_const(tl, 's', 8, 20, 40);
- V_ques(math_exp, 's', 9, 20, 40);
- V_const(units, 's', 10, 20, 10);
- V_ques(nd, 's', 12, 20, 10);
-
- V_intrpt_ok();
- if (!V_call())
- exit(1);
-
- }
-
- return 0;
-}
More information about the grass-commit
mailing list