[GRASS-SVN] r56031 - grass/branches/develbranch_6/display/d.grid

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 29 04:08:16 PDT 2013


Author: hamish
Date: 2013-04-29 04:08:15 -0700 (Mon, 29 Apr 2013)
New Revision: 56031

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

Modified: grass/branches/develbranch_6/display/d.grid/plot.c
===================================================================
--- grass/branches/develbranch_6/display/d.grid/plot.c	2013-04-29 07:10:07 UTC (rev 56030)
+++ grass/branches/develbranch_6/display/d.grid/plot.c	2013-04-29 11:08:15 UTC (rev 56031)
@@ -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;
@@ -242,6 +243,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;
 
@@ -269,9 +271,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_a_row(n1) < extra_y_off)
+			start_coord = -9999.;  /* wait until the next point south */
+		}
 	    }
 
 	    if (line_width)
@@ -290,7 +299,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