The terrain header tag provides location of the elevation map's edges, as well as dimensions of the matrix's rows and columns. After the opening elevation_surface tag, each row of values is listed between the <row> . . . </row> tags.
Terrain Elevation Record:
<elevation_surface name="MapName" north="z1" east="x1" south="z2" west="x2" ncols="nc" nrows="nr" > <row> y11 y12 y13 ... y1nc </row> <row> y21 y22 y23 ... y2nc </row> . . . <row> ynr1 ynr2 ynr3 ... ynrnc </row> </elevation_surface>The values within a row, represent the elevations from the Western-edge, to the Eastern-edge, left-to-right respectively. The rows are listed from the Northern-edge, down to the Southern-edge of the terrain map, from top-to bottom, just like on a map, respectively. Many different terrain segments may be contained in data files. Each can be referenced by its own name - usually the name of the region it corresponds to.
Example Terrain Elevation Record:
<elevation_surface name="Utopia" north="50000" east="50000" south="-50000" west="-50000" ncols="512" nrows="512" > <row> 6.4 6.4 6.4 6.4 6.6 6.8 7.0 7.0 7.2 7.2 7.6 7.8 7.8 8.0 8.0 8.2 8.4 ... 9.4 9.6 </row> <row> 3.7 3.7 3.7 3.7 3.7 3.9 3.9 4.1 4.1 4.3 4.3 4.5 4.7 4.9 5.3 5.5 5.9 ... 7.2 7.4 </row> . . . <row> 23.8 23.8 24.0 24.2 24.2 24.4 24.4 24.6 24.6 24.8 25.0 25.2 25.4 ... 6.2 6.2 </row> </elevation_surface>For storage and read-in efficiency, the elevation table may be compressed in the SCZ format See: sourceforge.net/projects/scz-compress . Compression is preferred for efficiency reasons. SCZ, or simple compression, is a very-lightweight free open-source, non-proprietary and non-encumbered compression method with portable (all-platform, cross-platform) format. If compressed, the terrain file-name shall have a .xml.scz suffix.
Storing terrain data in Winframe's XML format has several advantages. It specifies the dimensions and coordinates of the map-edges in an unambiguously self-contained way, to avoid errors, so that it an be registered with other map data, and objects may be accurately positioned within the surface. It enables arbitrary precision and range, and can be conveniently read by all applications, unlike image formats.
To assist in providing conversions to- and from- the XML format, several convenience tools are provided here, that can be compiled and used on all platforms by anyone.
A convenient intermediate image format for elevation data is PPM. It offers a standard raw binary gray-scale image format than can be viewed by many image display tools, such as XV, or GIMP. It can be optionally compressed in the SCZ format or image-SCZ formats. Note that most image formats store 8-bit values, meaning that elevation must be quantized and/or restricted to range of 256. If scaled and quantized, then the scale factor must also be stored and communicated with the file. PPM enables arbitrary comments to be placed in the header, which could permit this. However, the fact that there is no convention for using the header in this way, is one reason the XML format provides advantages for longterm trouble-free usage.
Optionally, terrain data can be provided in compressed form using any of the standard image compression formats, such as JPEG, GIF, or PNG, and converted to- or from- binary (raw) PPM. However, note that lossy formats, such as JPEG may contribute arbitrary artifacts.
Return to WFL Format Document