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).

Levels of map objects

How levels are stored in map objects

The level is stored as a signed nybble in bits 12..15 (mask = 0x0000F000) of the integer attributes of an object, but only if the road flag mask for that layer selects those bits. The road flags are set in the <layer> element, either by road='true', which sets them to 0xFFFFFFFF (all ones) or by the roadflags attribute: for example, roadflags='#1F001' in the amenity <layer> states that we wish to use the 'bridge' (0x10000), 'level' (0xF000) and 'tunnel' flags (0x1).

If the level flags are not selected by the road flag mask, the level is set to zero or ground level.

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 %lt;layer%gt; elements occur in the style sheet. Within each layer, objects are drawn in %lt;condition%gt; order, as the conditions occur in the style sheet.

Style Sheets Directory