~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to raster/r.random.surface/save.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* save.c                                                               */
2
 
 
3
 
#undef TRACE
4
 
#undef DEBUG
5
 
 
6
2
#undef MAIN
7
3
#include <string.h>
8
4
#include <grass/gis.h>
20
16
    char String[80], Label[240];
21
17
    struct History history;
22
18
 
23
 
    FUNCTION(SaveMap);
 
19
    G_debug(2, "SaveMap()");
24
20
 
25
21
    OutFD = G_open_cell_new(OutNames[NumMap]);
26
22
    if (OutFD < 0)
27
 
        G_fatal_error("%s: unable to open new raster map [%s]",
28
 
                      G_program_name(), OutNames[NumMap]);
 
23
      G_fatal_error(_("Unable to create raster map <%s>"),
 
24
                    OutNames[NumMap]);
29
25
 
30
26
    MeanMod = 0.0;
31
 
    INT(FDM);
 
27
    G_debug(3, "(FDM):%d", FDM);
32
28
    if (FDM == -1) {
33
29
        for (Row = 0; Row < Rs; Row++) {
34
30
            for (Col = 0; Col < Cs; Col++) {
71
67
        }
72
68
 
73
69
        MeanMod /= MapCount;
74
 
        DOUBLE(MeanMod);
75
 
        DOUBLE(FilterSD);
 
70
        G_debug(3, "(MeanMod):%.12lf", MeanMod);
 
71
        G_debug(3, "(FilterSD):%.12lf", FilterSD);
76
72
        /* Value = (Value - MeanMod) / FilterSD + MeanMod / FilterSD; */
77
73
        Value /= FilterSD;
78
 
        DOUBLE(Value);
79
 
        RETURN;
 
74
        G_debug(3, "(Value):%.12lf", Value);
 
75
        
80
76
        DownInterval = UpInterval = Value;
81
77
 
82
78
        for (Row = 0; Row < Rs; Row++) {
101
97
        }
102
98
    }
103
99
 
104
 
    G_message(_("%s: saving [%s] raster map layer.\nPercent complete:"),
105
 
              G_program_name(), OutNames[NumMap]);
 
100
    G_message(_("Writing raster map <%s>..."),
 
101
              OutNames[NumMap]);
106
102
 
107
103
    for (Index = 0; Index < CatInfo.NumCat; Index++) {
108
104
        CatInfo.Max[Index] = DownInterval;
115
111
        UpInterval += .1;
116
112
 
117
113
    if (!Uniform->answer) {
118
 
        FUNCTION(NOT_UNIFORM);
119
114
        /* normal distribution */
120
115
        for (Row = 0; Row < Rs; Row++) {
121
116
            for (Col = 0; Col < Cs; Col++) {
171
166
    }
172
167
 
173
168
    for (Row = 0; Row < Rs; Row++) {
 
169
        G_percent(Row, Rs, 2);
174
170
        for (Col = 0; Col < Cs; Col++) {
175
171
            CellBuffer[Col] = (CELL) Surface[Row][Col];
176
172
        }
177
173
        G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
178
 
        if (!Verbose->answer)
179
 
            G_percent(Row + 1, Rs, 1);
180
174
    }
 
175
    G_percent(1, 1, 1);
181
176
 
182
177
    G_close_cell(OutFD);
183
178
    G_short_history(OutNames[NumMap], "raster", &history);
214
209
        LowColor = 0;
215
210
    if (Uniform->answer || HighColor > 255)
216
211
        HighColor = 255;
217
 
    INT(LowColor);
218
 
    INT(HighColor);
 
212
    G_debug(3, "(LowColor):%d", LowColor);
 
213
    G_debug(3, "(HighColor):%d", HighColor);
219
214
 
220
215
    G_add_color_rule(1, LowColor, LowColor, LowColor,
221
216
                     High, HighColor, HighColor, HighColor, &Colr);
222
217
 
223
218
    if (G_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
224
 
        G_warning("%s: unable to write colr file for %s\n",
225
 
                  G_program_name(), OutNames[NumMap]);
 
219
        G_warning(_("Unable to write color table for raster map <%s>"),
 
220
                  OutNames[NumMap]);
226
221
}