~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to raster/r.coin/inter.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/****************************************************************************
3
 
 *
4
 
 * MODULE:       r.coin
5
 
 *
6
 
 * AUTHOR(S):    Michael O'Shea - CERL
7
 
 *               Michael Shapiro - CERL
8
 
 *
9
 
 * PURPOSE:      Calculates the coincidence of two raster map layers.
10
 
 *
11
 
 * COPYRIGHT:    (C) 2006 by the GRASS Development Team
12
 
 *
13
 
 *               This program is free software under the GNU General Public
14
 
 *               License (>=v2). Read the file COPYING that comes with GRASS
15
 
 *               for details.
16
 
 *
17
 
 ***************************************************************************/
18
 
 
19
 
#include <stdlib.h>
20
 
#include "coin.h"
21
 
#include <grass/spawn.h>
22
 
#include <grass/glocale.h>
23
 
 
24
 
int interactive_version(void)
25
 
{
26
 
    int cols;
27
 
    char key;
28
 
    char line[128], outname[GNAME_MAX], command[1024];
29
 
    char ans[80];
30
 
 
31
 
    setbuf(stderr, NULL);
32
 
 
33
 
    G_clear_screen();
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"));
37
 
 
38
 
    mapset1 = G_ask_cell_old("Enter Name of Map Layer 1", map1name);
39
 
    if (!mapset1)
40
 
        G_fatal_error(_("Raster map <%s> not found"), map1name);
41
 
 
42
 
    mapset2 = G_ask_cell_old("Enter Name of Map Layer 2", map2name);
43
 
    if (!mapset2)
44
 
        G_fatal_error(_("Raster map <%s> not found"), map2name);
45
 
 
46
 
    make_coin();
47
 
    check_report_size();
48
 
 
49
 
 
50
 
    while (1) {
51
 
        G_clear_screen();
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, "> ");
65
 
 
66
 
        *ans = 0;
67
 
        if (!G_gets(ans))
68
 
            continue;
69
 
        if (sscanf(ans, "%c", &key) != 1)
70
 
            continue;
71
 
 
72
 
        switch (key) {
73
 
        case 'c':
74
 
        case 'p':
75
 
        case 'x':
76
 
        case 'y':
77
 
        case 'a':
78
 
        case 'h':
79
 
        case 'k':
80
 
        case 'm':
81
 
            print_coin(key, 80, 1);
82
 
            break;
83
 
        case 'Q':
84
 
            exit(0);
85
 
        default:
86
 
            continue;
87
 
        }
88
 
 
89
 
        sprintf(command, "%s \"%s\"", getenv("GRASS_PAGER"),
90
 
                G_convert_dirseps_to_host(dumpname));
91
 
        G_system(command);
92
 
 
93
 
        while (1) {
94
 
            fprintf(stderr,
95
 
                    _("Do you wish to save this report in a file? (y/n) [n] "));
96
 
            *ans = 0;
97
 
            if (!G_gets(ans))
98
 
                continue;
99
 
            G_strip(ans);
100
 
            if (ans[0] != 'y' && ans[0] != 'Y')
101
 
                break;
102
 
 
103
 
            fprintf(stderr, _("Enter the file name or path\n> "));
104
 
            if (!G_gets(line))
105
 
                continue;
106
 
            if (sscanf(line, "%s", outname) != 1)
107
 
                continue;
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 */
111
 
                break;
112
 
        }
113
 
 
114
 
        while (1) {
115
 
            *ans = 0;
116
 
            fprintf(stderr,
117
 
                    _("Do you wish to print this report (requires Unix lpr command)? (y/n) [n] "));
118
 
            if (!G_gets(ans))
119
 
                continue;
120
 
            G_strip(ans);
121
 
            if (ans[0] != 'y' && ans[0] != 'Y')
122
 
                break;
123
 
 
124
 
          ask132:
125
 
            fprintf(stderr,
126
 
                    _("Do you wish it printed in 80 or 132 columns?\n> "));
127
 
            *ans = 0;
128
 
            if (!G_gets(ans))
129
 
                continue;
130
 
            G_strip(ans);
131
 
            if (sscanf(ans, "%d", &cols) != 1)
132
 
                goto ask132;
133
 
            if (cols == 132)
134
 
                print_coin(key, 132, 1);
135
 
            else if (cols != 80)
136
 
                goto ask132;
137
 
            G_spawn("lpr", "lpr", dumpname, NULL);
138
 
            break;
139
 
        }
140
 
 
141
 
        do {
142
 
            fprintf(stderr, _("Do you wish to run this report with a "
143
 
                              "different unit of measure? (y/n) [y] "));
144
 
            *ans = 0;
145
 
        }
146
 
        while (!G_gets(ans));
147
 
        G_strip(ans);
148
 
        if (*ans == 'n' || *ans == 'N')
149
 
            break;
150
 
    }
151
 
 
152
 
    return 0;
153
 
}