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

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/i.photo.rectify/bilinear_f.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
 
/*
2
 
 * Name
3
 
 *  bilinear_f.c -- use bilinear interpolation with fallback for given row, col
4
 
 *
5
 
 * Description
6
 
 *  bilinear interpolation for the given row, column indices.
7
 
 *  If the interpolated value (but not the nearest) is null,
8
 
 *  it falls back to nearest neighbor.
9
 
 */
10
 
 
11
 
#include <math.h>
12
 
#include "global.h"
13
 
 
14
 
void p_bilinear_f(struct cache *ibuffer,    /* input buffer                */
15
 
                  void *obufptr,            /* ptr in output buffer        */
16
 
                  int cell_type,            /* raster map type of obufptr  */
17
 
                  double *row_idx,          /* row index                   */
18
 
                  double *col_idx,          /* column index                */
19
 
                  struct Cell_head *cellhd  /* cell header of input layer  */
20
 
    )
21
 
{
22
 
    /* start nearest neighbor to do some basic tests */
23
 
    int row, col;               /* row/col of nearest neighbor   */
24
 
    DCELL *cellp, cell;
25
 
 
26
 
    /* cut indices to integer */
27
 
    row = (int)floor(*row_idx);
28
 
    col = (int)floor(*col_idx);
29
 
 
30
 
    /* check for out of bounds - if out of bounds set NULL value     */
31
 
    if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) {
32
 
        G_set_null_value(obufptr, 1, cell_type);
33
 
        return;
34
 
    }
35
 
 
36
 
    cellp = CPTR(ibuffer, row, col);
37
 
    /* if nearest is null, all the other interps will be null */
38
 
    if (G_is_d_null_value(cellp)) {
39
 
        G_set_null_value(obufptr, 1, cell_type);
40
 
        return;
41
 
    }
42
 
    cell = *cellp;
43
 
 
44
 
    p_bilinear(ibuffer, obufptr, cell_type, row_idx, col_idx, cellhd);
45
 
    /* fallback to nearest if bilinear is null */
46
 
    if (G_is_d_null_value(obufptr))
47
 
        G_set_raster_value_d(obufptr, cell, cell_type);
48
 
}