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

« back to all changes in this revision

Viewing changes to general/g.setproj/main.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:
57
57
    int stat;
58
58
    char cmnd2[500];
59
59
    char proj_out[20], proj_name[50], set_name[20];
60
 
    char path[GPATH_MAX], buffa[1024], buffb[1024], answer[200], answer1[200];
 
60
    char path[1024], buffa[1024], buffb[1024], answer[200], answer1[200];
61
61
    char answer2[200], buff[1024];
62
62
    char tmp_buff[20], *buf;
63
63
 
64
64
    struct Key_Value *old_proj_keys, *out_proj_keys, *in_unit_keys;
65
65
    double aa, e2;
66
66
    double f;
67
 
    FILE *FPROJ, *fp;
 
67
    FILE *FPROJ;
68
68
    int exist = 0;
69
69
    char spheroid[100];
70
70
    int j, k, sph_check;
71
71
    struct Cell_head cellhd;
72
72
    char datum[100], dat_ellps[100], dat_params[100];
73
73
    struct proj_parm *proj_parms;
74
 
    struct Option *set_myname;
75
 
    struct Flag *print_myname;
76
 
 
77
74
 
78
75
    G_gisinit(argv[0]);
79
76
 
80
77
    module = G_define_module();
81
 
    module->keywords = _("general, projection");
 
78
    G_add_keyword(_("general"));
 
79
    G_add_keyword(_("projection"));
82
80
    module->description =
83
81
        _("Interactively reset the location's projection settings.");
84
82
 
85
 
    set_myname = G_define_option();
86
 
    set_myname->key = "description";
87
 
    set_myname->key_desc = "\"phrase\"";
88
 
    set_myname->type = TYPE_STRING;
89
 
    set_myname->required = NO;
90
 
    set_myname->description =
91
 
        _("Reset the location's one line description with this text, then exit");
92
 
 
93
 
    print_myname = G_define_flag();
94
 
    print_myname->key = 'n';
95
 
    print_myname->description =
96
 
        _("Print the location's one line description and exit");
97
 
 
98
 
    if (argc > 1 && G_parser(argc, argv))
 
83
    if (G_parser(argc, argv))
99
84
        exit(EXIT_FAILURE);
100
85
 
101
86
 
102
 
    if (print_myname->answer) {
103
 
        fprintf(stdout, "%s\n", G_myname());
104
 
        exit(EXIT_SUCCESS);
105
 
    }
106
 
 
107
87
    if (strcmp(G_mapset(), "PERMANENT") != 0)
108
88
        G_fatal_error(_("You must be in the PERMANENT mapset to run g.setproj"));
109
89
 
110
 
    if (set_myname->answer) {
111
 
        fp = G_fopen_new(".", "MYNAME");
112
 
        if (strlen(set_myname->answer) > RECORD_LEN-1)
113
 
            G_warning(_("Text shortened to first %d characters"), RECORD_LEN-1);
114
 
        strncpy(buffa, set_myname->answer, RECORD_LEN-1);
115
 
        buffa[RECORD_LEN-1] = '\0';
116
 
        G_squeeze(buffa);
117
 
        fputs(buffa, fp);
118
 
        fclose(fp);
119
 
        exit(EXIT_SUCCESS);
120
 
    }
121
 
 
122
90
        /***
123
 
          * no longer necessary, table is a static struct
 
91
         * no longer necessary, table is a static struct 
124
92
         * init_unit_table();
125
93
        ***/
126
94
    sprintf(set_name, "PERMANENT");
127
 
    G__file_name(path, "", PROJECTION_FILE, set_name);
 
95
    G_file_name(path, "", PROJECTION_FILE, set_name);
128
96
 
129
97
    /* get the output projection parameters, if existing */
130
98
    /* Check for ownership here */
131
 
    stat = G__mapset_permissions(set_name);
 
99
    stat = G_mapset_permissions(set_name);
132
100
    if (stat == 0) {
133
101
        G_fatal_error(_("PERMANENT: permission denied"));
134
102
    }
193
161
        }
194
162
    case PROJECTION_UTM:
195
163
        if (!exist) {
196
 
            sprintf(proj_name, "%s", G__projection_name(PROJECTION_UTM));
 
164
            sprintf(proj_name, "%s", G_projection_name(PROJECTION_UTM));
197
165
            sprintf(proj_out, "utm");
198
166
            break;
199
167
        }
200
168
    case PROJECTION_SP:
201
169
        if (!exist) {
202
 
            sprintf(proj_name, "%s", G__projection_name(PROJECTION_SP));
 
170
            sprintf(proj_name, "%s", G_projection_name(PROJECTION_SP));
203
171
            sprintf(proj_out, "stp");
204
172
            break;
205
173
        }
206
174
    case PROJECTION_LL:
207
175
        if (!exist) {
208
 
            sprintf(proj_name, "%s", G__projection_name(PROJECTION_LL));
 
176
            sprintf(proj_name, "%s", G_projection_name(PROJECTION_LL));
209
177
            sprintf(proj_out, "ll");
210
178
            break;
211
179
        }
279
247
    }
280
248
    else {
281
249
 
282
 
        /*****************   GET spheroid  **************************/
 
250
/*****************   GET spheroid  **************************/
283
251
 
284
252
        if (Out_proj != PROJECTION_SP) {        /* some projections have 
285
253
                                                 * fixed spheroids */
351
319
                    radius =
352
320
                        prompt_num_double(_("Enter radius for the sphere in meters"),
353
321
                                          RADIUS_DEF, 1);
354
 
            }   /* end ask radius */
 
322
            }                   /* end ask radius */
355
323
        }
356
324
    }
357
325
 
519
487
                    G_set_key_value(desc->key, tmp_buff, out_proj_keys);
520
488
                }
521
489
            }
522
 
        }       /* for OPTIONS */
 
490
        }                       /* for OPTIONS */
523
491
    }
524
492
 
525
493
    /* create the PROJ_INFO & PROJ_UNITS files, if required */
534
502
        G_free_key_value(old_proj_keys);
535
503
 
536
504
  write_units:
537
 
    G__file_name(path, "", UNIT_FILE, set_name);
 
505
    G_file_name(path, "", UNIT_FILE, set_name);
538
506
 
539
507
    /* if we got this far, the user
540
508
     ** already affirmed to write over old info
671
639
        G_free_key_value(in_unit_keys);
672
640
    }                           /* if */
673
641
 
674
 
    if (G__put_window(&cellhd, "", "DEFAULT_WIND") < 0)
 
642
    if (G_put_element_window(&cellhd, "", "DEFAULT_WIND") < 0)
675
643
        G_fatal_error(_("Unable to write to DEFAULT_WIND region file"));
676
644
    fprintf(stderr,
677
645
            _("\nProjection information has been recorded for this location\n\n"));