-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
As stated in Deployment: For mapnik-stylesheets and Preselected Rendering to use your database, you need to edit this file to match your configuration. Generate_view_tiles.py does not parse this file, so it ignores comments. Therefore, the correct database configuration needs to be the first occurence of parameters.
To configure the script to match your directory setting, edit 'generate_view_tiles.py' (section PSR constants):
- DIR_NAME: should remain '__file__', used as base for relative paths
- DATABASE_SOURCE: relative path to your datasource-settings.xml.inc
- PREFIX_SOURCE: relative path to your settings.xml.inc
- TILE_DIR: absolute path to the output of rendered tiles (DATE / ZOOM / X / Y.png is added in rendering)
As stated before, this file is a heavily modified version of 'generate_tiles.py' from the mapnik-stylesheets repository. The original file did not take any arguments and rendered according to hard-coded values. Neither did it handle errors nor validate values. So if you discover problems concerning usage of this script create an issue in this repository (preselected-rendering).
Type $ python generate_view_tiles.py --help for an explanation for usage from Command Line.
Note: Communication Protocol will not be explained in help, please see below.
$ python generate_view_tiles.py [PARAMETERS]
Parameters can either be
--date [dd.mm.yyyy] --zoom [int] --left [float] --bottom [float] --right [float] --top [float]
or
--port [int]
If you try to use both types of parameters at once, the script will fail with an error message.\
A single '-' and the respective first letter of a parameter work as well (e.g.
-z [int]).
The parameters can be in any order, but the following restrictions apply:
| Parameter | Restrictions |
|---|---|
| date | needs to be strictly the format above |
| zoom | can range from 0 to 18 |
| left / right | can range from -180.0 to 180.0 |
| bottom / top | can range from -90.0 to 90.0 |
left / bottom / right / top are describing the bounding box to render. For that reason, left cannot be greater than right and bottom cannot be greater than top.
If any restriction is violated, the script will fail with an error message.
If used correctly, the tiles will be rendererd and saved to [TILE_DIR / DATE / ZOOM / X / Y.png].
If you use only --port [PORT] as parameter, the script will listen on the given port for an incoming TCP-connection. The process ends either by received command, KeyBoardInterrupt or by losing the connection.
PORT - This number needs to be at least 5000 and the port needs to be available.
While listening, the script accepts the following protocol:
[CMD]&[PARAM1]=[VALUE1]&[PARAM2]=[VALUE2]&...
E.g. "render&date=02.03.1020&zoom=1&left=4.4232&bottom=4&right=42.2324&top=12.1451"
Reads the immediately following parameters, validates them, then renders tiles and saves them to [TILE_DIR / DATE / ZOOM / X / Y.png].
The Parameters can be in any order. There can be an indefinite number of parameters, but only the last occurence of a certain parameter is used. The possible parameters are the same as in '1) One-time-rendering' with the exact same restrictions. If validation fails, the process ignores the command, sends an error message and continues to listen for further commands.
Ends the process, given parameters will be ignored.
| Problem | Message |
|---|---|
| Unknown CMD | "errorCMD&Message not according to protocol (unknown command) - ignored" |
| Unknown PARAM | "errorPARAM&Message not according to protocol (unknown parameter) - ignored" |
| Wrong VALUE | "errorVALUE&[PARAM] [...] seems to be incorrect ([VALUE_RESTRICTIONS])" |
| Missing PARAM | same as Wrong VALUE for the first PARAM the process cannot find |
| left > right | "errorVALUE&First longitude (left) needs to be smaller than the second longitude (right)" |
| bottom > top | "errorVALUE&First latitude (bottom) needs to be smaller than the second latitude (top)" |
Example for Wrong VALUE error message:
Received String = "render&date=02.03.1020&zoom=13131&left=4.4232&bottom=4&right=42.2324&top=12.1451"
Error Message = "errorVALUE&Zoom level 13131 seems to be incorrect (0 - 18)"
There will be error messages as in '1) One-time-rendering' printed to the CLI as well.
The process sends "done&Rendered successfully." as an answer, if the rendering process ended without errors.