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

« back to all changes in this revision

Viewing changes to raster/r.param.scale/close_down.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:
8
8
/*****************************************************************************/
9
9
 
10
10
#include <string.h>
 
11
#include <grass/raster.h>
11
12
#include "param.h"
12
13
 
13
14
 
14
15
void close_down(void)
15
16
{
16
17
    struct History history;
17
 
    char map_title[RECORD_LEN], map_type[32];
 
18
    char map_title[80], map_type[32];
18
19
 
19
20
    /* Close connection with existing input raster. */
20
 
    G_unopen_cell(fd_in);
 
21
    Rast_unopen(fd_in);
21
22
 
22
23
    /* Write output raster map and close connection. */
23
 
    G_close_cell(fd_out);
 
24
    Rast_close(fd_out);
24
25
 
25
26
    /* write out map metadata */
26
 
    G_short_history(rast_out_name, "raster", &history);
 
27
    Rast_short_history(rast_out_name, "raster", &history);
27
28
 
28
 
    strncpy(history.datsrc_1, rast_in_name, RECORD_LEN-1);
29
 
    history.datsrc_1[RECORD_LEN-1] = '\0';
 
29
    Rast_set_history(&history, HIST_DATSRC_1, rast_in_name);
30
30
 
31
31
    switch (mparam) {
32
32
 
36
36
 
37
37
    case SLOPE:
38
38
        strcpy(map_type, "Magnitude of maximum gradient");
39
 
        G_write_raster_units(rast_out_name, "degrees");
 
39
        Rast_write_units(rast_out_name, "degrees");
40
40
 
41
 
        strcpy(history.edhist[0],
 
41
        Rast_append_history(
 
42
            &history,
42
43
            "Slope is given for steepest slope angle and measured in degrees.");
43
 
        history.edlinecnt = 1;
44
44
        break;
45
45
 
46
46
    case ASPECT:
47
47
        strcpy(map_type, "Direction of maximum gradient");
48
 
        G_write_raster_units(rast_out_name, "degrees");
 
48
        Rast_write_units(rast_out_name, "degrees");
49
49
 
50
 
        strcpy(history.edhist[0],
 
50
        Rast_append_history(
 
51
            &history,
51
52
            "Flow direction (aspect): W=0, E=180, N=+90, S=-90 degrees");
52
 
        history.edlinecnt = 1;
53
53
        break;
54
54
 
55
55
    case PROFC:
56
56
        strcpy(map_type, "Profile curvature");
57
 
        strcpy(history.edhist[0],
 
57
        Rast_append_history(
 
58
            &history,
58
59
            "Curvature intersecting with the plane defined by the Z axis and");
59
 
        strcpy(history.edhist[1],
 
60
        Rast_append_history(
 
61
            &history,
60
62
            "maximum gradient direction. Positive values describe convex profile");
61
 
        strcpy(history.edhist[2], "curvature, negative values concave profile.");
62
 
        history.edlinecnt = 3;
 
63
        Rast_append_history(
 
64
            &history,
 
65
            "curvature, negative values concave profile.");
63
66
        break;
64
67
 
65
68
    case PLANC:
66
69
        strcpy(map_type, "Plan curvature");
67
 
        strcpy(history.edhist[0],
 
70
        Rast_append_history(
 
71
            &history,
68
72
            "Plan curvature is the horizontal curvature, intersecting with");
69
 
        strcpy(history.edhist[1],
 
73
        Rast_append_history(
 
74
            &history,
70
75
            "the XY plane.");
71
 
        history.edlinecnt = 2;
72
76
        break;
73
77
 
74
78
    case LONGC:
75
79
        strcpy(map_type, "Longitudinal curvature");
76
 
        strcpy(history.edhist[0],
 
80
        Rast_append_history(
 
81
            &history,
77
82
            "Longitudinal curvature is the profile curvature intersecting with the");
78
 
        strcpy(history.edhist[1],
 
83
        Rast_append_history(
 
84
            &history,
79
85
            "plane defined by the surfacenormal and maximum gradient direction.");
80
 
        history.edlinecnt = 2;
81
86
        break;
82
87
 
83
88
    case CROSC:
84
89
        strcpy(map_type, "Cross-sectional curvature");
85
 
        strcpy(history.edhist[0],
 
90
        Rast_append_history(
 
91
            &history,
86
92
            "Cross-sectional curvature is the tangential curvature intersecting");
87
 
        strcpy(history.edhist[1],
 
93
        Rast_append_history(
 
94
            &history,
88
95
            "with the plane defined by the surface normal and a tangent to the");
89
 
        strcpy(history.edhist[2],
 
96
        Rast_append_history(
 
97
            &history,
90
98
            "contour - perpendicular to maximum gradient direction.");
91
 
        history.edlinecnt = 3;
92
99
        break;
93
100
 
94
101
    case MINIC:
95
102
        strcpy(map_type, "Minimum curvature");
96
 
        strcpy(history.edhist[0],
 
103
        Rast_append_history(
 
104
            &history,
97
105
            "Measured in direction perpendicular to the direction of of maximum curvature.");
98
 
        history.edlinecnt = 1;
99
106
        break;
100
107
 
101
108
    case MAXIC:
102
109
        strcpy(map_type, "Maximum curvature");
103
 
        strcpy(history.edhist[0],
 
110
        Rast_append_history(
 
111
            &history,
104
112
            "The maximum curvature is measured in any direction");
105
 
        history.edlinecnt = 1;
106
113
        break;
107
114
 
108
115
    case FEATURE:
109
116
        strcpy(map_type, "Morphometric features");
110
 
        strcpy(history.edhist[0],
 
117
        Rast_append_history(
 
118
            &history,
111
119
            "Morphometric features: peaks, ridges, passes, channels, pits and planes");
112
 
        history.edlinecnt = 1;
113
120
        break;
114
121
 
115
122
    default:
117
124
        break;
118
125
    }
119
126
 
120
 
    G_command_history(&history);
121
 
    G_write_history(rast_out_name, &history);
 
127
    Rast_command_history(&history);
 
128
    Rast_write_history(rast_out_name, &history);
122
129
 
123
130
    sprintf(map_title, "DEM terrain parameter: %s", map_type);
124
 
    G_put_cell_title(rast_out_name, map_title);
 
131
    Rast_put_cell_title(rast_out_name, map_title);
125
132
 
126
133
    return;
127
134
}