# generate-jobs

The **generate-jobs** component is responsible creating JSON jobs consumed by the **export** component. It supports two types of jobs:

- **Pyramid:** Job of rendering a tile pyramid (e.g. from z8 all down to z14). Used for initial rendering of the world.
- **List:** Batch jobs of list of tiles to be rendered grouped by data locality. Used for rendering dirty tiles.

**generate-jobs** will output the jobs as individual JSON objects to stdout.
Use a tool like [pipecat](https://github.com/lukasmartinelli/pipecat) to schedule
them on your job server.

## Usage

### Generate pyramid jobs

1. [Search for to tile you want to render](http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/) and choose a low zoom level tile. If you want to render the entire world use the z0 tile.
2. Decide for a job zoom level. This is the zoom level at which **generate-jobs** will create pyramid jobs (e.g. for a z7 tile with job zoom level z8 four pyramid jobs for z8 will be generated)
3. Run `docker-compose run generate-jobs generate_jobs.py pyramid <x> <y> <z> --job-zoom=<job-zoom>` generate the jobs. To store the jobs permanently pipe them into a file.

![Choose tile from Tiles à la Google Maps](screenshot_choose_tile.png)

### Generate list jobs

1. Given you have a large file with tiles (best generated by the **changed-tiles** component) called `tiles.txt` in the `./export` folder.
2. Run `./docker-compose run generate-jobs python generate_jobs.py list /data/export/tiles.txt --batch-size=3000`

### Schedule Jobs on Message Server

1. Install [pipecat](https://github.com/lukasmartinelli/pipecat)
2. Set the AMQP connection options. If you are running the RabbitMQ server locally using `docker-compose` you can use `export AMQP_URI=amqp://osm:osm@localhost:5672/`
3. Publish the jobs to the job queue with `cat <job-file> | pipecat publish jobs`.
