[GRASS-SVN] r37351 - grass/trunk/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 22 05:16:53 EDT 2009


Author: hamish
Date: 2009-05-22 05:16:52 -0400 (Fri, 22 May 2009)
New Revision: 37351

Modified:
   grass/trunk/ps/ps.map/ps_vareas.c
Log:
don't fill islands (merge from devbr6)

Modified: grass/trunk/ps/ps.map/ps_vareas.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vareas.c	2009-05-22 09:03:43 UTC (rev 37350)
+++ grass/trunk/ps/ps.map/ps_vareas.c	2009-05-22 09:16:52 UTC (rev 37351)
@@ -82,15 +82,16 @@
     return 1;
 }
 
-/* set pscolor based on rgb color definition stored in rgbcolumn */
-void set_ps_color_rgbcol_varea(struct Map_info *map, int vec, int area,
-			       dbCatValArray * cvarr_rgb)
+
+/* get pscolor based on rgb color definition stored in rgbcolumn */
+/*   sets *color and returns 1 on success, -1 if no color found */
+int get_ps_color_rgbcol_varea(struct Map_info *map, int vec, int area,
+			       dbCatValArray * cvarr_rgb, PSCOLOR *color)
 {
     int cat, ret;
     dbCatVal *cv_rgb;
     int red, grn, blu;
     char *rgbstring = NULL;
-    PSCOLOR color;
 
     cat = Vect_get_area_cat(map, area, vector.layer[vec].field);
 
@@ -110,21 +111,18 @@
     }
 
     if (rgbstring) {
-	G_debug(3, "    dynamic symbol rgb color = %s", rgbstring);
-
-	set_color(&color, red, grn, blu);
-	set_ps_color(&color);
+	G_debug(3, "    dynamic varea fill rgb color = %s", rgbstring);
+	set_color(color, red, grn, blu);
     }
-    else {			/* use default symbol */
-	G_debug(3, "    static symbol rgb color = %d:%d:%d",
-		vector.layer[vec].color.r,
-		vector.layer[vec].color.g, vector.layer[vec].color.b);
+    else {
+	set_color(color, 0, 0, 0);
+	return -1;
+    }
 
-	set_ps_color(&(vector.layer[vec].fcolor));
-    }
-    return;
+    return 1;
 }
 
+
 /* plot areas */
 int PS_vareas_plot(struct Map_info *P_map, int vec)
 {
@@ -135,6 +133,8 @@
     struct line_cats *Cats;
     BOUND_BOX box;
     VARRAY *Varray = NULL;
+    PSCOLOR color;
+    int centroid;
 
     /* rgbcol */
     dbCatValArray cvarr_rgb;
@@ -172,9 +172,19 @@
     /* read and plot areas */
     na = Vect_get_num_areas(P_map);
     for (area = 1; area <= na; area++) {
+	G_debug(4, "area = %d", area);
+
 	if (Varray != NULL && Varray->c[area] == 0)
 	    continue;		/* is not in array */
 
+	if (!Vect_area_alive(P_map, area))
+	    continue;
+
+	centroid = Vect_get_area_centroid(P_map, area);
+	G_debug(4, "centroid = %d", centroid);
+	if (centroid < 1)  /* area is an island */
+	    continue;
+
 	Vect_get_area_box(P_map, area, &box);
 	n = box.N;
 	s = box.S;
@@ -209,9 +219,21 @@
 	    if (ret != 1)
 		return 0;
 	}
+
 	if (vector.layer[vec].pat != NULL ||
 	    (!color_none(&vector.layer[vec].fcolor) ||
 	     vector.layer[vec].rgbcol != NULL)) {
+
+	    if (vector.layer[vec].rgbcol != NULL) {
+		/* load fill color from rgbcol */
+		/* if data column is empty or cat is missing don't fill */
+		if (get_ps_color_rgbcol_varea(P_map, vec, area, &cvarr_rgb, &color) != 1)
+		    return 0;
+	    }
+	    else {
+		color = vector.layer[vec].fcolor;
+	    }
+
 	    if (vector.layer[vec].pat != NULL) {	/* use pattern */
 		sc = vector.layer[vec].scale;
 		/* DEBUG */
@@ -231,13 +253,9 @@
 			(urx - llx) * sc, (ury - lly) * sc);
 		fprintf(PS.fp, "    /PaintProc\n      { begin\n");
 		fprintf(PS.fp, "        %f %f scale\n", sc, sc);
-		/* load line color from rgbcol */
-		if (vector.layer[vec].rgbcol != NULL) {
-		    set_ps_color_rgbcol_varea(P_map, vec, area, &cvarr_rgb);
-		}
-		else {
-		    set_ps_color(&(vector.layer[vec].fcolor));
-		}
+
+		set_ps_color(&color);
+
 		fprintf(PS.fp, "        %.8f W\n", vector.layer[vec].pwidth);
 		fprintf(PS.fp, "        %s\n", pat);
 		fprintf(PS.fp, "        end\n");
@@ -247,13 +265,7 @@
 		fprintf(PS.fp, "/Pattern setcolorspace\n %s setcolor\n", pat);
 	    }
 	    else {
-		/* load line color from rgbcol */
-		if (vector.layer[vec].rgbcol != NULL) {
-		    set_ps_color_rgbcol_varea(P_map, vec, area, &cvarr_rgb);
-		}
-		else {
-		    set_ps_color(&(vector.layer[vec].fcolor));
-		}
+		set_ps_color(&color);
 	    }
 
 	    fprintf(PS.fp, "F\n");



More information about the grass-commit mailing list