2
/****************************************************************************
6
* AUTHOR(S): Michael O'Shea - CERL
7
* Michael Shapiro - CERL
9
* PURPOSE: Calculates the coincidence of two raster map layers.
11
* COPYRIGHT: (C) 2006 by the GRASS Development Team
13
* This program is free software under the GNU General Public
14
* License (>=v2). Read the file COPYING that comes with GRASS
17
***************************************************************************/
21
#include <grass/spawn.h>
22
#include <grass/glocale.h>
24
int interactive_version(void)
28
char line[128], outname[GNAME_MAX], command[1024];
34
G_message(_("GIS Coincidence Tabulation Facility\n"));
35
G_message(_("This utility will allow you to compare the "
36
"coincidence of two map layers\n"));
38
mapset1 = G_ask_cell_old("Enter Name of Map Layer 1", map1name);
40
G_fatal_error(_("Raster map <%s> not found"), map1name);
42
mapset2 = G_ask_cell_old("Enter Name of Map Layer 2", map2name);
44
G_fatal_error(_("Raster map <%s> not found"), map2name);
52
G_message(_("The report can be made in one of 8 units."));
53
G_message(_("Please choose a unit by entering one of the "
54
"following letter codes:"));
55
G_message(_(" 'c': cells"));
56
G_message(_(" 'p': percent cover of region"));
57
G_message(_(" 'x': percent of '%s' category (column)"), map1name);
58
G_message(_(" 'y': percent of '%s' category (row)"), map2name);
59
G_message(_(" 'a': acres"));
60
G_message(_(" 'h': hectares"));
61
G_message(_(" 'k': square kilometers"));
62
G_message(_(" 'm': square miles\n"));
63
G_message(_(" 'Q': quit"));
64
fprintf(stderr, "> ");
69
if (sscanf(ans, "%c", &key) != 1)
81
print_coin(key, 80, 1);
89
sprintf(command, "%s \"%s\"", getenv("GRASS_PAGER"),
90
G_convert_dirseps_to_host(dumpname));
95
_("Do you wish to save this report in a file? (y/n) [n] "));
100
if (ans[0] != 'y' && ans[0] != 'Y')
103
fprintf(stderr, _("Enter the file name or path\n> "));
106
if (sscanf(line, "%s", outname) != 1)
108
fprintf(stderr, _("'%s' being saved\n"), outname);
109
if (G_copy_file(dumpname, outname))
110
/* Break out if file copy was successful otherwise try again */
117
_("Do you wish to print this report (requires Unix lpr command)? (y/n) [n] "));
121
if (ans[0] != 'y' && ans[0] != 'Y')
126
_("Do you wish it printed in 80 or 132 columns?\n> "));
131
if (sscanf(ans, "%d", &cols) != 1)
134
print_coin(key, 132, 1);
137
G_spawn("lpr", "lpr", dumpname, NULL);
142
fprintf(stderr, _("Do you wish to run this report with a "
143
"different unit of measure? (y/n) [y] "));
146
while (!G_gets(ans));
148
if (*ans == 'n' || *ans == 'N')