Opened 15 years ago

Closed 6 years ago

#934 closed enhancement (fixed)

d.vect with z height colors uses a random polygon point for height - patch to fix attached

Reported by: jarim Owned by: grass-dev@…
Priority: normal Milestone: 7.6.0
Component: Display Version: svn-trunk
Keywords: d.vect, z height color zcolor Cc:
CPU: x86-32 Platform: All

Description

When you use d.vect with -z and zcolor= options the polygons are colored based on a table of heights and colors. Looking at the source code in display/d.vect/area.c the point (z coordinate) that is used for the color lookup is taken from the first vertex of the area. From the user's point of view this can appear as a random point, especially if the areas are triangles that are created by v.delaunay. For delaunay triangles using a single vertex does not make sense if all three points are at different heights as can often be the case for a TIN model. The current implementation would work in the restricted case that all area points are at the same height.

A "good enough" and quick solution is to use a midpoint of the area bounding box top and bottom as the z coordinate for determining the color. A patch that implements this is attached. The centroid could be the optimal choice for z coordinate.

The patch makes use of the bounding box of the area that is already calculated earlier in the function. The original implementation of this z height color functionality has unfortunately reused the same variable name "box" for map bounding box so I renamed that one to "map_box" to make the area bounding box available.

I have only been able to do very limited testing on Linux but this patch seems to fix the issue that I had with my dataset.

Attachments (1)

display.d.vect.area.c.patch (980 bytes ) - added by jarim 15 years ago.
patch

Download all attachments as: .zip

Change History (11)

by jarim, 15 years ago

Attachment: display.d.vect.area.c.patch added

patch

comment:1 by martinl, 9 years ago

Milestone: 7.0.07.0.5

comment:2 by martinl, 8 years ago

Milestone: 7.0.57.3.0

comment:3 by martinl, 8 years ago

Milestone: 7.3.07.4.0

Milestone renamed

comment:4 by neteler, 7 years ago

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:5 by neteler, 7 years ago

Milestone: 7.4.17.4.2

comment:6 by martinl, 6 years ago

In 73180:

d.vect with z height colors uses a random polygon point for height - patch to fix attached (see #934)

comment:7 by martinl, 6 years ago

Milestone: 7.4.27.6.0

comment:8 by martinl, 6 years ago

In 73181:

d.vect: explain z height for 3D lines/polygons, see #934

comment:9 by martinl, 6 years ago

In 73182:

d.vect: explain z height for 3D lines/polygons, see #934

comment:10 by martinl, 6 years ago

Keywords: d.vect added
Resolution: fixed
Status: newclosed

Z height computation for 3D lines/polygons changed accordingly in r73180. Milestone changed to 7.6, the current behaviour in GRASS 7.4 and 7.2 should remain as it is (first vertex based). Explained in r73181 and r73182.

Note: See TracTickets for help on using tickets.