~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/photo.2target/zoom.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

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 cancel(void);
5
 
 
6
 
int zoom(void)
7
 
{
8
 
    static int use = 1;
9
 
    static Objects objects[] = {
10
 
        MENU("CANCEL", cancel, &use),
11
 
        MENU("BOX", zoom_box, &use),
12
 
        MENU("POINT", zoom_point, &use),
13
 
        INFO("Select type of zoom", &use),
14
 
        {0}
15
 
    };
16
 
 
17
 
    Input_pointer(objects);
18
 
    return 0;                   /* return, but don't QUIT */
19
 
}
20
 
 
21
 
static int cancel(void)
22
 
{
23
 
    return -1;
24
 
}
25
 
 
26
 
/* get target point for source point */
27
 
void source_to_target(double srx, double sry, double *trx, double *try)
28
 
{
29
 
    int i;
30
 
    double spx, spy, spz;       /* source photo */
31
 
    double trz;                 /* target raster */
32
 
 
33
 
    G_debug(2, "source raster: %.0f %.0f", srx, sry);
34
 
 
35
 
    /* Photo coordinates of center on ZOOM1 */
36
 
    I_georef(srx, sry, &spx, &spy, group.E12, group.N12);
37
 
    G_debug(2, "source photo: %.3f %.3f", spx, spy);
38
 
 
39
 
    /* We need height but we don't know point on target ->
40
 
     * get aproximately the point on target and use that 
41
 
     * height for more precise position */
42
 
    spz = 0;
43
 
    for (i = 0; i < 3; i++) {
44
 
        I_inverse_ortho_ref(spx, spy, spz, trx, try, &trz,
45
 
                            &group.camera_ref,
46
 
                            group.XC, group.YC, group.ZC,
47
 
                            group.omega, group.phi, group.kappa);
48
 
 
49
 
        G_debug(2, "target raster: %.0f %.0f", *trx, *try);
50
 
        get_z_from_cell2(*try, *trx, &spz);
51
 
        G_debug(2, "target raster height: %.0f", spz);
52
 
    }
53
 
 
54
 
    G_debug(2, "target rast center: %.0f %.0f", *trx, *try);
55
 
}
56
 
 
57
 
void auto_zoom(void)
58
 
{
59
 
    double srx, sry;            /* source raster */
60
 
    double trx, try;            /* target raster */
61
 
    int vx, vy;
62
 
    double trl, trr;
63
 
    double width, magnific;
64
 
 
65
 
    if (autozoom_off)
66
 
        return;
67
 
 
68
 
    Compute_ortho_equation();
69
 
    if (group.con_equation_stat <= 0)
70
 
        return;
71
 
 
72
 
    /* Calc scale for target */
73
 
    sry = VIEW_MAP1_ZOOM->cell.head.north;
74
 
    srx = VIEW_MAP1_ZOOM->cell.head.west;
75
 
    source_to_target(srx, sry, &trl, &try);
76
 
    srx = VIEW_MAP1_ZOOM->cell.head.east;
77
 
    source_to_target(srx, sry, &trr, &try);
78
 
    width = trr - trl;          /* ZOOM1 width in target units */
79
 
 
80
 
    /* Calc magnification - relation between resolution
81
 
     * in zoom window and cell head */
82
 
    magnific = (VIEW_MAP1_ZOOM->right - VIEW_MAP1_ZOOM->left) / width;
83
 
    G_debug(3, "width = %.0f magnific = %f", width, magnific);
84
 
 
85
 
    /* Raster coordinates of center on ZOOM1 */
86
 
    srx = (VIEW_MAP1_ZOOM->cell.head.east +
87
 
           VIEW_MAP1_ZOOM->cell.head.west) / 2;
88
 
    sry = (VIEW_MAP1_ZOOM->cell.head.north +
89
 
           VIEW_MAP1_ZOOM->cell.head.south) / 2;
90
 
 
91
 
    source_to_target(srx, sry, &trx, &try);
92
 
 
93
 
    vx = easting_to_col(&VIEW_MAP2->cell.head, trx);
94
 
    vy = northing_to_row(&VIEW_MAP2->cell.head, try);
95
 
    G_debug(2, "target rast col, row: %d %d", vx, vy);
96
 
 
97
 
    vx = col_to_view(VIEW_MAP2, vx);
98
 
    vy = row_to_view(VIEW_MAP2, vy);
99
 
 
100
 
    G_debug(2, "target view col, row: %d %d", vx, vy);
101
 
 
102
 
    zoom_point2(vx, vy, 0, magnific);
103
 
}