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

« back to all changes in this revision

Viewing changes to vector/v.in.dxf/add_text.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_text(struct dxf_file *dxf, struct Map_info *Map)
 
5
void add_text(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 */
14
15
    char label[DXF_BUF_SIZE];   /* read in from dxf file */
15
16
    int label_len = 0;
16
17
 
 
18
    handle[0] = 0;
17
19
    strcpy(layer, UNIDENTIFIED_LAYER);
18
20
 
19
21
    zpnts[0] = 0.0;
20
22
    /* read in lines and process information until a 0 is read in */
21
23
    while ((code = dxf_get_code(dxf)) != 0) {
22
24
        if (code == -2)
23
 
            return -1;
 
25
            return;
24
26
 
25
27
        switch (code) {
26
28
        case 1:         /* label value */
27
29
            label_len = strlen(dxf_buf);
28
30
            strcpy(label, dxf_buf);
29
31
            break;
 
32
        case 5:         /* entity handle */
 
33
            strcpy(handle, dxf_buf);
 
34
            break;
30
35
        case 8:         /* layer name */
31
36
            if (!layer_flag && *dxf_buf) {
32
37
                if (flag_list) {
33
 
                    if (!is_layer_in_list(dxf_buf)) {
34
 
                        add_layer_to_list(dxf_buf);
35
 
                        fprintf(stdout, _("Layer %d: %s\n"), num_layers,
36
 
                                dxf_buf);
37
 
                    }
38
 
                    return 0;
 
38
                    if (!is_layer_in_list(dxf_buf))
 
39
                        add_layer_to_list(dxf_buf, 1);
 
40
                    return;
39
41
                }
40
 
                /* skip if layers != NULL && (
 
42
                /* skip if (opt_layers != NULL && (
41
43
                 * (flag_invert == 0 && is_layer_in_list == 0) ||
42
44
                 * (flag_invert == 1 && is_layer_in_list == 1)
43
45
                 * )
44
46
                 */
45
 
                if (layers && flag_invert == is_layer_in_list(dxf_buf))
46
 
                    return 0;
 
47
                if (opt_layers && flag_invert == is_layer_in_list(dxf_buf))
 
48
                    return;
47
49
                strcpy(layer, dxf_buf);
48
50
                layer_flag = 1;
49
51
            }
79
81
    }
80
82
 
81
83
    if (label_len == 0)
82
 
        return -2;
 
84
        return;
83
85
 
84
86
    if (xflag && yflag) {
85
87
        /* TODO */
111
113
        ypnts[3] = ypnts[0] + (length * sin(theta));
112
114
        zpnts[3] = zpnts[0];
113
115
 
114
 
        write_line(Map, layer, 5);
 
116
        write_vect(Map, layer, "TEXT", handle, "", 5, GV_LINE);
115
117
#endif
116
 
        write_text(Map, layer, label);
 
118
        write_vect(Map, layer, "TEXT", handle, label, 1, GV_POINT);
117
119
    }
118
120
 
119
 
    return 0;
 
121
    return;
120
122
}