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

« back to all changes in this revision

Viewing changes to raster/r.le/r.le.setup/polytocell/bmf.b

  • 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
 
#include "ply_to_cll.h"
3
 
#include "gis.h"
4
 
#include <stdio.h>
5
 
#define ROW_SHIFT       -1
6
 
 
7
 
char *gets() ;
8
 
 
9
 
#define MAXLINE  90
10
 
#define FGET        gets(buffer)
11
 
#define READLINE        if (FGET==NULL) quit() ;\
12
 
                                        sscanf (buffer,"%d%d%d%d",\
13
 
                                        &cur_row, &col_b, &col_e, &cat) 
14
 
 
15
 
main(argc, argv)
16
 
        int argc;
17
 
        char *argv[] ;
18
 
{
19
 
        struct Cell_head wind ;
20
 
        char buffer[MAXLINE] ;
21
 
        CELL *record ;
22
 
        CELL *col_ptr ;
23
 
        int cat ;
24
 
        int cur_row, col_b, col_e ;
25
 
        int num_rows, num_cols ;
26
 
        int atrow, atcol ;
27
 
        int newmap ;
28
 
 
29
 
        if (argc != 2)
30
 
                exit(-1) ;
31
 
 
32
 
        G_gisinit("bmif_to_cell") ;
33
 
 
34
 
        READLINE ;
35
 
        num_rows = col_b ;
36
 
        num_cols = col_e ;
37
 
 
38
 
        if ((num_rows*num_cols) <= 0)
39
 
        {
40
 
                fprintf(stderr,
41
 
                  "    READ ERROR:  bmif_to_cell receiving bad header info\n") ;
42
 
                quit() ;
43
 
        }
44
 
 
45
 
        G_get_window(&wind) ;
46
 
        wind.rows = num_rows ;
47
 
        wind.cols = num_cols ;
48
 
        wind.ew_res= 1.0 ;
49
 
        wind.ns_res= 1.0 ;
50
 
        wind.north = (double)wind.rows ;
51
 
        wind.south = 0.0 ;
52
 
        wind.east  = (double)wind.cols ;
53
 
        wind.west  = 0.0 ;
54
 
        G_set_window(&wind) ;
55
 
 
56
 
        record = G_allocate_cell_buf() ;
57
 
 
58
 
        if ( (newmap = G_open_cell_new(argv[1],"") ) == -1)
59
 
        {
60
 
            fprintf("bmif_to_cell error: can't open raster map %s\n", argv[1]) ;
61
 
            quit() ;
62
 
        }
63
 
 
64
 
        READLINE ;
65
 
 
66
 
        /* Loop for all data rows */
67
 
        for(atrow=0; atrow<num_rows; atrow++)
68
 
        {
69
 
        /* zero the output buffer array */
70
 
                col_ptr = record ;
71
 
                for(atcol=0; atcol<num_cols; atcol++)
72
 
                        *(col_ptr++) = 0 ;
73
 
                
74
 
        /* If we've hit the end of the file, write out some zero rows and quit */
75
 
                if (cur_row > num_rows)
76
 
                {
77
 
                        while (atrow < num_rows)
78
 
                        {
79
 
                                G_put_map_row(newmap, record) ; 
80
 
                                atrow++ ;
81
 
                        }
82
 
                        G_close_cell(newmap) ;
83
 
                        exit(0) ;
84
 
                }
85
 
 
86
 
        /* write out enough rows to get to current row */
87
 
                while (atrow < cur_row + ROW_SHIFT)
88
 
                {
89
 
                        G_put_map_row(newmap, record) ; 
90
 
                        atrow++ ;
91
 
                }
92
 
 
93
 
                do
94
 
                {
95
 
                        col_ptr = record + col_b ;
96
 
                        for(atcol=col_b; atcol<=col_e; atcol++)
97
 
                                *(col_ptr++) = (CELL)cat ;
98
 
                        READLINE ;
99
 
                } while (cur_row == (atrow - ROW_SHIFT)) ;
100
 
 
101
 
                G_put_map_row(newmap, record) ; 
102
 
        }
103
 
        fprintf(stderr, "Close: %d\n", G_close_cell(newmap)) ;
104
 
}
105
 
 
106
 
quit()
107
 
{
108
 
        fprintf(stderr,"    You drew a region outside the mask; restart REGIONS setup\n") ;
109
 
        exit(-1) ;
110
 
}