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

« back to all changes in this revision

Viewing changes to vector/v.what/what.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:
15
15
#define WDTH 5
16
16
 
17
17
int what(double east, double north, double maxdist, int width,
18
 
         int mwidth, int topo, int showextra)
 
18
         int mwidth, int topo, int showextra, int script)
19
19
{
20
20
    int type;
21
21
    char east_buf[40], north_buf[40];
38
38
 
39
39
    /* always use plain feet not US survey ft */
40
40
    /*  if you really want USfeet, try G_database_units_to_meters_factor()
41
 
        here, but then watch that sq_miles is not affected too */
 
41
        here, but then watch that sq_miles is not affected too */
42
42
    sqm_to_sqft = 1 / ( 0.0254 * 0.0254 * 12 * 12 );
43
43
 
44
44
 
52
52
                           maxdist, 0, 0);
53
53
        if (line == 0) {
54
54
            line = Vect_find_line(&Map[i], east, north, 0.0,
55
 
                                  GV_LINE | GV_BOUNDARY | GV_FACE, maxdist, 0,
56
 
                                  0);
 
55
                                  GV_LINE | GV_BOUNDARY | GV_FACE, maxdist, 0, 0);
57
56
        }
58
57
 
59
58
        if (line == 0) {
67
66
            G_format_easting(east, east_buf, G_projection());
68
67
            G_format_northing(north, north_buf, G_projection());
69
68
            if (line + area > 0 || G_verbose() >= G_verbose_std()) {
70
 
                fprintf(stdout, "\nEast: %s\nNorth: %s\n", east_buf,
71
 
                        north_buf);
 
69
                if (script) {
 
70
                    fprintf(stdout, "East=%s\nNorth=%s\n", east_buf,
 
71
                            north_buf);
 
72
                }
 
73
                else {
 
74
                    fprintf(stdout, "\nEast: %s\nNorth: %s\n", east_buf,
 
75
                            north_buf);
 
76
                }
72
77
                if (notty)
73
78
                    fprintf(stderr, "\nEast: %s\nNorth: %s\n", east_buf,
74
79
                            north_buf);
81
86
            *str = 0;
82
87
 
83
88
        if (line + area > 0 || G_verbose() >= G_verbose_std()) {
84
 
            /* fprintf(stdout, "Map: %*s \nMapset: %-*s\n", width, Map[i].name, mwidth, Map[i].mapset); */
85
 
            fprintf(stdout, "\nMap: %s \nMapset: %s\n", Map[i].name,
86
 
                    Map[i].mapset);
 
89
            if (script) {
 
90
                fprintf(stdout, "Map=%s\nMapset=%s\n", Map[i].name,
 
91
                        Map[i].mapset);
 
92
            }
 
93
            else {
 
94
                fprintf(stdout, "\nMap: %s \nMapset: %s\n", Map[i].name,
 
95
                        Map[i].mapset);
 
96
            }
87
97
            if (notty)
88
 
                /* fprintf(stderr, "Map: %*s \nMapset: %-*s\n", width, Map[i].name, mwidth, Map[i].mapset); */
89
98
                fprintf(stderr, "\nMap: %s \nMapset: %s\n", Map[i].name,
90
99
                        Map[i].mapset);
91
100
        }
135
144
                float angle;
136
145
 
137
146
                Vect_get_line_areas(&(Map[i]), line, &left, &right);
138
 
                fprintf(stdout, "Looking for features within: %f\n",
139
 
                        maxdist);
140
 
                fprintf(stdout,
141
 
                        _("Id: %d\nType: %s\nLeft: %d\nRight: %d\n"),
142
 
                        line, buf, left, right);
 
147
                if (script) {
 
148
                    fprintf(stdout, "Feature_max_distance=%f\n", maxdist);
 
149
                    fprintf(stdout,
 
150
                            "Id=%d\nType=%s\nLeft=%d\nRight=%d\n",
 
151
                            line, buf, left, right);
 
152
                }
 
153
                else {
 
154
                    fprintf(stdout, "Looking for features within: %f\n",
 
155
                            maxdist);
 
156
                    fprintf(stdout,
 
157
                            _("Id: %d\nType: %s\nLeft: %d\nRight: %d\n"),
 
158
                            line, buf, left, right);
 
159
                }
143
160
                if (type & GV_LINES) {
144
161
                    nnodes = 2;
145
162
                    fprintf(stdout, _("Length: %f\n"), l);
146
163
                }
147
164
                else {          /* points */
148
165
                    nnodes = 1;
149
 
                    fprintf(stdout, "\n");
 
166
                    if (!script)
 
167
                        fprintf(stdout, "\n");
150
168
                }
151
169
 
152
170
                Vect_get_line_nodes(&(Map[i]), line, &node[0], &node[1]);
157
175
                    nnlines = Vect_get_node_n_lines(&(Map[i]), node[n]);
158
176
 
159
177
                    Vect_get_node_coor(&(Map[i]), node[n], &nx, &ny, &nz);
160
 
                    fprintf(stdout,
161
 
                            _("Node[%d]: %d\nNumber of lines: %d\nCoordinates: %.6f, %.6f, %.6f\n"),
162
 
                            n, node[n], nnlines, nx, ny, nz);
 
178
                    if (script) {
 
179
                        fprintf(stdout,
 
180
                                _("Node[%d]=%d\nNumber_lines=%d\nCoordinates=%.6f,%.6f,%.6f\n"),
 
181
                                n, node[n], nnlines, nx, ny, nz);
 
182
                    }
 
183
                    else {
 
184
                        fprintf(stdout,
 
185
                                _("Node[%d]: %d\nNumber of lines: %d\nCoordinates: %.6f, %.6f, %.6f\n"),
 
186
                                n, node[n], nnlines, nx, ny, nz);
 
187
                    }
163
188
 
164
189
                    for (nli = 0; nli < nnlines; nli++) {
165
190
                        nodeline =
166
191
                            Vect_get_node_line(&(Map[i]), node[n], nli);
167
192
                        angle =
168
193
                            Vect_get_node_line_angle(&(Map[i]), node[n], nli);
169
 
                        fprintf(stdout, _("Id: %5d\nAngle: %.8f\n"),
170
 
                                nodeline, angle);
 
194
                        if (script) {
 
195
                            fprintf(stdout, "Id=%5d\nAngle=%.8f\n",
 
196
                                    nodeline, angle);
 
197
                        }
 
198
                        else {
 
199
                            fprintf(stdout, _("Id: %5d\nAngle: %.8f\n"),
 
200
                                    nodeline, angle);
 
201
                        }
171
202
                    }
172
203
                }
173
204
 
174
205
            }
