Pārlūkot izejas kodu

d.vect with z height colors uses a random polygon point for height - patch to fix attached (see https://trac.osgeo.org/grass/ticket/934)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73180 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 7 gadi atpakaļ
vecāks
revīzija
67a5c1572c
3 mainītis faili ar 12 papildinājumiem un 3 dzēšanām
  1. 3 1
      display/d.vect/area.c
  2. 4 1
      display/d.vect/d.vect.html
  3. 5 1
      display/d.vect/lines.c

+ 3 - 1
display/d.vect/area.c

@@ -166,7 +166,9 @@ int display_area(struct Map_info *Map, struct cat_list *Clist, const struct Cell
 
 	/* 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;

+ 4 - 1
display/d.vect/d.vect.html

@@ -81,7 +81,10 @@ d.vect -c map=soils attribute_column=label
 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

+ 5 - 1
display/d.vect/lines.c

@@ -261,7 +261,11 @@ int draw_line(int type, int ltype, int line,
     
     /* 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;