Debian Codegraph @

imagery/i.ortho.photo/i.ortho.target/main.c

raw symbols SCIP
1 /****************************************************************************
2 *
3 * MODULE: i.photo.target
4 * AUTHOR(S): Mike Baba, DBA Systems, Inc. (original contributor)
5 * Markus Neteler <neteler itc.it>,
6 * Roberto Flor <flor itc.it>,
7 * Bernhard Reiter <bernhard intevation.de>,
8 * Glynn Clements <glynn gclements.plus.com>
9 * Hamish Bowman
10 *
11 * PURPOSE: Select target location and mapset
12 * COPYRIGHT: (C) 1999-2017 by the GRASS Development Team
13 *
14 * This program is free software under the GNU General Public
15 * License (>=v2). Read the file COPYING that comes with GRASS
16 * for details.
17 *
18 *****************************************************************************/
19
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <grass/gis.h>
24 #include <grass/imagery.h>
25 #include <grass/glocale.h>
26 #include "orthophoto.h"
27
28 int main(int argc, char *argv[])
29 {
30 struct GModule *module;
31 struct Option *group_opt;
32 struct Option *location_opt;
33 struct Option *mapset_opt;
34
35 /* current location and mapset of that group */
36 char location[GMAPSET_MAX];
37 char mapset[GMAPSET_MAX];
38 char group[GNAME_MAX];
39
40 /* newly defined location and maspet */
41 char target_location[GMAPSET_MAX];
42 char target_mapset[GMAPSET_MAX];
43 int stat;
44 struct Cell_head target_window;
45
46 G_gisinit(argv[0]);
47
48 module = G_define_module();
49 G_add_keyword(_("imagery"));
50 G_add_keyword(_("orthorectify"));
51 module->description = _("Select or modify the imagery group target.");
52
53 group_opt = G_define_standard_option(G_OPT_I_GROUP);
54 group_opt->description = _("Name of imagery group for ortho-rectification");
55
56 location_opt = G_define_standard_option(G_OPT_M_LOCATION);
57 location_opt->key = "target_project";
58 location_opt->required = YES;
59 location_opt->description =
60 _("Name of target project (location) for ortho-rectification");
61
62 mapset_opt = G_define_standard_option(G_OPT_M_MAPSET);
63 mapset_opt->key = "target_mapset";
64 mapset_opt->required = YES;
65 mapset_opt->description =
66 _("Name of target mapset for ortho-rectification");
67
68 if (G_parser(argc, argv))
69 exit(EXIT_FAILURE);
70
71 strcpy(group, group_opt->answer);
72 strcpy(target_location, location_opt->answer);
73 strcpy(target_mapset, mapset_opt->answer);
74
75 I_get_target(group, location, mapset);
76 G_create_alt_env();
77 G_setenv_nogisrc("LOCATION_NAME", target_location);
78 stat = G_mapset_permissions(target_mapset);
79 if (stat != 1) {
80 G_fatal_error(_("Unable to access target project/mapset %s/%s"),
81 target_location, target_mapset);
82 }
83
84 G_setenv_nogisrc("MAPSET", target_mapset);
85 G_get_window(&target_window);
86 if (target_window.proj == PROJECTION_XY)
87 G_fatal_error(_("Target projects (locations) with XY (unreferenced) "
88 "are not supported"));
89 else if (target_window.proj == PROJECTION_LL)
90 G_fatal_error(
91 _("Target projects (locations) with lon/lat are not supported"));
92
93 G_switch_env();
94 I_put_target(group, target_location, target_mapset);
95
96 G_message(_("Group [%s] targeted for project (location) [%s], mapset [%s]"),
97 group, target_location, target_mapset);
98
99 exit(EXIT_SUCCESS);
100 }