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

« back to all changes in this revision

Viewing changes to imagery/i.points/where.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 "globals.h"
2
 
#include "local_proto.h"
3
 
 
4
 
static int where_12(View *, int, int);
5
 
static int where_21(View *, int, int);
6
 
static int where_am_i(View *, int, int, Window *, double *, double *,
7
 
                      Window *);
8
 
 
9
 
int where(int x, int y)
10
 
{
11
 
    if (VIEW_MAP1->cell.configured && In_view(VIEW_MAP1, x, y))
12
 
        where_12(VIEW_MAP1, x, y);
13
 
    else if (VIEW_MAP1_ZOOM->cell.configured && In_view(VIEW_MAP1_ZOOM, x, y))
14
 
        where_12(VIEW_MAP1_ZOOM, x, y);
15
 
    else if (VIEW_MAP2->cell.configured && In_view(VIEW_MAP2, x, y))
16
 
        where_21(VIEW_MAP2, x, y);
17
 
    else if (VIEW_MAP2_ZOOM->cell.configured && In_view(VIEW_MAP2_ZOOM, x, y))
18
 
        where_21(VIEW_MAP2_ZOOM, x, y);
19
 
    return 0;                   /* return but don't quit */
20
 
}
21
 
 
22
 
static int where_12(View * view, int x, int y)
23
 
{
24
 
    where_am_i(view, x, y, MENU_WINDOW, group.E12, group.N12, INFO_WINDOW);
25
 
 
26
 
    return 0;
27
 
}
28
 
 
29
 
static int where_21(View * view, int x, int y)
30
 
{
31
 
    where_am_i(view, x, y, INFO_WINDOW, group.E21, group.N21, MENU_WINDOW);
32
 
 
33
 
    return 0;
34
 
}
35
 
 
36
 
static int where_am_i(View * view, int x, int y, Window * w1,
37
 
                      double *E, double *N, Window * w2)
38
 
{
39
 
    double e1, n1, e2, n2;
40
 
    int row, col;
41
 
 
42
 
    char buf[100];
43
 
 
44
 
    /* convert x,y to east,north at center of cell */
45
 
    col = view_to_col(view, x);
46
 
    e1 = col_to_easting(&view->cell.head, col, 0.5);
47
 
    row = view_to_row(view, y);
48
 
    n1 = row_to_northing(&view->cell.head, row, 0.5);
49
 
 
50
 
    Curses_clear_window(w1);
51
 
    sprintf(buf, "East:  %10.2f", e1);
52
 
    Curses_write_window(w1, 3, 3, buf);
53
 
    sprintf(buf, "North: %10.2f", n1);
54
 
    Curses_write_window(w1, 4, 3, buf);
55
 
 
56
 
    /* if transformation equation is useable, determine point via equation */
57
 
    if (group.equation_stat <= 0)
58
 
        return 1;
59
 
 
60
 
    I_georef(e1, n1, &e2, &n2, E, N);
61
 
    Curses_clear_window(w2);
62
 
    sprintf(buf, "East:  %10.2f", e2);
63
 
    Curses_write_window(w2, 3, 3, buf);
64
 
    sprintf(buf, "North: %10.2f", n2);
65
 
    Curses_write_window(w2, 4, 3, buf);
66
 
 
67
 
    return 0;
68
 
}