175
206
            else {
176
 
                fprintf(stdout, _("Type: %s"), buf);
177
 
                fprintf(stdout, _("Id: %d\n"), line);
178
 
                if (type & GV_LINES)
179
 
                    fprintf(stdout, _("Length: %f\n"), l);
 
207
                if (script) {
 
208
                    fprintf(stdout, "Type=%s\n", buf);
 
209
                    fprintf(stdout, "Id=%d\n", line);
 
210
                    if (type & GV_LINES)
 
211
                        fprintf(stdout, "Length=%f\n", l);
 
212
                }
 
213
                else {
 
214
                    fprintf(stdout, _("Type: %s"), buf);
 
215
                    fprintf(stdout, _("Id: %d\n"), line);
 
216
                    if (type & GV_LINES)
 
217
                        fprintf(stdout, _("Length: %f\n"), l);
 
218
                }
180
219
            }
181
220
 
182
221
            /* Height */
185
224
                double min, max;
186
225
 
187
226
                if (type & GV_POINTS) {
188
 
                    fprintf(stdout, _("Point height: %f\n"), Points->z[0]);
 
227
                    if (script) {
 
228
                        fprintf(stdout, "Point_height=%f\n", Points->z[0]);
 
229
                    }
 
230
                    else {
 
231
                        fprintf(stdout, _("Point height: %f\n"),
 
232
                                Points->z[0]);
 
233
                    }
189
234
                }
