2022-02-04 13:19:33 +00:00
# Keeping the Vector Tiles Updated
2017-01-16 09:09:29 +00:00
Once you have imported OpenMapTiles you can also keep it up to date by importing the latest OSM changes and
regenerating the tables.
## Import
2022-02-04 13:19:33 +00:00
You can either keep the database up to date based on the daily (or minutely) OSM change feed
2017-01-16 09:09:29 +00:00
or import specific change files.
2022-02-04 13:19:33 +00:00
### Choosing the Download Source
2022-07-26 16:59:34 +00:00
While GeoFabrik currently provides extracts of basically all countries, they provide only daily updates.
2022-02-04 13:19:33 +00:00
If you need minutely updates you might want to try openstreetmap.fr, for example like this: `make download-osmfr area=africa/eritrea` , which configures minutely updates.
### Preparations
2022-07-26 16:59:34 +00:00
If you plan to keep data updated automatically, before importing any data, make sure to set
2022-02-04 13:19:33 +00:00
```
DIFF_MODE=true
```
2022-07-26 16:59:34 +00:00
2022-02-04 13:19:33 +00:00
in the `.env`
Now download fresh data:
2022-07-26 16:59:34 +00:00
```
2022-02-04 13:19:33 +00:00
make download area=your-area-of-choice
```
2017-01-16 09:09:29 +00:00
### Keep Database Updated
2022-07-26 16:59:34 +00:00
You can use imposm3 to keep the database updated (thanks to the [work by @stirringhalo ](https://github.com/openmaptiles/openmaptiles/pull/131 )).
This will repeatedly download the OSM change feed and import it into the database.
In order to be able to update the database, the initial download and import of the OSM data must be done when `DIFF_MODE=true` is set in the `.env` file.
In this mode the initial download also sets the update source and the update intervals.
2017-01-16 09:09:29 +00:00
2022-07-26 16:59:34 +00:00
To start the update process please use
2017-01-16 09:09:29 +00:00
```
2022-07-26 16:59:34 +00:00
make start-update-osm
```
To stop the update process please use
2017-01-16 09:09:29 +00:00
```
2022-07-26 16:59:34 +00:00
make stop-update-osm
```
After each update activation, **imposm3** will store lists of updated tiles in text format in subfolders of the `diffdir` ,
named for the date(s) on which the import took place (`YYYYMMDD`).
See [Generate Changed Tiles ](#generate-changed-tiles ) below on how this file can be used.
#### Note
When the update process is actively updating the DB it is impossible to successfully generate tiles,
as there will be conflicts and deadlocks related to the DB access.
Unfortunately, there is no known way to execute an external command in-between rounds of the `update-osm` process.
2017-01-16 09:09:29 +00:00
2022-02-04 13:19:33 +00:00
#### Troubleshooting
2022-07-26 16:59:34 +00:00
The log file for osm update can be viewed using
```
docker-compose logs --tail 100 --follow update-osm
```
Use `Ctrl-C` to stop following the log.
2022-02-04 13:19:33 +00:00
The output will be similar to this:
2022-07-26 16:59:34 +00:00
```
[info] Importing #4889572 including changes till ....... +0000 UTC (2h10m10s behind)
```
2022-02-04 13:19:33 +00:00
2022-07-26 16:59:34 +00:00
It might take some time to catch up with the latest changes, but the "time behind" should decrease until it is a few minutes.
If it doesn't, you need to download a new extract or check that there are enough system resources to keep-up with the changes.
2022-02-04 13:19:33 +00:00
Finally you will get an output like this - this indicates, that some 6 objects were changed:
```
[progress] 3s C: 0/s (0) N: 0/s (0) W: 0/s (6) R: 0/s (0)
```
2022-07-26 16:59:34 +00:00
The process will keep running foreverprint something like this - which just means that no changes were in the latest changeset:
2022-02-04 13:19:33 +00:00
```
[progress] 0s C: 0/s (0) N: 0/s (0) W: 0/s (0) R: 0/s (0)
```
2017-01-16 09:09:29 +00:00
### Import Change File
2022-07-26 16:59:34 +00:00
You may perform a one-time import of OSM changes from the `changes.osc.gz` file in your import folder using
2017-01-16 09:09:29 +00:00
```
Upgrade to tools v5 - rm import-osm, new downloader... (#785)
Update to tools v5. See https://github.com/openmaptiles/openmaptiles-tools/releases/tag/v5.0.0 for the list of all changes. Other OMT-repo specific changes:
* removes `import-osm` docker usage, replacing it with `openmaptiles-tools`
* quickstart builds faster because it uses postgres with preloaded water, natural earth, and lake centerlines tables.
### Makefile targets
* `tools-dev` will open a shell in a docker to experiment and debug (instead of `import-sql-dev` and `import-osm-dev`)
* separated `start-maputnik` from `start-postserve`
* renamed `clean-docker` into `db-destroy` to make it more explicit
* cleaner `db-start`, `db-stop`, `db-destroy` targets
* `db-start-preloaded` is the same as `db-start`, except that it uses `postgis-preloaded` -- an image with preloaded water, natural-earth, and lake centerline data
* `db-start` will not recreate the container if it already exists -- this way if it was started as preloaded, it will not be rebuilt.
* better output messages
### Quickstart
* uses `postgis-preloaded` image by default to make quickstart quicker. To start with a clean db, pass 2 parameters to quickstart, e.g. `./quickstart.sh albania empty`
2020-05-05 15:53:09 +00:00
make import-diff
2017-01-16 09:09:29 +00:00
```
2022-07-26 16:59:34 +00:00
Similar to[Keep Database Updated](#keep_database_updated) above, **imposm3** will store the list of updated tiles in text file in subfolders of the `diffdir` ,
named for the date on which the import took place (`YYYYMMDD`).
2022-02-04 13:19:33 +00:00
2022-07-26 16:59:34 +00:00
See [Generate Changed Tiles ](#generate-changed-tiles ) below.
2017-01-16 09:09:29 +00:00
2022-07-26 16:59:34 +00:00
#### Note
There is no `make` command for downloading OSM changes into `changes.osc.gz` .
You may perform this task using [`osmupdate` ](https://wiki.openstreetmap.org/wiki/Osmupdate ),
[pyosmium-get-changes ](https://docs.osmcode.org/pyosmium/latest/tools_get_changes.html ),
or downloading the changefile directly from the replication server.
2022-02-04 13:19:33 +00:00
2022-07-26 16:59:34 +00:00
## Generate Changed Tiles
2022-02-04 13:19:33 +00:00
2022-07-26 16:59:34 +00:00
To generate all changed tiles, based on the lists of all updated tiles, and update the existing MBtiles file, please use
2017-01-16 09:09:29 +00:00
```
2022-07-26 16:59:34 +00:00
make generate-changed-tiles
2017-01-16 09:09:29 +00:00
```