瀏覽代碼

d.grid: fix labels in latlon, see https://trac.osgeo.org/grass/ticket/3017

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68556 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 9 年之前
父節點
當前提交
9019acd147
共有 1 個文件被更改,包括 17 次插入8 次删除
  1. 17 8
      display/d.grid/plot.c

+ 17 - 8
display/d.grid/plot.c

@@ -138,10 +138,21 @@ int plot_grid(double grid_size, double east, double north, int do_text,
                     D_get_text_box(text, &bt, &bb, &bl, &br);
                     w = br - bl;
                     h = bt - bb;
+
+                    if (w > 0)
+                        w += 0.2 * fontsize * fabs(D_get_d_to_u_xconv());
+                    else  /* D_text() does not draw " ". */
+                        w = 0.8 * fontsize * fabs(D_get_d_to_u_xconv());
+                    if (h > 0)
+                        h += 0.2 * fontsize * fabs(D_get_d_to_u_yconv());
+                    else  /* D_text() does not draw " ". */
+                        h = 0.8 * fontsize * fabs(D_get_d_to_u_yconv());
+
                     bl = tx - w/2;
                     bt = ty + h/10;
                     br = tx + w + w/2;
                     bb = ty - h - h/10;
+
                     D_use_color(bgcolor);
                     D_box_abs(bl, bt, br, bb);
                 }
@@ -191,15 +202,13 @@ int plot_grid(double grid_size, double east, double north, int do_text,
                     h = bt - bb;
 
                     if (w > 0)
-                    w += 0.2 * fontsize;
-                    else
-                    /* D_text() does not draw " ". */
-                    w = 0.8 * fontsize;
+                        w += 0.2 * fontsize * fabs(D_get_d_to_u_xconv());
+                    else  /* D_text() does not draw " ". */
+                        w = 0.8 * fontsize * fabs(D_get_d_to_u_xconv());
                     if (h > 0)
-                    h += 0.2 * fontsize;
-                    else
-                    /* D_text() does not draw " ". */
-                    h = 0.8 * fontsize;
+                        h += 0.2 * fontsize * fabs(D_get_d_to_u_yconv());
+                    else  /* D_text() does not draw " ". */
+                        h = 0.8 * fontsize * fabs(D_get_d_to_u_yconv());
 
                     bl = tx - w/10;
                     bt = ty + h + h/2;