190
235
                else if (type & GV_LINES) {
191
236
                    min = max = Points->z[0];
196
241
                            max = Points->z[j];
197
242
                    }
198
243
                    if (min == max) {
199
 
                        fprintf(stdout, _("Line height: %f\n"), min);
 
244
                        if (script) {
 
245
                            fprintf(stdout, "Line_height=%f\n", min);
 
246
                        }
 
247
                        else {
 
248
                            fprintf(stdout, _("Line height: %f\n"), min);
 
249
                        }
200
250
                    }
201
251
                    else {
202
 
                        fprintf(stdout,
203
 
                                _("Line height min: %f\nLine height max: %f\n"),
204
 
                                min, max);
 
252
                        if (script) {
 
253
                            fprintf(stdout,
 
254
                                    "Line_height_min=%f\nLine_height_max=%f\n",
 
255
                                    min, max);
 
256
                        }
 
257
                        else {
 
258
                            fprintf(stdout,
 
259
                                    _("Line height min: %f\nLine height max: %f\n"),
 
260
                                    min, max);
 
261
                        }
205
262
                    }
206
263
                }
207
264
            }                   /* if height */
209
266
 
210
267
        if (area > 0) {
211
268
            if (Map[i].head.with_z && getz) {
212
 
                fprintf(stdout, _("Type: Area\nArea height: %f\n"),
213
 
                        z);
 
269
                if (script) {
 
270
                    fprintf(stdout, "Type=Area\nArea_height=%f\n", z);
 
271
                }
 
272
                else {
 
273
                fprintf(stdout, _("Type: Area\nArea height: %f\n"), z);
 
274
                }
214
275
            }
215
276
            else {
216
 
                fprintf(stdout, _("Type: Area\n"));
 
277
                if (script) {
 
278
                    fprintf(stdout, "Type=Area\n");
 
279
                }
 
280
                else {
 
281
                    fprintf(stdout, _("Type: Area\n"));
 
282
                }
217
283
            }
218
284
 
219
285
 
229
295
                int nisles, isleidx, isle, isle_area;
230
296
 
231
297
                nisles = Vect_get_area_num_isles(&Map[i], area);
232
 
                fprintf(stdout, _("Area: %d\nNumber of isles: %d\n"), area,
233
 
                        nisles);
 
298
                if (script) {
 
299
                    fprintf(stdout, "Area=%d\nNumber_isles=%d\n", area,
 
300
                            nisles);
 
301
                }
 
302
                else {
 
303
                    fprintf(stdout, _("Area: %d\nNumber of isles: %d\n"),
 
304
                            area, nisles);
 
305
                }
234
306
 
235
307
                for (isleidx = 0; isleidx < nisles; isleidx++) {
236
308
                    isle = Vect_get_area_isle(&Map[i], area, isleidx);
237
 
                    fprintf(stdout, _("Isle[%d]: %d\n"), isleidx, isle);
 
309
                    if (script) {
 
310
                        fprintf(stdout, "Isle[%d]=%d\n", isleidx, isle);
 
311
                    }
 
312
                    else {
 
313
                        fprintf(stdout, _("Isle[%d]: %d\n"), isleidx, isle);
 
314
                    }
238
315
                }
239
316
 
240
317
                isle = Vect_find_island(&Map[i], east, north);
241
318
 
242
319
                if (isle) {
243
320
                    isle_area = Vect_get_isle_area(&Map[i], isle);
244
 
                    fprintf(stdout, _("Island: %d In area: %d\n"), isle,
245
 
                            isle_area);
 
321
                    if (script) {
 
322
                        fprintf(stdout, "Island=%d\nIsland_area=%d\n", isle,
 
323
                                isle_area);
 
324
                    }
 
325
                    else {
 
326
                        fprintf(stdout, _("Island: %d In area: %d\n"), isle,
 
327
                                isle_area);
 
328
                    }
246
329
                }
247
330
            }
