Contents |
A ruleset is a collection of Maperitive rendering rules stored in a file. You can edit these rules to change how the map is displayed.
Maperitive comes with several built-in rulesets:
The default ruleset draws a map similarily to Mapnik layer on OpenStreetMap web site. When you start Maperitive, this is the ruleset that is used to display the data.
The wireframe ruleset draws all of the map data using a simple wireframe style. All line features are drawn as simple thin lines. All areas are drawn as green polygons. This ruleset is useful when you want to identify map elements which are not yet covered by some other ruleset (the default ruleset, for example, shows only a subset of the OSM features).
The Google Maps ruleset draws a map similarily to Google Maps.
This ruleset draws a hiking map. The map style resembles that of paper hiking maps produced by Alpine Association of Slovenia.
In order to use the wireframe ruleset, you have to tell Maperitive to use it:
use-ruleset alias=googlemaps apply-ruleset
The first command, use-ruleset, instructs Maperitive to activate a ruleset with an alias googlemaps. Activation merely tells Maperitive that all future map sources loaded should use Google Maps rules. In order to apply the Google Maps ruleset to already loaded map sources, you have to execute the apply-ruleset command.
Can you guess how to switch back to default rules? It's simple:
use-ruleset alias=default apply-ruleset
As you can see from the examples above, rulesets can have aliases. The built-in rulesets come with already specified aliases. You can assign your own aliases to your own rulesets. All very nice, but how do I write my own rulesets? you may ask. Well, let's see.
The first step is to create a new text file, let's say Rules/MyOwn.mrules (it doesn't have to be in the Rules directory, but it's a nice place to store the rules).
The second step involves the actual writing of rules in the file. For more information about this, visit Rendering Rules Introduction. We can skip this step by simply copying the contents of some other ruleset file to our own MyOwn.mrules. I'll copy the contents from the wireframe ruleset:
features lines all lines : areas all areas : properties map-background-color : #181818 rules target : all areas define fill-color : green fill-opacity : 0.1 draw : fill target : all lines define line-color : lightgray line-width : 0.5 draw : line
I'll change the line width to something thicker, just to see the difference:
line-width : 5
Now we tell Maperitive to load our ruleset and apply them to our map:
use-ruleset location=Rules/Hiking.mrules apply-ruleset
If everything is OK, you should see a map similar to this: ##image
Congratulations, you have now registered your first own ruleset!
Once registered, your ruleset(s) will be stored in your user settings so you can reuse them the next time you use Maperitive. To get a list of all registered rulesets, type the command
list-rulesets
Maperitive's response should be something like
1: D:\Programs\Maperitive\Rules\Default.mrules (default) 2: D:\Programs\Maperitive\Rules\Wireframe.mrules (wireframe) 3: D:\Programs\Maperitive\Rules\GoogleMaps.mrules (googlemaps) 4: Rules/MyOwn.mrules - ACTIVE Done
You can get some information from this list:
As mentioned before, you can assign aliases to your own rulesets. Let's assign an alias to MyOwn.mrules:
use-ruleset location=Rules/MyOwn.mrules as-alias=myrules
Now our list looks like this:
1: D:\Programs\Maperitive\Rules\Default.mrules (default) 2: D:\Programs\Maperitive\Rules\Wireframe.mrules (wireframe) 3: D:\Programs\Maperitive\Rules\GoogleMaps.mrules (googlemaps) 4: Rules/MyOwn.mrules (myrules) - ACTIVE Done
Notice "(myrules)" text - this is the alias we used.
Why do I need aliases, you may ask? Well, because you can then reference your rulesets regardless of the location of the ruleset file. For example, we can write a script like this one:
load-source mymap.osm use-ruleset alias=myrules apply-ruleset
And it will work even if we later moved the location of myrules ruleset to somewhere else (in future version you will even be able to store rules on the web). As long as your rules are registered using the new location, your scripts should work fine.
You can change the alias of your registered ruleset at any time, example:
use-ruleset index=4 as-alias=newalias
This commands assigns the newalias alias to fourth registered ruleset. You can also reassign the alias from one ruleset to another using the same technique.
remove-ruleset (TODO) command allows you to remove (unregister) a particular ruleset. Don't worry, the rules file will not be deleted. Example:
remove-ruleset alias=sameoldstuff
will remove a ruleset with the alias sameoldstuff.
TO BE CONTINUED