Feature Selectors

Contents

Features can be selected in a number of ways:

Based On The Feature Name

This is used to select a single feature:

target : motorway

This starts a rule definition that will work on a motorway feature (and only that feature).

Based On Wildcards-Matching Feature Names

This is used to select one or more features which share a similar naming. This way you can cover several related features with the same rule. The difference in rendering between these related features can then be expressed using sub-selecting commands like if, elseif, for, elsefor and else.

target : *road

This starts a rule definition that will work on any feature whose name ends with road, like secondary road, residential road etc.

if : *unpaved*

Starts the rule sub-selection on any feature whose name contains the word unpaved, like horribly unpaved road (kidding), unpaved dirt track etc.

By Matching Feature Names Using Regular Expressions

This is similar to using wildcards, but more powerful, since you can use the expressiveness of regular expressions to find anything you like. One common use case is when you want to select only two features out of a number of them:

 if : $regex("(hiking path)|track")

Starts the rule sub-selection on hiking path and track features,

NOTE: It is recommended that you keep the regular expression enclosed within quotes (like in the above sample). Otherwise parsing problems might happen.

Based On Feature Types

Wireframe rules which come built into Maperitive are a good example of where this kind of feature selection can come handy. Wireframe rules draw all line features the same way, for example.

target : $featuretype(line)

This starts a rule definition that will cover all line features.

target : $featuretype(point)

This starts a rule definition that will cover all point features.

target : $featuretype(area)

This starts a rule definition that will cover all area features.

target : $featuretype(any)

This starts a rule definition that will cover all features.

See also: