mapcomplete/Docs/SettingUpPSQL.md

45 lines
1.3 KiB
Markdown
Raw Normal View History

# Setting up a synced OSM-server for quick layer access
2024-01-15 15:23:40 +01:00
## Setting up the SQL-server:
2024-01-15 15:23:40 +01:00
`sudo docker run --name some-postgis -e POSTGRES_PASSWORD=password -e POSTGRES_USER=user -d -p 5444:5432 -v /home/pietervdvn/data/pgsql/:/var/lib/postgresql/data postgis/postgis`
Then, connect to this databank with PGAdmin, create a database within it.
Then activate following extensions for this database (right click > Create > Extension):
- Postgis activeren (rechtsklikken > Create > extension)
- HStore activeren
Install osm2pgsql (hint: compile from source is painless)
2024-01-15 15:23:40 +01:00
pg_tileserv kan hier gedownload worden: https://github.com/CrunchyData/pg_tileserv
DATABASE_URL=postgresql://user:none@localhost:5444/osm-poi ./pg_tileserv
## Create export scripts for every layer
Use scripts/osm2pgsl
## Importing data
To seed the database:
````
osm2pgsql -O flex -S drinking_water.lua -s --flat-nodes=import-help-file -d postgresql://user:none@localhost:5444/osm-poi andorra-latest.osm.pbf
````
## Deploying a tile server
````
export DATABASE_URL=postgresql://user:none@localhost:5444/osm-poi
./pg_tileserv
````
Tiles are available at:
````
map.addSource("drinking_water", {
"type": "vector",
"tiles": ["http://127.0.0.2:7800/public.drinking_water/{z}/{x}/{y}.pbf"] // http://127.0.0.2:7800/public.drinking_water.json",
})
````