Compare commits
1 Commits
master
...
310_fix_so
Author | SHA1 | Date | |
---|---|---|---|
|
663dbff9e6 |
2
.github/workflows/build-and-test.yaml
vendored
2
.github/workflows/build-and-test.yaml
vendored
@ -5,7 +5,7 @@ on:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,6 +0,0 @@
|
||||
pbf/*.pbf
|
||||
pbf/*.poly
|
||||
tiles/*
|
||||
!tiles/.gitkeep
|
||||
database/*
|
||||
!database/.gitkeep
|
46
Dockerfile
46
Dockerfile
@ -1,17 +1,11 @@
|
||||
FROM ubuntu:22.04 AS compiler-common
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV LANG C.UTF-8
|
||||
ENV LC_ALL C.UTF-8
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates gnupg lsb-release locales \
|
||||
wget curl \
|
||||
git-core unzip unrar \
|
||||
&& locale-gen $LANG && update-locale LANG=$LANG \
|
||||
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
|
||||
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
||||
&& apt-get update && apt-get -y upgrade
|
||||
git-core \
|
||||
ca-certificates \
|
||||
&& apt-get update
|
||||
|
||||
###########################################################################################################
|
||||
|
||||
@ -37,7 +31,7 @@ RUN mkdir -p /home/renderer/src \
|
||||
|
||||
###########################################################################################################
|
||||
|
||||
FROM compiler-common AS final
|
||||
FROM ubuntu:22.04 AS final
|
||||
|
||||
# Based on
|
||||
# https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
|
||||
@ -46,7 +40,6 @@ ENV AUTOVACUUM=on
|
||||
ENV UPDATES=disabled
|
||||
ENV REPLICATION_URL=https://planet.openstreetmap.org/replication/hour/
|
||||
ENV MAX_INTERVAL_SECONDS=3600
|
||||
ENV PG_VERSION 15
|
||||
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
@ -70,9 +63,9 @@ RUN apt-get update \
|
||||
osm2pgsql \
|
||||
osmium-tool \
|
||||
osmosis \
|
||||
postgresql-$PG_VERSION \
|
||||
postgresql-$PG_VERSION-postgis-3 \
|
||||
postgresql-$PG_VERSION-postgis-3-scripts \
|
||||
postgresql-14 \
|
||||
postgresql-14-postgis-3 \
|
||||
postgresql-14-postgis-3-scripts \
|
||||
postgis \
|
||||
python-is-python3 \
|
||||
python3-mapnik \
|
||||
@ -82,7 +75,7 @@ RUN apt-get update \
|
||||
python3-pip \
|
||||
renderd \
|
||||
sudo \
|
||||
vim \
|
||||
wget \
|
||||
&& apt-get clean autoclean \
|
||||
&& apt-get autoremove --yes \
|
||||
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
@ -109,19 +102,10 @@ RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/a
|
||||
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
|
||||
&& a2enconf mod_tile && a2enconf mod_headers
|
||||
COPY apache.conf /etc/apache2/sites-available/000-default.conf
|
||||
COPY leaflet-demo.html /var/www/html/index.html
|
||||
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
|
||||
&& ln -sf /dev/stderr /var/log/apache2/error.log
|
||||
|
||||
# leaflet
|
||||
COPY leaflet-demo.html /var/www/html/index.html
|
||||
RUN cd /var/www/html/ \
|
||||
&& wget https://github.com/Leaflet/Leaflet/releases/download/v1.8.0/leaflet.zip \
|
||||
&& unzip leaflet.zip \
|
||||
&& rm leaflet.zip
|
||||
|
||||
# Icon
|
||||
RUN wget -O /var/www/html/favicon.ico https://www.openstreetmap.org/favicon.ico
|
||||
|
||||
# Copy update scripts
|
||||
COPY openstreetmap-tiles-update-expire.sh /usr/bin/
|
||||
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \
|
||||
@ -131,11 +115,11 @@ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire.sh \
|
||||
&& echo "* * * * * renderer openstreetmap-tiles-update-expire.sh\n" >> /etc/crontab
|
||||
|
||||
# Configure PosgtreSQL
|
||||
COPY postgresql.custom.conf.tmpl /etc/postgresql/$PG_VERSION/main/
|
||||
COPY postgresql.custom.conf.tmpl /etc/postgresql/14/main/
|
||||
RUN chown -R postgres:postgres /var/lib/postgresql \
|
||||
&& chown postgres:postgres /etc/postgresql/$PG_VERSION/main/postgresql.custom.conf.tmpl \
|
||||
&& echo "host all all 0.0.0.0/0 scram-sha-256" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf \
|
||||
&& echo "host all all ::/0 scram-sha-256" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf
|
||||
&& chown postgres:postgres /etc/postgresql/14/main/postgresql.custom.conf.tmpl \
|
||||
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/14/main/pg_hba.conf \
|
||||
&& echo "host all all ::/0 md5" >> /etc/postgresql/14/main/pg_hba.conf
|
||||
|
||||
# Create volume directories
|
||||
RUN mkdir -p /run/renderd/ \
|
||||
@ -145,10 +129,10 @@ RUN mkdir -p /run/renderd/ \
|
||||
&& chown -R renderer: /data/ \
|
||||
&& chown -R renderer: /home/renderer/src/ \
|
||||
&& chown -R renderer: /run/renderd \
|
||||
&& mv /var/lib/postgresql/$PG_VERSION/main/ /data/database/postgres/ \
|
||||
&& mv /var/lib/postgresql/14/main/ /data/database/postgres/ \
|
||||
&& mv /var/cache/renderd/tiles/ /data/tiles/ \
|
||||
&& chown -R renderer: /data/tiles \
|
||||
&& ln -s /data/database/postgres /var/lib/postgresql/$PG_VERSION/main \
|
||||
&& ln -s /data/database/postgres /var/lib/postgresql/14/main \
|
||||
&& ln -s /data/style /home/renderer/src/openstreetmap-carto \
|
||||
&& ln -s /data/tiles /var/cache/renderd/tiles \
|
||||
;
|
||||
|
77
README.md
77
README.md
@ -1,74 +1,5 @@
|
||||
# openstreetmap-tile-server
|
||||
|
||||
|
||||
## Champs-libres fork
|
||||
|
||||
This is an adaptation of https://github.com/Overv/openstreetmap-tile-server/ for testing different cartoCss styles and generating tiles.
|
||||
|
||||
### Use with docker-compose
|
||||
|
||||
#### Fresh install
|
||||
|
||||
```bash
|
||||
#docker volume create osm-data
|
||||
docker-compose build
|
||||
```
|
||||
|
||||
For entering into the container, use the "terminal" argument of the run.sh script:
|
||||
|
||||
```bash
|
||||
docker-compose run --rm map terminal
|
||||
```
|
||||
|
||||
#### Do an import
|
||||
|
||||
Download a pbf and a poly file of your choice on https://download.geofabrik.de and put it in the `pbf` folder. Change the lines of the pbf and poly paths in the volumes in the `docker-compose.yml` file
|
||||
|
||||
Then, you can import the OSM data by doing this command:
|
||||
|
||||
```bash
|
||||
docker-compose run --rm map import
|
||||
```
|
||||
|
||||
This will take a while, about 15 min for Luxembourg for example.
|
||||
|
||||
You should end with :
|
||||
|
||||
```
|
||||
...
|
||||
INFO:root: Importing into database
|
||||
INFO:root: Import complete
|
||||
+ sudo -u renderer touch /data/database/planet-import-complete
|
||||
+ service postgresql stop
|
||||
* Stopping PostgreSQL 15 database server [ OK ]
|
||||
+ exit 0
|
||||
```
|
||||
|
||||
#### Run the server to produce and view tiles
|
||||
|
||||
```bash
|
||||
docker-compose run --rm map run
|
||||
```
|
||||
|
||||
The tiles are available on http://192.168.176.2/ or something like that. Have a look at the docker container to know which is the IP address: there is a message like "Could not reliably determine the server's fully qualified domain name, using 192.168.176.2.". (should be on http://localhost:8080/ though...)
|
||||
|
||||
#### Generate tiles from a list
|
||||
|
||||
There's a script in utils to generate a list of tiles to be used to generate the tiles.
|
||||
|
||||
```bash
|
||||
python3 generate-tiles-list.py > tiles.list
|
||||
```
|
||||
|
||||
Move this `tiles.list` file in the `/tiles/` directory and then run:
|
||||
|
||||
```bash
|
||||
docker-compose run --rm map generate_tiles
|
||||
```
|
||||
|
||||
|
||||
## Original README
|
||||
|
||||
[![Build Status](https://travis-ci.org/Overv/openstreetmap-tile-server.svg?branch=master)](https://travis-ci.org/Overv/openstreetmap-tile-server) [![](https://images.microbadger.com/badges/image/overv/openstreetmap-tile-server.svg)](https://microbadger.com/images/overv/openstreetmap-tile-server "openstreetmap-tile-server")
|
||||
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/overv/openstreetmap-tile-server?label=docker%20image)](https://hub.docker.com/r/overv/openstreetmap-tile-server/tags)
|
||||
|
||||
@ -136,10 +67,10 @@ By default the container will use openstreetmap-carto if it is not specified. Ho
|
||||
docker run \
|
||||
-e DOWNLOAD_PBF=https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf \
|
||||
-e DOWNLOAD_POLY=https://download.geofabrik.de/europe/luxembourg.poly \
|
||||
-e NAME_LUA=sample.lua \
|
||||
-e NAME_STYLE=test.style \
|
||||
-e NAME_MML=project.mml \
|
||||
-e NAME_SQL=test.sql \
|
||||
-e NAME_LUA=sample.lua
|
||||
-e NAME_STYLE=test.style
|
||||
-e NAME_MML=project.mml
|
||||
-e NAME_SQL=test.sql
|
||||
-v /home/user/openstreetmap-carto-modified:/data/style/ \
|
||||
-v osm-data:/data/database/ \
|
||||
overv/openstreetmap-tile-server \
|
||||
|
@ -4,16 +4,11 @@ services:
|
||||
map:
|
||||
image: overv/openstreetmap-tile-server
|
||||
volumes:
|
||||
#- osm-data:/data/database/
|
||||
- ./database:/data/database/
|
||||
- ./tiles:/data/tiles/
|
||||
- ./run.sh:/run.sh # for dev
|
||||
- ./pbf/luxembourg-latest.osm.pbf:/data/region.osm.pbf # change here your pbf
|
||||
- ./pbf/luxembourg.poly:/data/region.poly # and your poly
|
||||
- osm-data:/data/database/
|
||||
ports:
|
||||
- "8080:80"
|
||||
command: "run"
|
||||
|
||||
# volumes:
|
||||
# osm-data:
|
||||
# external: true
|
||||
volumes:
|
||||
osm-data:
|
||||
external: true
|
||||
|
@ -6,8 +6,8 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="leaflet.css"/>
|
||||
<script src="leaflet.js"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />
|
||||
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
|
||||
|
||||
<style>
|
||||
html, body, #map {
|
||||
|
22
run.sh
22
run.sh
@ -3,9 +3,9 @@
|
||||
set -euo pipefail
|
||||
|
||||
function createPostgresConfig() {
|
||||
cp /etc/postgresql/$PG_VERSION/main/postgresql.custom.conf.tmpl /etc/postgresql/$PG_VERSION/main/conf.d/postgresql.custom.conf
|
||||
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/$PG_VERSION/main/conf.d/postgresql.custom.conf
|
||||
cat /etc/postgresql/$PG_VERSION/main/conf.d/postgresql.custom.conf
|
||||
cp /etc/postgresql/14/main/postgresql.custom.conf.tmpl /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
||||
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
||||
cat /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
||||
}
|
||||
|
||||
function setPostgresPassword() {
|
||||
@ -40,17 +40,13 @@ if [ ! -f /data/style/mapnik.xml ]; then
|
||||
carto ${NAME_MML:-project.mml} > mapnik.xml
|
||||
fi
|
||||
|
||||
if [ "$1" == "terminal" ]; then
|
||||
bash
|
||||
fi
|
||||
|
||||
if [ "$1" == "import" ]; then
|
||||
# Ensure that database directory is in right state
|
||||
mkdir -p /data/database/postgres/
|
||||
chown renderer: /data/database/
|
||||
chown -R postgres: /var/lib/postgresql /data/database/postgres/
|
||||
if [ ! -f /data/database/postgres/PG_VERSION ]; then
|
||||
sudo -u postgres /usr/lib/postgresql/$PG_VERSION/bin/pg_ctl -D /data/database/postgres/ initdb -o "--locale C.UTF-8"
|
||||
sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl -D /data/database/postgres/ initdb -o "--locale C.UTF-8"
|
||||
fi
|
||||
|
||||
# Initialize PostgreSQL
|
||||
@ -199,15 +195,5 @@ if [ "$1" == "run" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" == "generate_tiles" ]; then
|
||||
|
||||
service postgresql start
|
||||
service apache2 restart
|
||||
|
||||
sudo -u renderer renderd -c /etc/renderd.conf
|
||||
|
||||
cat /data/tiles/default/tiles.list | render_list --map default
|
||||
fi
|
||||
|
||||
echo "invalid command"
|
||||
exit 1
|
||||
|
@ -1,35 +0,0 @@
|
||||
# usage: python3 generate-tiles-list.py > tiles.list
|
||||
|
||||
import math
|
||||
|
||||
def deg2num(lat_deg, lon_deg, zoom):
|
||||
lat_rad = math.radians(lat_deg)
|
||||
n = 2.0 ** zoom
|
||||
xtile = int((lon_deg + 180.0) / 360.0 * n)
|
||||
ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n)
|
||||
|
||||
return (xtile, ytile)
|
||||
|
||||
# GD lux coordinates
|
||||
max_x = 6.531
|
||||
max_y = 50.184
|
||||
min_x = 5.735
|
||||
min_y = 49.452
|
||||
|
||||
min_z = 9
|
||||
max_z = 17
|
||||
|
||||
for z in range(min_z, max_z+1):
|
||||
x1_tile, y1_tile = deg2num(max_y, max_x, z)
|
||||
x2_tile, y2_tile = deg2num(min_y, min_x, z)
|
||||
min_x_tile = x1_tile if x1_tile < x2_tile else x2_tile
|
||||
max_x_tile = x1_tile if x1_tile > x2_tile else x2_tile
|
||||
min_y_tile = y1_tile if y1_tile < y2_tile else y2_tile
|
||||
max_y_tile = y1_tile if y1_tile > y2_tile else y2_tile
|
||||
for tx in range(min_x_tile, max_x_tile):
|
||||
if tx % 8 != 0:
|
||||
continue
|
||||
for ty in range(min_y_tile, max_y_tile):
|
||||
if ty % 8 != 0:
|
||||
continue
|
||||
print("{} {} {}".format(tx, ty, z))
|
Loading…
Reference in New Issue
Block a user