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

« back to all changes in this revision

Viewing changes to vector/v.in.dxf/add_lwpolyline.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_lwpolyline(struct dxf_file *dxf, struct Map_info *Map)
 
5
void add_lwpolyline(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 polyline_flag = 0;      /* indicates the type of polyline */
11
12
    int xflag = 0;              /* indicates if a x value has been found */
17
18
    double bulge = 0.0;         /* for arc curves */
18
19
    double prev_bulge = 0.0;    /* for arc curves */
19
20
 
 
21
    handle[0] = 0;
20
22
    strcpy(layer, UNIDENTIFIED_LAYER);
21
23
 
22
24
    /* read in lines and process information until a 0 is read in */
23
25
    while ((code = dxf_get_code(dxf)) != 0) {
24
26
        if (code == -2)
25
 
            return -1;
 
27
            return;
26
28
 
27
29
        switch (code) {
 
30
        case 5:         /* entity handle */
 
31
            strcpy(handle, dxf_buf);
 
32
            break;
28
33
        case 8:         /* layer name */
29
34
            if (!layer_flag && *dxf_buf) {
30
35
                if (flag_list) {
31
 
                    if (!is_layer_in_list(dxf_buf)) {
32
 
                        add_layer_to_list(dxf_buf);
33
 
                        fprintf(stdout, _("Layer %d: %s\n"), num_layers,
34
 
                                dxf_buf);
35
 
                    }
36
 
                    return 0;
 
36
                    if (!is_layer_in_list(dxf_buf))
 
37
                        add_layer_to_list(dxf_buf, 1);
 
38
                    return;
37
39
                }
38
 
                /* skip if layers != NULL && (
 
40
                /* skip if (opt_layers != NULL && (
39
41
                 * (flag_invert == 0 && is_layer_in_list == 0) ||
40
42
                 * (flag_invert == 1 && is_layer_in_list == 1)
41
43
                 * )
42
44
                 */
43
 
                if (layers && flag_invert == is_layer_in_list(dxf_buf))
44
 
                    return 0;
 
45
                if (opt_layers && flag_invert == is_layer_in_list(dxf_buf))
 
46
                    return;
45
47
                strcpy(layer, dxf_buf);
46
48
                layer_flag = 1;
47
49
            }
61
63
            bulge = atof(dxf_buf);
62
64
            break;
63
65
        case 70:                /* polyline flag */
 
66
 
64
67
            /*******************************************************************
65
68
             Polyline flag (bit-coded); default is 0:
66
69
             1 = Closed; 128 = Plinegen
100
103
            arr_size++;
101
104
 
102
105
            /* arr_size incremented to be consistent with polyline_flag != 1 */
103
 
            if (arr_size == ARR_MAX) {
104
 
                ARR_MAX += ARR_INCR;
105
 
                xpnts = (double *)G_realloc(xpnts, ARR_MAX * sizeof(double));
106
 
                ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
107
 
                zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
 
106
            if (arr_size == arr_max) {
 
107
                arr_max += ARR_INCR;
 
108
                xpnts = (double *)G_realloc(xpnts, arr_max * sizeof(double));
 
109
                ypnts = (double *)G_realloc(ypnts, arr_max * sizeof(double));
 
110
                zpnts = (double *)G_realloc(zpnts, arr_max * sizeof(double));
108
111
            }
109
112
        }
110
113
    }
111
114
 
112
 
    write_line(Map, layer, arr_size);
 
115
    write_vect(Map, layer, "LWPOLYLINE", handle, "", arr_size, GV_LINE);
113
116
 
114
 
    return 0;
 
117
    return;
115
118
}