Home Documentation CartoType style sheets Levels

Levels of map objects

Most mapped objects are at ground level, but often it is useful to distinguish between various vertical levels, to allow the map to display objects in layer order. CartoType uses 16 different levels. Ground level is 0, lower levels range from -8 (lowest) to -1, and higher levels range from 1 to 7 (highest).

The <level> element

You can specify levels for objects in two ways. The standard object attributes have four bits for the level: a signed nybble in bits 12...15. You can also force the level of all the objects in any layer, or any <scale> or <condition> section in a layer, in the style sheet, using the <level> element.

You can use <level> inside <layer>, <condition>, <scale>. To set the level for the current normal style, bridge style, ramp style or tunnel style, respectively, use the attributes 'normal, 'bridge', 'ramp' and 'tunnel'; for example:

<level normal='-1' tunnel='-3'/>

It is better not to use <level> if possible, but to set the levels correctly in the attributes of the map objects themselves.

Drawing order

Levels affect the drawing order in quite a complicated way, but the order is designed to create a map that is as natural and easy to understand as possible.

Step 1: draw all objects in layers earlier than the road layer, so that roads, railways, etc., can be drawn over parks, rivers, etc., even if sub-surface.

Step 2: draw all other underground objects (levels less than zero) for the road layer and later layers.

Step 3: draw the surface-level objects for the road layer and later layers.

Step 4: draw all elevated objects (levels greater than zero), for the road layer and later layers.

Within each step, objects are drawn in level order, lowest first. Within each level, objects are drawn in layer order, as the <layer> elements occur in the style sheet. Within each layer, objects are drawn in <condition> order, as the conditions occur in the style sheet.