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

« back to all changes in this revision

Viewing changes to vector/v.in.dxf/add_line.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:
2
2
#include <string.h>
3
3
#include "global.h"
4
4
 
5
 
int add_line(struct dxf_file *dxf, struct Map_info *Map)
 
5
void add_line(struct dxf_file *dxf, struct Map_info *Map)
6
6
{
7
7
    int code;
8
 
    char layer[DXF_BUF_SIZE];
 
8
    char handle[DXF_BUF_SIZE];  /* entity handle, 16 hexadecimal digits */
 
9
    char layer[DXF_BUF_SIZE];   /* layer name */
9
10
    int layer_flag = 0;         /* indicates if a layer name has been found */
10
11
    int xflag = 0;              /* indicates if a x value has been found */
11
12
    int yflag = 0;              /* indicates if a y value has been found */
12
13
    int zflag = 0;              /* indicates if a z value has been found */
13
14
    int arr_size = 0;
14
15
 
 
16
    handle[0] = 0;
15
17
    strcpy(layer, UNIDENTIFIED_LAYER);
16
18
 
17
19
    /* read in lines and process information until a 0 is read in */
18
20
    while ((code = dxf_get_code(dxf)) != 0) {
19
21
        if (code == -2)
20
 
            return -1;
 
22
            return;
21
23
 
22
24
        switch (code) {
 
25
        case 5:         /* entity handle */
 
26
            strcpy(handle, dxf_buf);
 
27
            break;
23
28
        case 8:         /* layer name */
24
29
            if (!layer_flag && *dxf_buf) {
25
30
                if (flag_list) {
26
 
                    if (!is_layer_in_list(dxf_buf)) {
27
 
                        add_layer_to_list(dxf_buf);
28
 
                        fprintf(stdout, _("Layer %d: %s\n"), num_layers,
29
 
                                dxf_buf);
30
 
                    }
31
 
                    return 0;
 
31
                    if (!is_layer_in_list(dxf_buf))
 
32
                        add_layer_to_list(dxf_buf, 1);
 
33
                    return;
32
34
                }
33
 
                /* skip if layers != NULL && (
 
35
                /* skip if (opt_layers != NULL && (
34
36
                 * (flag_invert == 0 && is_layer_in_list == 0) ||
35
37
                 * (flag_invert == 1 && is_layer_in_list == 1)
36
38
                 * )
37
39
                 */
38
 
                if (layers && flag_invert == is_layer_in_list(dxf_buf))
39
 
                    return 0;
 
40
                if (opt_layers && flag_invert == is_layer_in_list(dxf_buf))
 
41
                    return;
40
42
                strcpy(layer, dxf_buf);
41
43
                layer_flag = 1;
42
44
            }
76
78
        }
77
79
    }
78
80
 
79
 
    if (arr_size == 2)  /* have both start and stop */
80
 
        write_line(Map, layer, arr_size);
 
81
    if (arr_size == 2)          /* have both start and stop */
 
82
        write_vect(Map, layer, "LINE", handle, "", arr_size, GV_LINE);
81
83
 
82
 
    return 0;
 
84
    return;
83
85
}