[GRASS-SVN] r56047 - grass/branches/releasebranch_6_4/display/d.grid

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 30 03:03:21 PDT 2013


Author: hamish
Date: 2013-04-30 03:03:21 -0700 (Tue, 30 Apr 2013)
New Revision: 56047

Modified:
   grass/branches/releasebranch_6_4/display/d.grid/plot.c
Log:
fix geogrid longitude text label placement, especially for projections with highly rotated meridians like LCC (merge from devbr6)

Modified: grass/branches/releasebranch_6_4/display/d.grid/plot.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.grid/plot.c	2013-04-30 09:59:46 UTC (rev 56046)
+++ grass/branches/releasebranch_6_4/display/d.grid/plot.c	2013-04-30 10:03:21 UTC (rev 56047)
@@ -159,6 +159,7 @@
     int SEGS = 100;
     char text[128];
     float border_off = 4.5;
+    float extra_y_off;
     float grid_off = 3.;
     double row_dist, colm_dist;
     float font_angle;
@@ -239,6 +240,7 @@
     n1 = north;
     for (j = 0; g > west; j++, g -= size) {
 	start_coord = -9999.;
+	extra_y_off = 0.0;
 	if (g == east || g == west)
 	    continue;
 
@@ -266,9 +268,16 @@
 	    e2 = lon;
 	    n2 = lat;
 
-	    if (start_coord == -9999.) {
+	    if ((start_coord == -9999.) && (D_u_to_a_row(n1) > 0)) {
 		font_angle = get_heading((e1 - e2), (n1 - n2));
 		start_coord = e1;
+
+		/* font rotates by bottom-left corner, try to keep top-left cnr on screen */
+		if (font_angle - 270 > 0) {
+		    extra_y_off = sin((font_angle - 270) * M_PI/180) * fontsize;
+		    if (D_u_to_d_row(n1) - D_get_d_north() < extra_y_off + grid_off)
+			start_coord = -9999.;  /* wait until the next point south */
+		}
 	    }
 
 	    if (line_width)
@@ -284,7 +293,7 @@
 	    R_text_rotation(font_angle);
 	    R_text_size(fontsize, fontsize);
 	    R_move_abs((int)(D_u_to_d_col(start_coord) + grid_off + 1.5),
-		       (int)(D_get_d_north() + border_off));
+		       (int)(D_get_d_north() + border_off + extra_y_off));
 	    R_text(text);
 	}
     }



More information about the grass-commit mailing list