[GRASS-SVN] r73180 - grass/trunk/display/d.vect

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 25 09:50:51 PDT 2018


Author: martinl
Date: 2018-08-25 09:50:50 -0700 (Sat, 25 Aug 2018)
New Revision: 73180

Modified:
   grass/trunk/display/d.vect/area.c
   grass/trunk/display/d.vect/d.vect.html
   grass/trunk/display/d.vect/lines.c
Log:
d.vect with z height colors uses a random polygon point for height - patch to fix attached (see #934)


Modified: grass/trunk/display/d.vect/area.c
===================================================================
--- grass/trunk/display/d.vect/area.c	2018-08-25 02:01:07 UTC (rev 73179)
+++ grass/trunk/display/d.vect/area.c	2018-08-25 16:50:50 UTC (rev 73180)
@@ -166,7 +166,9 @@
 
 	/* z height colors */
 	if (zcolors) {
-	    if (Rast_get_d_color(&Points->z[0], &red, &grn, &blu, zcolors) == 1)
+            double zval = (box.B + box.T) / 2; /* midpoint of area bounding box z */
+            G_debug(3, "area=%d -> zval=%f", area, zval);
+	    if (Rast_get_d_color(&zval, &red, &grn, &blu, zcolors) == 1)
 		custom_rgb = TRUE;
 	    else
 		custom_rgb = FALSE;

Modified: grass/trunk/display/d.vect/d.vect.html
===================================================================
--- grass/trunk/display/d.vect/d.vect.html	2018-08-25 02:01:07 UTC (rev 73179)
+++ grass/trunk/display/d.vect/d.vect.html	2018-08-25 16:50:50 UTC (rev 73180)
@@ -81,7 +81,10 @@
 d.vect -c map=soils where="label='VBF'" display=shape attribute_column=label
 </pre></div>
 
-<p>3D points, 3D lines and 3D polygons colorized according to z height:
+<p>3D points, 3D lines and 3D polygons colorized according to z height
+(for 3D lines and polygons a z height is computed by a midpoint of
+line/area bounding box):
+  
 <div class="code"><pre>
 g.region raster=elevation.10m
 r.random input=elevation.10m n=5000 vector=random3d -d

Modified: grass/trunk/display/d.vect/lines.c
===================================================================
--- grass/trunk/display/d.vect/lines.c	2018-08-25 02:01:07 UTC (rev 73179)
+++ grass/trunk/display/d.vect/lines.c	2018-08-25 16:50:50 UTC (rev 73180)
@@ -261,7 +261,11 @@
     
     /* z height colors */
     if (zcolors && (ltype & GV_POINTS)) {
-	if (Rast_get_d_color(&Points->z[0], &red, &grn, &blu, zcolors) == 1)
+        struct bound_box box;
+        Vect_line_box(Points, &box);
+        double zval = (box.B + box.T) / 2; /* midpoint of line bounding box z */
+        G_debug(3, "line=%d -> zval=%f", line, zval);
+	if (Rast_get_d_color(&zval, &red, &grn, &blu, zcolors) == 1)
 	    custom_rgb = TRUE;
 	else
 	    custom_rgb = FALSE;



More information about the grass-commit mailing list