Hi!

I have a patch to d.labels that I intend to apply. This patch adds support for positioning the label _exactly_ on the co-ordinated given in the labels file. The reason I need this is that v.label.sa calculates precise locations for labels, and naturally I want the labels to be placed exactly on that point.

Feel free to comment on the patch. Next I need to look at how ps.map positions labels...

Please see [1] for example screenshots.

--Wolf

[1] http://wolf.bergenheim.net/src/GRASS/v.label.sa

--

<:3 )---- Wolf Bergenheim ----( 8:>

Index: do_labels.c
===================================================================
--- do_labels.c	(revision 31091)
+++ do_labels.c	(working copy)
@@ -15,6 +15,7 @@
 #define TOP	0
 #define CENT	1
 #define BOT	2
+#define NONE	3
 #define LEFT	0
 #define RITE	2
 #define YES	1
@@ -243,7 +244,10 @@
 
 	G_debug(3, "line %d ='%s'", n_lines, line);
 
-	Y = (int)(D_u_to_d_row(north - (line_size*1.2) - ((n_lines-1)*line_size) ));
+	if (yref == NONE)
+	    Y = D_u_to_d_row(north);
+	else
+	    Y = (int)(D_u_to_d_row(north - (line_size*1.2) - ((n_lines-1)*line_size) ));
 	R_move_abs(X, Y) ;
 	R_text_rotation(0.0); /* reset */
 	R_get_text_box(line, &t, &b, &l, &r) ;
@@ -368,7 +372,10 @@
 	    *lptr = '\0' ;
 
 	    /* figure out text placement */
-	    Y = (int)(D_u_to_d_row(north - (line_size*1.2) - ((i-1)*line_size) ));
+	    if (yref == NONE)
+		Y = D_u_to_d_row(north);
+	    else
+		Y = (int)(D_u_to_d_row(north - (line_size*1.2) - ((i-1)*line_size) ));
 	    text_x = X + X_just_offset; /* reset after G_rotate_around_point_int() */
 	    text_y = Y + Y_just_offset;
 	    G_rotate_around_point_int(X, Y0, &text_x, &text_y, -1*rotation);
@@ -423,7 +430,10 @@
 	*lptr = '\0' ;
 
 	/* figure out text placement */
-	Y = (int)(D_u_to_d_row(north - (line_size*1.2) - ((i-1)*line_size) ));
+	if (yref == NONE)
+	    Y = D_u_to_d_row(north);
+	else
+	    Y = (int)(D_u_to_d_row(north - (line_size*1.2) - ((i-1)*line_size) ));
 	text_x = X + X_just_offset; /* reset after G_rotate_around_point_int() */
 	text_y = Y + Y_just_offset;
 	G_rotate_around_point_int(X, Y0, &text_x, &text_y, -1*rotation);
@@ -478,6 +488,8 @@
 	xref = LEFT;
     else if (strcmp (word, "right") == 0)
 	xref = RITE;
+    else if (strcmp (word, "none") == 0)
+	xref = LEFT;
     else
 	return 0;
     xok = 1;
@@ -500,6 +512,8 @@
 	yref = BOT;
     else if (strcmp (word, "bottom") == 0)
 	yref = BOT;
+    else if (strcmp (word, "none") == 0)
+	yref = NONE;
     else
 	return 0;
     yok = 1;
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to