This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Using one psql database for OSM psql database and tile server database

0

I am currently setting up an osm stack on my macOS computer. I have set up the rails port for the OSM website and a map tiles server from this GitHub page: GitHub page. I followed the instructions for both installations and set up separate psql databases. Is it possible for the rails port OSM psql database to be the same as the tile server database (in a docker container)? There are instructions on the map tiles GitHub page: "to connect to the PostgreSQL database inside the docker container." Could the OSM server directly use the tile server database or vice versa? Thanks!

Edit: I am importing a .pbf file for the OSM psql database, and it seems to be way larger compared to the tile server docker database. How large is a country-sized psql database supposed to be?

asked 18 Apr '22, 03:27

Nightilon's gravatar image

Nightilon
16113
accept rate: 0%

edited 18 Apr '22, 07:05


One Answer:

2

No, this is absolutely not possible. You need to export data from your rails database using e.g. the planet_dump_ng utility (https://github.com/zerebubuth/planet-dump-ng) and then import into a new database with osm2pgsql in order to use it for a tile server. (Both databases could be run on the same PostgreSQL instance / in the same container if you want but the data needs to be there twice.) The reason for this is that osm2pgsql builds geometry objects and indexes on import, which the original rails database has no need for. The tile server database is on a different abstraction level, for example when you have a building with four nodes, it is not interested in the individual nodes anymore, just the building object, whereas the rails database needs to record details about every single node.

answered 18 Apr '22, 11:51

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks, I think I got it working now with your explanation. Is there a process that can automate the transition from the rails psql database to the tile server psql database?

(18 Apr '22, 16:33) Nightilon
1

If you want to make changes to your rails database and have these replicated to the tile server, the process for that would be using osmosis (see https://wiki.openstreetmap.org/wiki/Osmosis/Replication#Server-side_Replication) to create minutely diffs and then processing these with osm2pgsql --append to modify the tile server database. If your database is very small and edits happen infrequently then it is possible that making a full dump every time a change has been made and processing that with osm2pgsql --create is the simpler option though.

(19 Apr '22, 00:21) Frederik Ramm ♦

OSZAR »