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

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/i.photo.camera/main.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:
 
1
 
 
2
/****************************************************************************
 
3
 *
 
4
 * MODULE:       i.photo.camera
 
5
 * AUTHOR(S):    Mike Baba,  DBA Systems, Inc. (original contributor)
 
6
 *               Markus Neteler <neteler itc.it>,
 
7
 *               Roberto Flor <flor itc.it>, 
 
8
 *               Bernhard Reiter <bernhard intevation.de>, 
 
9
 *               Glynn Clements <glynn gclements.plus.com>
 
10
 *               Hamish Bowman
 
11
 *
 
12
 * PURPOSE:      Creates or modifies entries in a camera reference file
 
13
 * COPYRIGHT:    (C) 1999-2008 by the GRASS Development Team
 
14
 *
 
15
 *               This program is free software under the GNU General Public
 
16
 *               License (>=v2). Read the file COPYING that comes with GRASS
 
17
 *               for details.
 
18
 *
 
19
 *****************************************************************************/
 
20
/* select_camera */
 
21
/* select a camera reference file for a given imagery group */
 
22
 
 
23
#define  MAIN   1
 
24
#include <stdlib.h>
 
25
#include <string.h>
 
26
 
 
27
#ifdef DEBUG
 
28
#include <unistd.h> /* for sleep() */
 
29
#endif
 
30
 
 
31
#include <grass/gis.h>
 
32
#include <grass/glocale.h>
 
33
#include "orthophoto.h"
 
34
#include "globals.h"
 
35
 
 
36
int main(int argc, char *argv[])
 
37
{
 
38
    struct GModule *module;
 
39
    struct Option *group_opt, *camera_opt;
 
40
 
 
41
    char *location;
 
42
    char *mapset;
 
43
    char group[GNAME_MAX];
 
44
 
 
45
    static int have_old;
 
46
    char *camera;
 
47
 
 
48
 
 
49
    /* must run in a term window */
 
50
    G_putenv("GRASS_UI_TERM", "1");
 
51
 
 
52
    G_gisinit(argv[0]);
 
53
 
 
54
    module = G_define_module();
 
55
    module->keywords = _("imagery, orthorectify");
 
56
    module->description =
 
57
        _("Interactively select and modify the imagery group camera reference file.");
 
58
 
 
59
    group_opt = G_define_standard_option(G_OPT_I_GROUP);
 
60
    group_opt->description =
 
61
        _("Name of imagery group for ortho-rectification");
 
62
 
 
63
    camera_opt = G_define_standard_option(G_OPT_F_INPUT);
 
64
    camera_opt->key = "camera";
 
65
    camera_opt->required = NO;
 
66
    camera_opt->gisprompt = "old_file,camera,camera";
 
67
    camera_opt->description =
 
68
        _("Name of camera reference file to use");
 
69
 
 
70
    if (G_parser(argc, argv))
 
71
        exit(EXIT_FAILURE);
 
72
 
 
73
 
 
74
    camera = (char *)G_malloc(GNAME_MAX * sizeof(char));
 
75
 
 
76
    location = G_location();
 
77
    mapset = G_mapset();
 
78
 
 
79
    strcpy(group, group_opt->answer);
 
80
 
 
81
    if (!camera_opt->answer) {
 
82
        /* select the camera to use */
 
83
        if (!I_ask_camera_any(
 
84
            _("Enter a camera reference file to be used with this imagery group"),
 
85
              camera)) {
 
86
            exit(EXIT_SUCCESS);
 
87
        }
 
88
    }
 
89
    else {
 
90
        if (G_legal_filename (camera_opt->answer) < 0)
 
91
            G_fatal_error(_("<%s> is an illegal file name"),
 
92
                          camera_opt->answer);
 
93
        else
 
94
            strcpy(camera, camera_opt->answer);
 
95
    }
 
96
 
 
97
    /* I_put_camera (camera); */
 
98
    I_put_group_camera(group, camera);
 
99
 
 
100
    G_message(
 
101
        _("Group [%s] in location [%s] mapset [%s] now has camera file [%s]"),
 
102
          group, location, mapset, camera);
 
103
#ifdef DEBUG
 
104
    /* slight pause before the screen is cleared */
 
105
    sleep(3);
 
106
#endif
 
107
 
 
108
    /* show the camera info for modification */
 
109
    if (I_find_camera(camera)) {
 
110
        have_old = 1;
 
111
        I_get_cam_info(camera, &cam_info);
 
112
    }
 
113
    mod_cam_info(have_old, &cam_info);
 
114
    I_put_cam_info(camera, &cam_info);
 
115
 
 
116
    exit(EXIT_SUCCESS);
 
117
}