File: process_left.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (74 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "distance.h"

int process_left (int from_row, int to_row, int start_col, int first_zone)
{
    register int i,col,cur_zone;
    register MAPTYPE *to_ptr, *from_ptr;
    register int ncols,incr,farthest;


	/* find cells to the left
	 * stop at left edge, or when ncols is bigger than the last zone,
	 * or when we see a 1 in the map
	 */

    col = start_col;
    from_ptr = map + MAPINDEX(from_row, col);
    to_ptr   = map + MAPINDEX(to_row, col);
    farthest = distances[ndist-1].ncols;


	/* planimetric grids will look for ncols^2
	 * and can use fact that (n+1)^2 = n^2 + 2n + 1
	 */

    if (window.proj != PROJECTION_LL)
	incr = 1;
    else
	incr = 0;

    ncols = 0;
    while(1)
    {
	if (col == 0)
	{                             /* global wrap-around */
	    if (!wrap_ncols) break;   /* only can happen with lat-lon */
	    col = window.cols;
	    ncols += wrap_ncols-1;
	    from_ptr = map + MAPINDEX(from_row, col);
	    to_ptr   = map + MAPINDEX(to_row, col);
	}
	col--;

	if (incr)
	{
	    ncols += incr;
	    incr += 2;
	}
	else
	    ncols++;
	if(ncols > farthest) break;

	if (*--from_ptr == 1)  break;

	    /* convert 1,2,3,4 to -1,0,1,2 etc. 0 becomes ndist */

	if(cur_zone = *--to_ptr)
	    cur_zone -= ZONE_INCR;
	else
	    cur_zone = ndist;

	    /* find the first zone that is closer than the current value */

	for (i = first_zone; i < cur_zone; i++)
	{
	    if (distances[i].ncols >= ncols)
	    {
		*to_ptr = (first_zone=i) + ZONE_INCR;
		break;
	    }
	}
    }

    return 0;
}