|
1 | | -# Rendering paper maps using tiles |
| 1 | +# Mapnik rendering |
2 | 2 |
|
3 | | -This script renders an area with given boundaries using tiles from either a [mapbox MBTiles file](https://wiki.openstreetmap.org/wiki/MBTiles), a [tile server](https://wiki.openstreetmap.org/wiki/Tile_servers) or locally rendered using [mapnik](http://mapnik.org/). It is designed to work with hikingmap but it can be used standalone as well if desired. |
4 | | - |
5 | | -## Usage |
6 | | - |
7 | | -`render.py [OPTION]... gpxfiles...` |
8 | | - |
9 | | -Options: |
10 | | - |
11 | | -| Parameter | Description |
12 | | -| --------- | ----------- |
13 | | -| `-o` | Minimum longitude of the area boundaries |
14 | | -| `-O` | Maximum longitude of the area boundaries |
15 | | -| `-a` | Minimum latitude of the area boundaries |
16 | | -| `-A` | Maximum latitude of the area boundaries |
17 | | -| `-w` | Page width in cm |
18 | | -| `-h` | Page height in cm |
19 | | -| `-t` | Temp track file to render. This is used to draw the page boundaries of the overview map, hikingmap will save those as a temporary GPX file. |
20 | | -| `-y` | Temp waypoints file to render. This is used to render the distance each kilometer or mile, hikingmap will save those waypoints as a temporary GPX file. |
21 | | -| `-v, --verbose` | Display extra information while processing. |
22 | | -| `-h, --help` | Display help |
23 | | -| `gpxfiles` | The GPX track(s) to render. |
24 | | - |
25 | | -## Prerequisites |
26 | | - |
27 | | -To run this script you should have a working installation of [python 3](https://www.python.org/), [Landez](https://github.com/makinacorpus/landez) and [mapnik](http://mapnik.org/). Make sure you also have [python-mapnik](https://github.com/mapnik/python-mapnik/) installed. |
28 | | - |
29 | | -## Tile sources |
30 | | - |
31 | | -The tiles are cached in a local folder using the tile manager of Landez. Landez will add tiles to the cache when necessary, supporting a number of possible sources. |
32 | | - |
33 | | -### MBTiles |
34 | | - |
35 | | -This is a file format from mapbox, they can be created using tools such as (but not limited to) [mapbox mbutil](https://github.com/mapbox/mbutil) or [Maperitive](http://maperitive.net/). Please note that only raster MBTiles files are supported, vector MBTiles files require rendering before use. |
36 | | - |
37 | | -### Tile server |
38 | | - |
39 | | -This is the easiest to set up, Landez will simply download tiles from a web source. Make sure you don't violate [usage policies](https://operations.osmfoundation.org/policies/tiles/) if you render too many maps at once or set the dpi value too high. |
40 | | - |
41 | | -### Mapnik |
42 | | - |
43 | | -Since mapnik is installed as a prerequisite of this project, it is included as a possible tile source. However the setup is rather difficult. Consult the documentation of [render_mapnik](https://github.com/roelderickx/hikingmap/blob/master/documentation/render_mapnik.html) in the hikingmap package to get an idea. |
44 | | - |
45 | | -### WMS server |
46 | | - |
47 | | -Although Landez supports WMS sources, it is not configurable here. WMS servers are generally replaced by WMTS servers, which use fewer resources on the server side. |
48 | | - |
49 | | -## Configuration |
50 | | - |
51 | | -Apart from these parameters there are some specific parameters for this renderer. They need to be configured in the file render_tiles.config.xml. An example is included in this repository: |
| 3 | +This program renders an area with given boundaries using landez and mapnik. It is designed to work with hikingmap but it can be used standalone as well if desired. |
52 | 4 |
|
| 5 | +## Installation |
| 6 | +Clone this repository and run the following command in the created directory. |
| 7 | +```bash |
| 8 | +python setup.py install |
53 | 9 | ``` |
54 | | -<?xml version="1.0" encoding="utf-8"?> |
55 | | -<render_tiles> |
56 | | - <tilesmanager> |
57 | | - <mbtiles_file>mbsource.mbtiles</mbtiles_file> |
58 | | - <mapnik_stylefile>mapnik_style.xml</mapnik_stylefile> |
59 | | - <wmts_url>https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png</wmts_url> |
60 | | - <wmts_subdomains>abc</wmts_subdomains> |
61 | | - <cache_dir>tilecache</cache_dir> |
62 | | - <tile_size>256</tile_size> |
63 | | - <tile_format>image/png</tile_format> |
64 | | - <tile_scheme>wmts</tile_scheme> |
65 | | - </tilesmanager> |
66 | | - <hikingmapstyle>hikingmap_style.xml</hikingmapstyle> |
67 | | - <outputformat>png</outputformat> |
68 | | - <dpi>300</dpi> |
69 | | - <scalefactor>1.0</scalefactor> |
70 | | - <fontdirs> |
71 | | - <fontdir>/usr/share/fonts/noto</fontdir> |
72 | | - <fontdir>/usr/share/fonts/noto-cjk</fontdir> |
73 | | - <fontdir>/usr/share/fonts/TTF</fontdir> |
74 | | - </fontdirs> |
75 | | -</render_tiles> |
76 | | -``` |
77 | | - |
78 | | -Options: |
79 | | - |
80 | | -| Tag | Description |
81 | | -| --- | ----------- |
82 | | -| mbtiles_file | Optional. An MBTiles file providing raster tiles. |
83 | | -| mapnik_stylefile | Optional. Mapnik stylesheet file. |
84 | | -| wmts_url | Optional. Remote URL to download tiles. |
85 | | -| wmts_subdomains | Optional. URL subdomains. |
86 | | -| cache_dir | Local folder containing cached tiles. |
87 | | -| tile_size | Tile size. |
88 | | -| tile_format | Tile image format. |
89 | | -| tile_scheme | Tile scheme, value can be tms or wmts. |
90 | | -| hikingmapstyle | The filename of the hikingmap stylesheet. This stylesheet contains the styles to draw the GPX track and waypoints. |
91 | | -| outputformat | Output format. See the [mapnik documentation](http://mapnik.org/docs/v2.2.0/api/python/mapnik._mapnik-module.html#render_to_file) for possible values. |
92 | | -| dpi | Amount of detail to render in dots per inch. This value is unrelated to the setting on your printer, a higher value will simply result in smaller icons, thinner roads and unreadable text. |
93 | | -| scalefactor | The scale factor to use when rendering to image formats. |
94 | | -| fontdirs | Optional. Can contain one or more fontdir subtags with additional font directories to be used by mapnik. |
95 | | - |
96 | | -### Tile source precedence |
97 | | - |
98 | | -Please note you should at least add one tile source. Although it is possible to define all tile sources together in <tilesmanager>, Landez will use only one of them. The precedence is: |
99 | | -1. MBTiles. Fill the tag <mbtiles_file> if you want to use this. |
100 | | -2. Mapnik. Fill the tag <mapnik\_stylefile> if you want to use this, but leave <mbtiles\_file> blank or remove this tag. |
101 | | -3. Tile server. Fill the tags <wmts\_url> and <wmts_subdomains> if you want to use this, but leave <mbtiles\_file> and <mapnik\_stylefile> blank or remove them. |
102 | 10 |
|
0 commit comments