Visualization of spatial data is an important part of DSpatial. Through the TDSpViewer component it is also the first point of contact for many users.

The visualization of spatial data in DSpatial uses a fast rendering pipeline that exploits the multi-threaded access to data sources provided by the PFA. The pipeline is optimized for rendering the dirty area of the display, rather than the entire display. Furthermore, spatial data inside the display area is cached in memory so that repeated paints do not have to access the data source at all (for instance, when a window moves in front of the viewer). Data source access is required only when the viewer is resized, when the scale of the display changes, or when the legend of the data set changes.



The TDSpViewer component is the visual interface to DSpatial. It may sound surprising, but the DSpViewer "knows" nothing about spatial data. It manages a geographical space (the extent in N-S and E-W directions) and the scale at which data are displayed, but not much else. It supports basic visual functions such as pan and zoom and it can save its current display as a graphic.

The management of spatial data to be displayed is handled by a list of renderers, to which the DSpViewer has access. A renderer has all the information required to paint spatial features to a bitmap: colours, patterns, markers, etc. There are renderers specific to vector and raster data, and they all derive from the abstract TDSpRenderer class. The renderer classes are not interactive, so you can set all rendering parameters in code.

The rendering pipeline consists of two distinct operations. In the first operation the source data is read by the data set and cached by the renderer in memory. This cache is refreshed whenever the viewing geometry changes: when the DSpViewer is resized, when its display scale changes, and when the rendering parameters (colour, etc.) change. This operation activates the handlers for data access, and these are activated simultaneously. The second operation consists of the actual rendering of the renderer cache onto a bitmap the size of DSpViewer. This setup minimizes source data access (which is slow compared to other operations), and it introduces a form of parallelism making the overall process faster than using a more straightforward single-threaded implementation.

Raster data

Raster data is displayed by adding its bands to a TDSpRasterRenderer. There are two forms of the TDSpRasterRenderer class: TDSpRasterRendererSimple, where all bands are displayed using a single transformation of data value to colour, and TDSpRasterRenderer3Channel, where bands are assigned to one of the RGB components that together make up the colour. This latter renderer also has a fourth channel which can be used for pan sharpening of satellite imagery.

For the first pipeline operation, caching the source data, the raster renderer uses a so-called TDSpRenderRasterMap, which is an array of words (TDSpRasterRendererSimple) or bytes (TDSpRasterRenderer3Channel). The array has a dimension that corresponds to the overlap in the area of the viewer and that of the renderer. The source data is stretched or compressed into the bit range according to the settings of the renderer. This approach was chosen to accommodate the different bit depths of raster data transparently.

For the rendering of the data by a TDSpRasterRendererSimple renderer the render map is transformed into a bitmap by an instance of a descendant of the TDSpRRT class (RRT = raster render transform). Every type of legend (gray scale, cold-to-hot, smooth ramp) has a specific type of RRT. The TDSpRasterRenderer3Channel renderer does its rendering in its own DoRender method. The bitmap is owned by the renderer and used by all the bands linked to the renderer. Finally (part of) the renderer bitmap is copied to the dirty area of the viewer canvas.

Vector data

Vector data are not yet supported in DSpatial.


Go to SourceForge
Last modified: 25 February 2004. Page maintained by pvanlaake