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

« back to all changes in this revision

Viewing changes to raster/r.proj.seg/cubic.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:
25
25
             struct Cell_head *cellhd   /* information of output map     */
26
26
    )
27
27
{
28
 
    int row,                    /* row indices for interp        */
29
 
      col;                      /* column indices for interp     */
 
28
    int row;                    /* row indices for interp        */
 
29
    int col;                    /* column indices for interp     */
30
30
    int i, j;
31
 
    FCELL t, u,                 /* intermediate slope            */
32
 
      result,                   /* result of interpolation       */
33
 
      val[4];                   /* buffer for temporary values   */
34
 
    FCELL *cellp[4][4];
 
31
    FCELL t, u;                 /* intermediate slope            */
 
32
    FCELL result;               /* result of interpolation       */
 
33
      FCELL val[4];             /* buffer for temporary values   */
 
34
    FCELL cell[4][4];
35
35
 
36
36
    /* cut indices to integer */
37
 
    row = (int)floor(*row_idx);
38
 
    col = (int)floor(*col_idx);
 
37
    row = (int)floor(*row_idx - 0.5);
 
38
    col = (int)floor(*col_idx - 0.5);
39
39
 
40
40
    /* check for out of bounds of map - if out of bounds set NULL value     */
41
41
    if (row - 1 < 0 || row + 2 >= cellhd->rows ||
45
45
    }
46
46
 
47
47
    for (i = 0; i < 4; i++)
48
 
        for (j = 0; j < 4; j++)
49
 
            cellp[i][j] = CPTR(ibuffer, row - 1 + i, col - 1 + j);
50
 
 
51
 
    /* check for NULL value                                         */
52
 
    for (i = 0; i < 4; i++)
53
48
        for (j = 0; j < 4; j++) {
54
 
            if (G_is_f_null_value(cellp[i][j])) {
 
49
            const FCELL *cellp = CPTR(ibuffer, row - 1 + i, col - 1 + j);
 
50
            if (G_is_f_null_value(cellp)) {
55
51
                G_set_null_value(obufptr, 1, cell_type);
56
52
                return;
57
53
            }
 
54
            cell[i][j] = *cellp;
58
55
        }
59
56
 
60
57
    /* do the interpolation  */
61
 
    t = *col_idx - col;
62
 
    u = *row_idx - row;
 
58
    t = *col_idx - 0.5 - col;
 
59
    u = *row_idx - 0.5 - row;
63
60
 
64
61
    for (i = 0; i < 4; i++) {
65
 
        FCELL **tmp = cellp[i];
66
 
 
67
 
        val[i] = G_interp_cubic(t, *tmp[0], *tmp[1], *tmp[2], *tmp[3]);
 
62
        const FCELL *tmp = cell[i];
 
63
        val[i] = G_interp_cubic(t, tmp[0], tmp[1], tmp[2], tmp[3]);
68
64
    }
69
65
 
70
66
    result = G_interp_cubic(u, val[0], val[1], val[2], val[3]);