Note: this file type and rules system are obsolete. Use the newer system (.makemap files) instead. This documentation is provided to help understand old osm_to_ctm1 files.
You can optionally control the way data is converted from OSM to CTM1 format, and which data is used, and which data is omitted, using an XML file containing rules. By convention such a file has the extension osm_to_ctm1_rules. You supply its name on the command line, before the names of any osm files it needs to affect, using /input=<rules file name>.
The rules file consists of a single <OsmRules> element containing as many <Rule> elements as necessary. Rules may be nested. All the rules at the top level are tested, and for any rule that is fulfilled, (i) it is executed, and (ii) all its nested rules are tested.
How a <Rule> element works: tests
A Rule element tests OSM tags. It can test the key, the value, and whether the tag is in a way. It does this using attributes:
<Rule Key="name" StringAttribName="name"/> tests whether the key is 'name', and if so sets the object's string attribute name to 'name'.
<Rule KeyStartsWith="name:" StringAttribName="%Key%"/> tests whether the key starts with 'name:' and if so sets the object's string attribute name to the key value.
<Rule Value="motorway" Layer="major-road" RoadType="Motorway"/> tests whether the value is 'motorway', and if so sets the layer to 'major-road', the road type to 'motorway, and implicitly sets the one-way flag to true.
<Rule InWay="true" Type="polygon"/> tests whether the tag is in a way, and if so sets the object type to polygon.
How a <Rule> element works: actions
The actions of a rule element, like the tests, are attributes of <Rule>. If a rule's tests all succeed, all its actions are performed, and its nested rules are tested. (Only one of the actions marked with * can be used in a single rule. Use multiple rules to perform more than one of these actions.) The available actions are:
Layer: set the object's layer to the supplied layer name.
StringAttribName: set this string attribute to the supplied value
Type: set the object's type; legal values are 'point', 'line'. 'polygon' and 'array' (but 'array' is not yet supported in any useful way).
*OsmType: set the object's OSM type - a three-letter abbreviation usable by the style sheet, e.g., 'woo' for a wood. This is encoded using 5 bits per letter and placed in the top 15 bits of the object's integer attribute.
*IntAttrib: set the object's integer attribute to the supplied value. If the value is '%Value% use the tag's value.
*IntAttribLowWord: set the low word of the object's integer attribute to the supplied value. If the value is '%Value% use the tag's value.
*RoadType: set the object's road type; legal values are Motorway, MotorwayLink, TrunkRoad, TrunkRoadLink, PrimaryRoad, PrimaryRoadLink, SecondaryRoad, TertiaryRoad, UnclassifiedRoad, ServiceRoad, Track, PedestrianRoad. The values Motorway and MotorwayLink implicitly set the one-way flag.
*Level: set the object's level (for tunnels, bridges, overpasses, etc.) to the supplied value. If the value is '%Value% use the tag's value.
*Bridge: set the object's bridge flag to the supplied value. If the value is '%Value% use the tag's value.
*Tunnel: set the object's tunnel flag to the supplied value. If the value is '%Value% use the tag's value.
*OneWay: set the object's one-way value to the supplied value. If the value is '%Value% use the tag's value.
*Roundabout: set the object's roundabout flag to the supplied value (0 or 1). If the value is 1, set the one-way-forward flag true.
The <Filter> element
You can make a set of rules apply only if certain conditions are met, using the Filter element. For example, if you want to extract all boundaries you might have these rules:
<Rule Key='boundary' OsmType='bou'> <Rule Value='administrative' Layer='boundary'/> </Rule> <Rule Key='admin_level' IntAttribLowWord='%Value%'/>
But what if you only need admin-level-4 boundaries, like US state lines? You can enclose the rules in a filter like this:
<Filter exp='admin_level==4'> <Rule Key='boundary' OsmType='bou'> <Rule Value='administrative' Layer='boundary'/> </Rule> <Rule Key='admin_level' IntAttribLowWord='%Value%'/> </Filter>
The exp attribute is an expression where the variables are the keys of the current object, so in this case, only those objects with a key 'admin_level' with a value of 4 are accepted by the filter. The expression syntax is the same as that of style sheet expressions.
The standard rules
The standard rules are stored by makemap. You can write them out, so that you can edit them and create a customised version, by using the following command:
makemap /writerules=2 >standard.osm_to_ctm1_rules