Maperitive

From OpenStreetMap Wiki
Jump to navigation Jump to search
Maperitive
Mapertive 823 OSX .png
Author: Igor Brejc
License: Proprietary (free of charge)
Platforms: Windows, Linux, and macOS
Version: 2.4.3 (2018-02-27[1])
Language: English
Website: http://maperitive.net
Programming language: C#

Desktop based

German power grid as rendered in Maperitive.

Maperitive is a desktop application which renders maps in real time using OSM and other sources of data.

http://maperitive.net/

It is a successor to Kosmos.

The full documentation (under construction) is at http://maperitive.net/docs/. The instructions here are just to get you going while the full documentation is being written and are the "discoveries" of the early adopters and the Author's helpful emails.

You can download the latest version of Maperitive from http://maperitive.net/download/Maperitive-latest.zip (requires .NET Framework v4.0). Keep in mind that it is still in the beta stage of development and as of now it has just a simple GUI and is controlled via a command console. Please note when using the command line the different use of / under Linux and \ under Windows.


Installation

Windows

Download the latest version of the Maperitive zip file from http://maperitive.net/download/Maperitive-latest.zip and unzip it into a directory of your choosing (it is probably sensible to remove the version number, because updates will go to the same place).

To run it simply double-click on maperitive.exe (you may find it helpful to create a shortcut on the desktop)

Ubuntu 10.04 - 12.10

Download the latest version of the Maperitive zip file from http://maperitive.net/download/Maperitive-latest.zip and unzip it into a directory of your choosing. Maperitive also requires a couple of dependencies. These can be installed by opening a Terminal window and running:

sudo apt-get install libmono-winforms2.0-cil mono-devel

Once these have downloaded and installed, navigate to the directory in which you unzipped Maperitive, mark the Maperitive.sh file as executable and run it. This can be done by right-clicking the file and changing the properties to "Allow executing file as program", alternatively run the following lines in Terminal:

chmod +x ./Maperitive.sh
./Maperitive.sh

Ubuntu 10.04

Since Maperitive uses a proprietary file name extension for its rules files (.mrules), editing them using edit-rules may fail. To fix this, create the appropriate custom MIME type and mailcap entries. The following commands define a new MIME type for mrules files for the current user and set gedit as default application to edit them:

echo "text/vnd-maperitive-rules  mrules" >> ~/.mime.types
echo "text/vnd-maperitive-rules; gedit '%s'; description=\"Maperitive rules file\"; test=test -n \"\$DISPLAY\"" >> ~/.mailcap

Fedora 14

Download the latest version of the Maperitive zip file from http://maperitive.net/download/Maperitive-latest.zip and unzip it into a directory of your choosing (it is probably sensible to remove the version number, because updates will go to the same place).

As root execute

yum install mono-winforms

and then go to the directory where you unzipped Maperitive and make it executable with

chmod +x ./Maperitive.sh

To start Maperitive type

./Maperitive.sh

Fixing the mono System.ConsoleDriver exception in Fedora 29

If Maperitive fails to load the map on startup, edit your Maperitive.sh file like this:

#!/bin/sh
export TERM=xterm
mono --desktop Maperitive.exe "$@"

Mac OS X

Download the latest Mono installation and install it.

X11 has to be installed on the Mac. Download it from XQuartz.

Download http://maperitive.net/download/Maperitive-latest.zip, unpack it and move the whole directory to the programms directory (or to any other place).

To launch Maperitive open a terminal and swicht to the Maperitive directory using

cd /Applications/Maperitive

Launch Maperitive:

mono --arch=32 Maperitive.exe

If you are using a version of Mono older than v5.2 then you can omit the --arch switch[2], as those versions default to 32-bit operation.

The starting of Maperitive may take a while, just wait.

Get some data

You will need a file of OSM data. There are a number of ways to get this:

  • download an area in JOSM and then use File>Save As to save it
  • take your pick of bz2 files at Geofabrik

It is suggested not to use very large areas because Maperitive loads all the data into RAM. Cut the data off with Osmosis or Osmconvert you do not need.

