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

« back to all changes in this revision

Viewing changes to raster/r.le/r.le.setup/polytocell/wrte_recrd.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
 
#include <stdio.h>
2
 
static int rec_num = 1;
3
 
static int maxrow, minrow;
4
 
static float maxcol, mincol;
5
 
 
6
 
void set_limits(int numrows, int numcols)
7
 
{
8
 
    maxrow = numrows;
9
 
    maxcol = (float)(numcols - 1);
10
 
    minrow = 1;
11
 
    mincol = 0.0;
12
 
}
13
 
 
14
 
static int check_limits(int *row, float *first_cell, float *last_cell)
15
 
{
16
 
    if (*row < minrow)
17
 
        return (0);
18
 
    if (*row > maxrow)
19
 
        return (0);
20
 
    if (*first_cell > maxcol)
21
 
        return (0);
22
 
    if (*last_cell < mincol)
23
 
        return (0);
24
 
    if (*first_cell < mincol)
25
 
        *first_cell = mincol;
26
 
    if (*last_cell > maxcol)
27
 
        *last_cell = maxcol;
28
 
    *last_cell = maxcol - *last_cell;
29
 
    return (1);
30
 
}
31
 
 
32
 
void write_record(int row, float first_cell, float last_cell, int category)
33
 
{
34
 
    float fc, lc;
35
 
 
36
 
    fc = first_cell;
37
 
    lc = last_cell;
38
 
 
39
 
    if (check_limits(&row, &fc, &lc))
40
 
        printf("%d %8d:%d:%d:%d\n",
41
 
               row, rec_num++, (int)(100. * fc), (int)(100. * lc), category);
42
 
}
43
 
 
44
 
void write_end_record(int row, int first_cell, int last_cell, int category)
45
 
{
46
 
    printf("%d %8d:%d:%d:%d\n",
47
 
           row, rec_num++, first_cell, last_cell, category);
48
 
}