Maperitive/HowTo

From OpenStreetMap Wiki
Jump to navigation Jump to search

How to use Maperitive to work off line and display different options simply for the end user.

The formatting is easier to follow here:

https://docs.google.com/Doc?docid=0ARVnTmG7VmshZGY5cG1tcHdfNGRoazJnZ2M3&hl=en

To make this work simply for the end user, put a pretty picture on the desktop that links to the appropriate .bat file.

Rules govern what is displayed and how it is displayed. However they are fairly complex to enter from the keyboard in Maperitive, a better way is to make a copy of the default rule set and rename it. Then adjust the rules in the renamed copy. Maperitive also allows scripts so we can build a .bat file to start Maperitive up with a script selecting a set of rules.

Maperitive can be run from a .bat file. The simplest method is to put the .bat file in the same directory as Maperitive.exe. The .bat file can be linked to a desktop icon.

The process is:

  1. Download and save the OSM data file
  2. Download and save the custom icons if running offline
  3. Create a ruleset file
  4. Create a script to load the data file and apply the ruleset
  5. Create a batch file to run Maperitive using the script

Note the load-source command is loading from the local hard drive.

Some samples follow.

Sample 1. Displaying French Names

This sample shows all names in French where they are defined. Useful in bilingual Canada, for example.

french.bat contains:

Maperitive.exe myfscript.txt

myfscript.txt contains

clear-map
use-ruleset location=Rules\french.txt as-alias=french
load-source mymaps/ormm.osm

The french rule set contains one additional line to the default.txt text : name:fr under properties (make sure to surround tag names containing special characters like colons with double brackets).

properties
    map-background-color    : #F1EEE8
    map-background-opacity    : 1
    map-sea-color : #B5D0D0
    font-weight : bold
    font-family : Verdana Bold
    text-halo-width : 25%
    text-halo-opacity : 0.75
    text : [[name:fr]]

Sample 2. Displaying Custom Icons

This sample is more interesting as it contains additional icons and points of interest. Here florist, video, and playground have been added.

florist.bat contains

Maperitive.exe myfloristscript.txt

myfloristscript.txt contains

clear-map
use-ruleset location=Rules\florist.txt as-alias=florist
load-source mymaps/ormm.osm

The ruleset florist.txt has the three extra points for florist, video and playground

    points
        place city : place=city
        place town : place=town
        place village : place=village
        place hamlet : place=hamlet
        hospital : amenity=hospital
        diy : shop=doityourself
        hair dresser : shop=hairdresser
        supermarket : shop=supermarket
        convenience : shop=convenience
        bakery : shop=bakery
        restaurant : amenity=restaurant
        cafe : amenity=cafe
        pharmacy : amenity=pharmacy

        florist : shop=florist
        video : shop=video
        playground : leisure=playground

We also need to define the icons. So copy the entry for Pharmacy, note the playground and video icons have been copied to the local hard drive, this would normally be C: not G: Note this use of local icons is a new feature that currently not really supported but it works if the icon is in cache.

    target : pharmacy
        define
            icon-image : http://svn.openstreetmap.org/applications/rendering/mapnik/symbols/pharmacy.p.16.png
            min-zoom : 16
            icon-width : 16
        draw : icon
    target : florist
        define
            icon-image : http://svn.openstreetmap.org/applications/share/map-icons/classic.small/shop/florist.png
            min-zoom : 16
            icon-width : 16
        draw : icon
    target : playground
        define
            icon-image : G:\Program Files (x86)\maperitive\icons\playground.png
            min-zoom : 16
            icon-width : 16
        draw : icon
    target : video
        define
            icon-image : G:\Program Files (x86)\maperitive\icons\video.png
            min-zoom : 16
            icon-width : 16
        draw : icon

Icons can be found here: http://svn.openstreetmap.org/applications/share/map-icons/

To make it usable by non technical people

Senior managers and politicians are an excellent source of non technical people. You just give them a pretty picture to click on and they are happy. So create a .bat file and a script file behind it so that non technical people would have a pretty picture to click on. Now we can demonstrate by clicking here, I can display a map with Drinking Fountains on, click this one and the street names display in French. Click this one and the florists in Orleans, an Ottawa suburb, are displayed. Click that one and you get just the pubs displayed with none of the other distracting icons. Get the picture?