248
331
            else {
249
 
                fprintf(stdout, _("Sq Meters: %.3f\nHectares: %.3f\n"),
250
 
                        sq_meters, hectares);
251
 
                fprintf(stdout, _("Acres: %.3f\nSq Miles: %.4f\n"),
252
 
                        acres, sq_miles);
 
332
                if (script) {
 
333
                    fprintf(stdout, "Sq_Meters=%.3f\nHectares=%.3f\n",
 
334
                            sq_meters, hectares);
 
335
                    fprintf(stdout, "Acres=%.3f\nSq_Miles=%.4f\n",
 
336
                            acres, sq_miles);
 
337
                }
 
338
                else {
 
339
                    fprintf(stdout, _("Sq Meters: %.3f\nHectares: %.3f\n"),
 
340
                            sq_meters, hectares);
 
341
                    fprintf(stdout, _("Acres: %.3f\nSq Miles: %.4f\n"),
 
342
                            acres, sq_miles);
 
343
                }
253
344
                if (notty) {
254
345
                    fprintf(stderr,
255
346
                            _("Sq Meters: %.3f\nHectares: %.3f\n"),
268
359
 
269
360
        if (Cats->n_cats > 0) {
270
361
            int j;
 
362
            char *formbuf1, *formbuf2;
271
363
 
272
364
            for (j = 0; j < Cats->n_cats; j++) {
273
365
                G_debug(2, "field = %d  category = %d\n", Cats->field[j],
274
366
                        Cats->cat[j]);
275
 
                fprintf(stdout, _("Layer: %d\nCategory: %d\n"),
276
 
                        Cats->field[j], Cats->cat[j]);
 
367
                if (script) {
 
368
                    fprintf(stdout, "Layer=%d\nCategory=%d\n", Cats->field[j],
 
369
                            Cats->cat[j]);
 
370
                }
 
371
                else {
 
372
                    fprintf(stdout, _("Layer: %d\nCategory: %d\n"),
 
373
                            Cats->field[j], Cats->cat[j]);
 
374
                }
277
375
                Fi = Vect_get_field(&(Map[i]), Cats->field[j]);
278
376
                if (Fi != NULL && showextra) {
279
377
                    int format = F_TXT, edit_mode = F_VIEW;
280
378
 
281
 
                    fprintf(stdout,
282
 
                            _("\nDriver: %s\nDatabase: %s\nTable: %s\nKey column: %s\n"),
283
 
                            Fi->driver, Fi->database, Fi->table, Fi->key);
284
 
                    F_generate(Fi->driver, Fi->database, Fi->table, Fi->key,
285
 
                               Cats->cat[j], NULL, NULL, edit_mode, format,
286
 
                               &form);
287
 
                    fprintf(stdout, "%s", form);
 
379
                    if (script) {
 
380
                        fprintf(stdout,
 
381
                                "Driver=%s\nDatabase=%s\nTable=%s\nKey_column=%s\n",
 
382
                                Fi->driver, Fi->database, Fi->table, Fi->key);
 
383
                    }
 
384
                    else {
 
385
                        fprintf(stdout,
 
386
                                _("\nDriver: %s\nDatabase: %s\nTable: %s\nKey column: %s\n"),
 
387
                                Fi->driver, Fi->database, Fi->table, Fi->key);
 
388
                    }
 
389
                    F_generate(Fi->driver, Fi->database, Fi->table,
 
390
                               Fi->key, Cats->cat[j], NULL, NULL,
 
391
                               edit_mode, format, &form);
 
392
 
 
393
                    if (script) {
 
394
                        formbuf1 = G_str_replace(form, " : ", "=");
 
395
                        formbuf2 = G_str_replace(formbuf1, " ", "_");
 
396
                        fprintf(stdout, "%s", formbuf2);
 
397
                        G_free(formbuf1);
 
398
                        G_free(formbuf2);
 
399
                    }
 
400
                    else
 
401
                        fprintf(stdout, "%s", form);
288
402
                    G_free(form);
289
403
                    G_free(Fi);
290
404
                }