It's a good idea to set up a directory for your working files with (for example) data, rules, scripts and outputs sub-directories.

Later examples assume your data is at c:\users\igor\documents\osm\maperitive\data\test.osm

Basic Instructions

To enter commands, click on the grey bar at the bottom of the screen (or simply press Enter) - the bar will turn yellow. Some commands are also available in the menus. Note that Maperitive only requires enough letters to uniquely identify a command. It fills in what it can as you go along.

By default, OSM 'standard' tiles are shown in the background (if you're connected to the internet). You need to relocate to match your data. For instance, this will take you to central London:

move-pos x=-0.11 y=51.52

You can render data on top of the Mapnik background, or you can use a blank page:

clear-map

Assuming your data is in a separate directory, it helps to make this the default, for example

change-directory c:\users\igor\documents\osm\maperitive\

To load the data you issue the command:

load-source data\test.osm

The map will be loaded and rendered using the default rules (which are in the rules\default.txt file which came with Maperitive). These rules are similar to normal Mapnik rendering. To save this moment for posterity:

export-bitmap zoom=15 file=outputs\test.png width=3000 height=3000 scale=3

Congratulations. You are a renderer.

Changing the Rendering Rules

To change the rendering rules, open the active rules, with a view to saving a copy in your working directory (best to File>Save As straightaway to rules\test.mrules):

edit-rules

When editing, you need to preserve the indentation. You could try changing some colours (most of the common colours can be entered as words). When you've made and saved some changes:

use-ruleset location=rules\test.mrules as-alias=test
apply-ruleset

When you have saved your changes, you run

reload-ruleset

render the map again with the new rules. Maperitive shows the effect of the new rules in just a few seconds. To switch back to the default rules, you use the alias:

use-ruleset alias=default
apply-ruleset

Maperitive remembers the locations of your rules, so you don't need to reload them. If you re-use an alias, it overwrites the old location.

The "wireframe"-Ruleset is a useful ruleset. It renders all lines whatever tags they have. This ruleset is pre-defined and has the alias "wireframe". You can use it with use-ruleset alias=wireframe followed by apply-ruleset

Examples for user modified or created rules can be found here in the Wiki in the Category Maperitive/Rules and some rendered samples can be found here: Maperitive/SampleRenderings.

Scripts

You can save a set of commands in a simple text file (known as a script). For example

move-pos x=-0.11 y=51.52
clear-map
change-directory c:\users\igor\documents\osm\maperitive\
use-ruleset location=rules\test.txt as-alias=test
load-source data\test.osm
export-bitmap zoom=15 file=outputs\test.png width=3000 height=3000 scale=3

You can then run all these commands at once:

run-script c:\users\igor\documents\osm\maperitive\scripts\myscript.txt

To save all that typing, you could put a change-directory command in the scripts\default.txt file that came with Maperitive (but be aware it might get overwritten by an update). Alternatively, create a Windows batch file (a text file with a .bat extension) in your working directory containing: maperitive.exe scripts\myscript.txt and create a shortcut to the batch file on your desktop. Within the shortcut's file properties, you need to set Start In to the location of maperitive.exe. You can also use the maperitive.ico icon (same place as maperitive.exe).

Understanding the Rules File

The high-level structure of the rules file is:

features
        ...
        areas
                ...
        lines
                ...
        points
                ...
properties
        ...
rules
        target : feature1
                ...
        target : feature2
                ...

The features section tells Maperitive what data you want to use. You can define a feature that only looks at areas, lines or points, or you can let it check everything.

The properties section lets you override Maperitive's defaults (eg the font it uses).

The rules section tells Maperitive what to draw for any of the features (sets of data) that match the stated criteria. Normally you would define a few properties, then draw something using those properties. You can change the rendering within each rule based on further tests, which makes it very flexible indeed.

Commands

The full list of commands can be seen by typing help-commands. They scroll past really quickly and the window is very narrow, so here they are listed as at version 809 (28 March 2010).

Command Action
add-web-map background=<draw the map in background (true/false)> intensity=<intensity of the web map (from 0 to 1)> provider=<name of the web map provider (mapnik, osmarender, osm cyclemap> adds a web map provider to the map
apply-ruleset [sourceindex] applies the active ruleset to the map
change-directory <directory> changes the current directory
check-updates checks for new updates in Maperitive software
clear-cache webmap=<clear cached web map tiles> clears the application cache
clear-command-history clears the command history
clear-map clears the map (removes all map sources)
clear-results clears the search results
dump-bounds dumps the map view bounds to the command log
dump-entrails dumps Mapertivie's entrails to the command log (for debugging purposes)
dump-pos dumps the current map position to the command log
exit closes the Maperitive application
export-bitmap aspect=<preserve aspect ratio> scale=<scale> zoom=<zoom level> file=<bitmap file name> width=<bitmap width> height=<bitmap height> exports the current map view to a bitmap file, also creates a worldfile
export-command-history <outputfilename> exports the command history to a text file
export-osm <filename> [sourceindex] exports the current map view to an OSM file (just the OSM data)
find <specificationtext> searches for map data using a query language
find-here <specificationtext> searches for map data using a query language but restricts the search to the visible map window
find-next moves to the next item in search results
find-prev moves to the previous item in search results
generate-contours [elevationinterval] generates relief contours for the current map view
get-info displays detailed information about the currently focused map object
help displays basic help information
help-commands displays a list of all Maperitive commands
help-keyboard displays a list of all Maperitive keyboard shortcuts
help-properties displays a list of all rendering rules properties in Maperitive
list-results dumps search results list in the command log
list-rulesets displays a list of all registered rulesets
list-sources displays a list of all map sources on the map
list-viewpoints
load-source <filename> loads a map source from a file (OSM, GPX or IBF file)
move-pos <x> <y> [zoom] moves the map to a new position
prompt sets the focus on the command prompt
remove-ruleset index=<ruleset index> alias=<ruleset alias> location=<ruleset location> removes (deregisters) a ruleset
remove-source [sourceindex] removes a specific map source from the map
run-script <scriptfilename> runs a Maperitive script from the specified file
save-map-script <scriptfilename> saves the current map as a Maperitive script
save-source <sourceindex> <destfilename> saves a specific map source to the specified file
send-feedback opens your mail client and prepares a mail message to Maperitive's author
use-ruleset index=<ruleset index> as-alias=<new alias> location=<ruleset location> alias=<ruleset alias> activates a specific ruleset
zoom <zoomfactor> sets the zoom level of the map view
zoom-all zooms to the extents of the map
zoom-bounds <minx> <miny> <maxx> <maxy> zooms to the specific map bounds
zoom-in zooms in
zoom-out zooms out
zoom-selection zooms to the currently focused element

Keyboard-Shortcuts

The full list of Keyboard-Shortcuts can be seen by typing help-keyboard. They scroll past really quickly and the window is very narrow, so here they are listed as at version 1154 (April 2nd, 2011)

> help-keyboard
   F3 (global): find-next
   Shift+F3 (global): find-prev
   Ctrl+A (map): zoom-all
   Ctrl+Shift+C (global): generate-contours
   Ctrl+Shift+D (global): download-osm
   Ctrl+E (global): export-bitmap
   Ctrl+H (global): go-home
   Ctrl+M (global): focus-map
   Ctrl+N (global): clear-map
   Ctrl+Q (global): exit
   Ctrl+R (global): reload-ruleset
   + (map): zoom-in
   = (map): zoom-in
   - (map): zoom-out
   Left (map): move-screen-pos x=-0.1
   Right (map): move-screen-pos x=0.1
   Up (map): move-screen-pos y=-0.1
   Down (map): move-screen-pos y=0.1
   Ctrl+Enter (global): prompt

Icons

Mapnik icons are included with Maperitive, but others are available (some of them may be subject to license, so at your own risk!) at:

Maperitive copies icons to the cache\images\ directory, and then simply refers to the filename. So once the rules have been used once, there is no need to be connected to the internet.

Links

How to

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

How to use Maperitive's find command.

Example for rulesets can be found under

Example for scripts can be found under

References