4
#include <grass/vask.h>
9
int ask_elev_data(void)
14
char *tl; /* Target Location */
15
char *elev_data; /* Tempoary elevation data layer */
17
int no_data_value = ZERO_DATA;
19
tl = (char *)G_calloc(40, sizeof(char));
20
elev_data = (char *)G_calloc(40, sizeof(char));
23
sprintf(elev_data, "ELEV_DATA");
24
sprintf(units, "METERS");
29
/** Ask user if modification of elevation data is needed **/
30
ok = G_yes("\nModify the data used for elevation ? ", ok);
33
if ((mapset_elev = G_find_cell(elev_layer, "")) == NULL)
41
/* List options on the screen for the user to answer */
44
V_line(1, "Please check the G_mapcalc convention:");
46
"ELEV_DATA = CELL FILE [MAPSET in LOCATION] [MATH EXPERSION][UNITS]");
48
V_line(5, "ELEV_DATA : ");
49
V_line(6, "CELL FILE : ");
50
V_line(7, "MAPSET : ");
51
V_line(8, "LOCATION : ");
52
V_line(9, "MATH EXPRESSION : ");
53
V_line(10, "UNITS : ");
54
V_line(12, "NO DATA VALUES = :");
57
/* V_ques ( variable, type, row, col, length) ; */
58
V_ques(elev_data, 's', 5, 20, 40);
59
V_const(elev_layer, 's', 6, 20, 40);
60
V_const(mapset_elev, 's', 7, 20, 40);
61
V_const(tl, 's', 8, 20, 40);
62
V_ques(buf1, 's', 9, 20, 40);
63
V_const(units, 's', 10, 20, 10);
64
V_ques(&no_data_value, 'i', 12, 20, 10);
71
sprintf(buf2, "Gmapcalc %s = 'if(%s, %s %s , %d)'", elev_data,
72
elev_layer, elev_layer, buf1, no_data_value);
75
"\n\n The following G_mapcalc syntax will be used \n for the modified elevation data\n\n");
76
fprintf(stderr, "%s = 'if(%s, %s %s , %d)'", elev_data, elev_layer,
77
elev_layer, buf1, no_data_value);
78
ok = G_yes("\nDo you accept this G_mapcalc convention \n", ok);
81
/** Set LOCATION to target location **/
82
G_setenv("LOCATION_NAME", tl);
84
/** system GMAPCALC **/
86
/* elev_data becomes the new elevation layer */
87
strcpy(elev_layer, elev_data);
88
/* need mapset if changed */
89
if ((mapset_elev = G_find_cell(elev_layer, "")) == NULL)
93
/** reset LOCATION to current location **/
94
G_setenv("LOCATION_NAME", G_location());