[GRASS5] [bug #2225] (grass) v.in.dxf not converting 8bit TEXT

this bug's URL: http://intevation.de/rt/webrt?serial_num=2225
-------------------------------------------------------------------------

Subject: v.in.dxf not converting 8bit TEXT

Platform: GNU/Linux/i386
grass obtained from: Mirror of Trento site
grass binary for platform: Compiled from Sources

DXF has a convention for encoding 8bit strings in 7bit strings by using a
decimal representation ('%%ddd') for bytes with 8th bit set. Example:

  0
TEXT
  8
TOPOGRAPHIE
62
7
10
3453700.036000
20
5556212.001000
30
0.000000
40
3.200000
41
1.200000
  1
Kantstra%%223e
  7
ISO8
50
43.988400000000
51
16.700000000000

v.in.dxf does not convert the 7bit encoding to 8bit.

I have made the following patch to src/mapdev/v.in.dxf/label_box.c to solve
the problem for myself:

*** label_box.c.orig Tue Jan 22 05:51:14 2002
--- label_box.c Sun Nov 16 10:58:00 2003
***************
*** 31,36 ****
--- 31,37 ----
        DXF_DIG *layer_fd, *label_fd;
        int count, char_cnt, code;
        char label[256]; /* same size as dxf_line */
+ char text_style[256];
        double start_x, start_y, angle, theta, height, length, diag;
        double base1, base2;
        int arr_size = 0;
***************
*** 42,47 ****
--- 43,49 ----
        start_y = 0.0;
        height = 1.0;
        angle = 0.0;
+ text_style[0] = '\0';

        while ((code = dxf_readcode (dxf_file)) > 0)
        {
***************
*** 73,78 ****
--- 75,83 ----
                case 50: /* Text angle */
                    angle = atof (dxf_line);
                    break;
+ case 7: /* Text Style */
+ strcpy(text_style,dxf_line);
+ break;

                case 30: /* Z */
                case 41: /* relative X scale factor */
***************
*** 86,92 ****

                debugf("TEXT got unused code %d\n", code );
                case 62: /* Color */
- case 7: /* Text Style */
                case 6: /* Line type */
                default:
                    break;
--- 91,96 ----
***************
*** 181,186 ****
--- 185,195 ----
        ** fprintf (label_fd->fd, "L %lf %lf
%d\n",pt_array[2].x,pt_array[2].y,label);
        ** Labels now characters, not integers BCH-J
        */
+
+ if (strcmp(text_style,"ISO8") == 0) {
+ iso8_convert(label);
+ }
+
      fprintf (label_fd->fd, "L %f %f %s\n",xinfo[0],yinfo[0],label);
      return (0);
  }
***************
*** 212,214 ****
--- 221,252 ----
      }
      return (-1); /* NOT NUMERIC */
  }
+
+
+ int iso8_convert(char *s) {
+ char *sub;
+
+ if (s == NULL) return(-1);
+
+ while ((sub = strstr(s, "%%")) != NULL) {
+ int sublen = strlen(sub);
+ if (sublen < 5) break;
+ if (isdigit(sub[2]) && isdigit(sub[3]) && isdigit(sub[4])) {
+ char dec[4];
+ int c, i;
+ strncpy(dec, &(sub[2]), 3);
+ dec[3] = '\0';
+ c = atoi(dec);
+ sub[0] = c;
+ i = 5;
+ while (sub[i] != '\0') {
+ sub[i-4] = sub[i];
+ i++;
+ }
+ sub[i-4] = '\0';
+ }
+ s = &(sub[1]);
+ }
+
+ return(0);
+ }

Best regards,
Michael Sczittnick

-------------------------------------------- Managed by Request Tracker