Compare commits

..

42 Commits

Author SHA1 Message Date
Alexander Overvoorde
705237446a Fix update script no longer working (fixes #222) 2021-11-08 22:18:47 +01:00
Stjepan Cvitanovic
1e684edb6a Added E flag (#217)
Added -E flag to use the set up environment.
2021-10-11 22:22:17 +02:00
galewis2
4b93ca3e52 Make the image smaller (#214)
* Update Dockerfile

* Add comment

* rm debs after install

* Get ready for buildkit

* Update Dockerfile

* Cleanup indenting

* Update Dockerfile

* Update Dockerfile

* Install certificates required for downloads

Co-authored-by: Alexander Overvoorde <overv161@gmail.com>
2021-10-11 22:15:44 +02:00
Andrey Prih
0a4d079b08 fix naciscdn.org (#212)
* fix naciscdn.org

* fix

Co-authored-by: prih <prih@prihhost.com>
2021-09-07 21:39:35 +02:00
Alexander Overvoorde
60ac7657d1 Don't clutter output of usage instructions 2021-09-03 12:51:45 +02:00
Alexander Overvoorde
ce176ae32e Fix erroneous quotes around WGET_ARGS (fixes #210) 2021-09-03 12:46:37 +02:00
Alexander Overvoorde
7b82bcae9d Use indexes.sql included with openstreetmap-carto instead of own copy (fixes #204) (#205) 2021-07-19 22:05:18 +02:00
Jason Montleon
85eaca5c79 Install python-is-python3 for openstreetmap-tiles-update-expire (#201) 2021-07-03 15:28:40 +02:00
Alexander Overvoorde
9679b29b50 Update NodeJS to 14 LTS (#185) 2021-05-13 14:44:24 +02:00
ruhepuls
8f2c575ad6 Carto 5.3.1 integrated (#183) 2021-05-13 14:41:01 +02:00
Alexander Overvoorde
75e7714f20 Merge pull request #168 from Overv/ubuntu-20.04
Upgrade to Ubuntu 20.04
2021-03-07 16:34:51 +01:00
Alexander Overvoorde
ec500a2cde Upgrade to Ubuntu 20.04 2021-03-07 16:34:21 +01:00
Alexander Overvoorde
affae5a92d Merge pull request #169 from mhajder/feature/update-components
Update PostGIS, OpenStreetMap Carto stylesheet and trim_osc.py helper
2021-03-01 21:47:13 +01:00
Mateusz Hajder
a204fb85fd Update PostGIS, OpenStreetMap Carto stylesheet and trim_osc.py helper 2021-02-21 15:37:07 +01:00
Alexander Overvoorde
7636079b4d Merge pull request #164 from jdmonin/readme-switch-url-moved 2021-02-10 21:09:28 +01:00
Jeremy D Monin
2ae828c52b Dockerfile: Update same switch2osm.org url as readme 2021-02-07 15:56:36 -05:00
Jeremy D Monin
6fb62935f3 README: Update link to switch2osm.org tile server guide 2021-02-06 16:20:46 -05:00
Alexander Overvoorde
953232051f Show progress output for wget by default (fixes #156) 2020-10-27 20:55:02 +01:00
Alexander Overvoorde
bedff2a880 Merge pull request #150 from ph1ll/patch-1
Fix Osmosis configuration change
2020-09-17 21:40:58 +02:00
Ph1ll
e79901b7dd Fix Osmosis configuration change 2020-09-16 10:05:33 +01:00
Alexander Overvoorde
5a059ab0a5 Merge pull request #140 from Floyddotnet/master
small improvement of build time and image size
2020-06-03 18:46:28 +02:00
Peter Becker
bcf2cfcada combine several apt install calls 2020-06-03 09:24:05 +00:00
Peter Becker
0e1db36457 fix shallow fetch for osm2pgsql and mod-tile 2020-06-03 09:24:05 +00:00
Peter Becker
677b52468e execute all make calls in parallel 2020-06-03 09:23:54 +00:00
Alexander Overvoorde
1093734e1b Merge branch 'Mou97-master' 2020-06-01 14:12:30 +02:00
Alexander Overvoorde
9fb0743c51 Fix shallow fetch for openstreetmap-carto 2020-06-01 14:11:52 +02:00
Mou97
19cb75baa4 removed git command thats fetches the whole history after a shallow clone 2020-05-31 01:21:42 +01:00
Mou97
82bc6a35a3 renamed Dockerfile-badInternet to Dockerfile 2020-05-29 18:58:57 +01:00
Mou97
44490df8c5 added a dockerfile version to avoid 'connection closed: RPC failed' error when cloning big repos 2020-05-29 14:23:36 +01:00
Alexander Overvoorde
6dc84f1d26 Merge pull request #135 from Istador/patch-1 2020-05-15 18:50:46 +02:00
Robin C. Ladiges
26a4b9f239 OSM2PGSQL_EXTRA_ARGS inside quotes
This commit fixes issue #133.
2020-05-15 16:24:01 +02:00
Alexander Overvoorde
2754592d1c Rearrange OSM2PGSQL_EXTRA_ARGS to allow overriding of existing parameters (fixes #112) 2020-04-26 19:00:59 +02:00
Alexander Overvoorde
e838310073 Merge pull request #119 from Sohalt/master
Use https everywhere and remove `--allow-unauthenticated`
2020-04-07 21:26:36 +02:00
sohalt
cca2d00a78 Remove --allow-unauthenticated 2020-04-07 04:30:10 +02:00
sohalt
cc5b50b050 http -> https 2020-04-07 04:29:18 +02:00
Alexander Overvoorde
d8f2fc14e4 Merge pull request #116 from atychang/master
Fix font_dir of mapnik
2020-04-02 20:44:53 +02:00
Allen Chang
1b437e143f Fix font_dir of mapnik
OpenType fonts (OTF) are located in `/usr/share/fonts/opentype`,
however, the font_dir of mapnik is `/usr/share/fonts/truetype` and
mapnik is support OTF, it will cause mapnik can't find the OTFs
(OTFs are used by openstreetmap-carto, e.g., Noto CJK JP).
2020-04-02 13:28:24 +08:00
Alexander Overvoorde
acedcce53d Improve consistency of parameter naming and document PBF/POLY download parameters 2020-02-20 20:29:14 +01:00
Alexander Overvoorde
e15dee4665 Merge pull request #105 from skydiablo/master
allow external PBF file with auto-downloader
2020-02-20 20:18:05 +01:00
Volker von Hoesslin
83f26e1abe fix indent 2020-02-20 08:46:46 +01:00
Volker von Hoesslin
6d0e8070f5 fix bash syntax 2020-02-19 12:01:17 +01:00
Volker von Hoesslin
2a69c977c9 allow external PBF file with auto-downloader 2020-02-14 11:59:27 +01:00
5 changed files with 221 additions and 214 deletions

View File

@@ -1,183 +1,214 @@
FROM ubuntu:18.04 FROM ubuntu:20.04 AS compiler-common
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git-core \
checkinstall \
g++ \
make \
tar \
wget \
ca-certificates
###########################################################################################################
FROM compiler-common AS compiler-postgis
RUN apt-get install -y --no-install-recommends \
postgresql-server-dev-12 \
libxml2-dev \
libgeos-dev \
libproj-dev
RUN wget https://download.osgeo.org/postgis/source/postgis-3.1.1.tar.gz -O postgis.tar.gz \
&& mkdir -p postgis_src \
&& tar -xvzf postgis.tar.gz --strip 1 -C postgis_src \
&& rm postgis.tar.gz \
&& cd postgis_src \
&& ./configure --without-protobuf --without-raster \
&& make -j $(nproc) \
&& checkinstall --pkgversion="3.1.1" --install=no --default make install
###########################################################################################################
FROM compiler-common AS compiler-osm2pgsql
RUN apt-get install -y --no-install-recommends \
cmake \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
libexpat1-dev \
zlib1g-dev \
libbz2-dev \
libpq-dev \
libproj-dev \
lua5.3 \
liblua5.3-dev \
pandoc
RUN cd ~ \
&& git clone -b master --single-branch https://github.com/openstreetmap/osm2pgsql.git --depth 1 \
&& cd osm2pgsql \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make -j $(nproc) \
&& checkinstall --pkgversion="1" --install=no --default make install
###########################################################################################################
FROM compiler-common AS compiler-modtile-renderd
RUN apt-get install -y --no-install-recommends \
apache2-dev \
automake \
autoconf \
autotools-dev \
libtool \
libmapnik-dev
RUN cd ~ \
&& git clone -b switch2osm --single-branch https://github.com/SomeoneElseOSM/mod_tile.git --depth 1 \
&& cd mod_tile \
&& ./autogen.sh \
&& ./configure \
&& make -j $(nproc) \
&& checkinstall --pkgversion="1" --install=no --pkgname "renderd" --default make install \
&& checkinstall --pkgversion="1" --install=no --pkgname "mod_tile" --default make install-mod_tile
###########################################################################################################
FROM compiler-common AS compiler-stylesheet
RUN apt-get install -y --no-install-recommends \
npm
RUN cd ~ \
&& git clone --single-branch --branch v5.3.1 https://github.com/gravitystorm/openstreetmap-carto.git --depth 1 \
&& cd openstreetmap-carto \
&& sed -ie 's#https:\/\/naciscdn.org\/naturalearth\/110m\/cultural\/ne_110m_admin_0_boundary_lines_land.zip#https:\/\/naturalearth.s3.amazonaws.com\/110m_cultural\/ne_110m_admin_0_boundary_lines_land.zip#g' external-data.yml \
&& npm install -g carto@0.18.2 \
&& carto project.mml > mapnik.xml
###########################################################################################################
FROM compiler-common AS compiler-helper-script
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone https://github.com/zverik/regional \
&& cd regional \
&& git checkout 889d630a1e1a1bacabdd1dad6e17b49e7d58cd4b \
&& rm -rf .git \
&& chmod u+x /home/renderer/src/regional/trim_osc.py
###########################################################################################################
FROM ubuntu:20.04 AS final-base
# Based on # Based on
# https://switch2osm.org/manually-building-a-tile-server-18-04-lts/ # https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/
ENV DEBIAN_FRONTEND=noninteractive
# Set up environment
ENV TZ=UTC
ENV AUTOVACUUM=on ENV AUTOVACUUM=on
ENV UPDATES=disabled ENV UPDATES=disabled
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install dependencies # Get packages
RUN apt-get update \ RUN apt-get update \
&& apt-get install wget gnupg2 lsb-core -y \ && apt-get install -y --no-install-recommends \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb [ trusted=yes ] http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y apt-transport-https ca-certificates
RUN apt-get install -y curl \
&& wget --quiet -O - https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs
RUN apt-get install -y --no-install-recommends --allow-unauthenticated \
apache2 \ apache2 \
apache2-dev \
autoconf \
build-essential \
bzip2 \
cmake \
cron \ cron \
fonts-noto-cjk \ fonts-noto-cjk \
fonts-noto-hinted \ fonts-noto-hinted \
fonts-noto-unhinted \ fonts-noto-unhinted \
gcc \
gdal-bin \ gdal-bin \
git-core \
libagg-dev \
libboost-filesystem-dev \
libboost-system-dev \
libbz2-dev \
libcairo-dev \
libcairomm-1.0-dev \
libexpat1-dev \
libfreetype6-dev \
libgdal-dev \
libgeos++-dev \
libgeos-dev \
libgeotiff-epsg \
libicu-dev \
liblua5.3-dev \ liblua5.3-dev \
libmapnik-dev \
libpq-dev \
libproj-dev \
libprotobuf-c0-dev \
libtiff5-dev \
libtool \
libxml2-dev \
lua5.3 \ lua5.3 \
make \
mapnik-utils \ mapnik-utils \
node-gyp \
osmium-tool \ osmium-tool \
osmosis \ osmosis \
postgis \
postgresql-12 \ postgresql-12 \
postgresql-contrib-12 \ python-is-python3 \
postgresql-server-dev-12 \
protobuf-c-compiler \
python3-mapnik \ python3-mapnik \
python3-lxml \ python3-lxml \
python3-psycopg2 \ python3-psycopg2 \
python3-shapely \ python3-shapely \
python3-pip \
sudo \ sudo \
tar \
ttf-unifont \ ttf-unifont \
unzip \
wget \ wget \
zlib1g-dev \
&& apt-get clean autoclean \ && apt-get clean autoclean \
&& apt-get autoremove --yes \ && apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ && rm -rf /var/lib/{apt,dpkg,cache,log}/
# Set up PostGIS
RUN wget http://download.osgeo.org/postgis/source/postgis-3.0.0.tar.gz -O postgis.tar.gz \
&& mkdir -p postgis_src \
&& tar -xvzf postgis.tar.gz --strip 1 -C postgis_src \
&& rm postgis.tar.gz \
&& cd postgis_src \
&& ./configure && make && make install \
&& cd .. && rm -rf postgis_src
# Set up renderer user
RUN adduser --disabled-password --gecos "" renderer RUN adduser --disabled-password --gecos "" renderer
# Install latest osm2pgsql # Install python libraries
RUN mkdir -p /home/renderer/src \ RUN pip3 install \
&& cd /home/renderer/src \ requests \
&& git clone https://github.com/openstreetmap/osm2pgsql.git \ pyyaml
&& cd /home/renderer/src/osm2pgsql \
&& rm -rf .git \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make -j $(nproc) \
&& make install \
&& mkdir /nodes \
&& chown renderer:renderer /nodes \
&& rm -rf /home/renderer/src/osm2pgsql
# Install mod_tile and renderd
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git \
&& cd mod_tile \
&& ./autogen.sh \
&& ./configure \
&& make -j $(nproc) \
&& make -j $(nproc) install \
&& make -j $(nproc) install-mod_tile \
&& ldconfig \
&& cd ..
# Configure stylesheet
RUN mkdir -p /home/renderer/src \
&& cd /home/renderer/src \
&& git clone https://github.com/gravitystorm/openstreetmap-carto.git \
&& git -C openstreetmap-carto checkout v4.23.0 \
&& cd openstreetmap-carto \
&& rm -rf .git \
&& npm install -g carto@0.18.2 \
&& carto project.mml > mapnik.xml \
&& scripts/get-shapefiles.py \
&& rm /home/renderer/src/openstreetmap-carto/data/*.zip
# Configure renderd
RUN sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
# Configure Apache # Configure Apache
RUN mkdir /var/lib/mod_tile \ RUN mkdir /var/lib/mod_tile \
&& chown renderer /var/lib/mod_tile \ && chown renderer /var/lib/mod_tile \
&& mkdir /var/run/renderd \ && mkdir /var/run/renderd \
&& chown renderer /var/run/renderd \ && chown renderer /var/run/renderd \
&& echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \ && echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \ && echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
&& a2enconf mod_tile && a2enconf mod_headers && a2enconf mod_tile && a2enconf mod_headers
COPY apache.conf /etc/apache2/sites-available/000-default.conf COPY apache.conf /etc/apache2/sites-available/000-default.conf
COPY leaflet-demo.html /var/www/html/index.html COPY leaflet-demo.html /var/www/html/index.html
RUN ln -sf /dev/stdout /var/log/apache2/access.log \ RUN ln -sf /dev/stdout /var/log/apache2/access.log \
&& ln -sf /dev/stderr /var/log/apache2/error.log && ln -sf /dev/stderr /var/log/apache2/error.log
# Configure PosgtreSQL
COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
RUN chown -R postgres:postgres /var/lib/postgresql \
&& chown postgres:postgres /etc/postgresql/12/main/postgresql.custom.conf.tmpl \
&& echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/12/main/pg_hba.conf \
&& echo "host all all ::/0 md5" >> /etc/postgresql/12/main/pg_hba.conf
# Copy update scripts # Copy update scripts
COPY openstreetmap-tiles-update-expire /usr/bin/ COPY openstreetmap-tiles-update-expire /usr/bin/
RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \ RUN chmod +x /usr/bin/openstreetmap-tiles-update-expire \
&& mkdir /var/log/tiles \ && mkdir /var/log/tiles \
&& chmod a+rw /var/log/tiles \ && chmod a+rw /var/log/tiles \
&& ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \ && ln -s /home/renderer/src/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag \
&& echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab && echo "* * * * * renderer openstreetmap-tiles-update-expire\n" >> /etc/crontab
# Install trim_osc.py helper script RUN mkdir /nodes \
RUN mkdir -p /home/renderer/src \ && chown renderer:renderer /nodes
&& cd /home/renderer/src \
&& git clone https://github.com/zverik/regional \ # Configure PosgtreSQL
&& cd regional \ COPY postgresql.custom.conf.tmpl /etc/postgresql/12/main/
&& git checkout 612fe3e040d8bb70d2ab3b133f3b2cfc6c940520 \ RUN chown -R postgres:postgres /var/lib/postgresql \
&& rm -rf .git \ && chown postgres:postgres /etc/postgresql/12/main/postgresql.custom.conf.tmpl \
&& chmod u+x /home/renderer/src/regional/trim_osc.py && echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/12/main/pg_hba.conf \
&& echo "host all all ::/0 md5" >> /etc/postgresql/12/main/pg_hba.conf
###########################################################################################################
FROM final-base AS final
# Install PostGIS
COPY --from=compiler-postgis postgis_src/postgis-src_3.1.1-1_amd64.deb .
RUN dpkg -i postgis-src_3.1.1-1_amd64.deb \
&& rm postgis-src_3.1.1-1_amd64.deb
# Install osm2pgsql
COPY --from=compiler-osm2pgsql /root/osm2pgsql/build/build_1-1_amd64.deb .
RUN dpkg -i build_1-1_amd64.deb \
&& rm build_1-1_amd64.deb
# Install renderd
COPY --from=compiler-modtile-renderd /root/mod_tile/renderd_1-1_amd64.deb .
RUN dpkg -i renderd_1-1_amd64.deb \
&& rm renderd_1-1_amd64.deb \
&& sed -i 's/renderaccount/renderer/g' /usr/local/etc/renderd.conf \
&& sed -i 's/\/truetype//g' /usr/local/etc/renderd.conf \
&& sed -i 's/hot/tile/g' /usr/local/etc/renderd.conf
# Install mod_tile
COPY --from=compiler-modtile-renderd /root/mod_tile/mod-tile_1-1_amd64.deb .
RUN dpkg -i mod-tile_1-1_amd64.deb \
&& ldconfig \
&& rm mod-tile_1-1_amd64.deb
COPY --from=compiler-modtile-renderd /root/mod_tile/osmosis-db_replag /usr/bin/osmosis-db_replag
# Install stylesheet
COPY --from=compiler-stylesheet /root/openstreetmap-carto /home/renderer/src/openstreetmap-carto
# Install helper script
COPY --from=compiler-helper-script /home/renderer/src/regional /home/renderer/src/regional
# Start running # Start running
COPY run.sh / COPY run.sh /
COPY indexes.sql /
ENTRYPOINT ["/run.sh"] ENTRYPOINT ["/run.sh"]
CMD [] CMD []
EXPOSE 80 5432 EXPOSE 80 5432

View File

@@ -2,7 +2,7 @@
[![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") [![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")
This container allows you to easily set up an OpenStreetMap PNG tile server given a `.osm.pbf` file. It is based on the [latest Ubuntu 18.04 LTS guide](https://switch2osm.org/manually-building-a-tile-server-18-04-lts/) from [switch2osm.org](https://switch2osm.org/) and therefore uses the default OpenStreetMap style. This container allows you to easily set up an OpenStreetMap PNG tile server given a `.osm.pbf` file. It is based on the [latest Ubuntu 18.04 LTS guide](https://switch2osm.org/serving-tiles/manually-building-a-tile-server-18-04-lts/) from [switch2osm.org](https://switch2osm.org/) and therefore uses the default OpenStreetMap style.
## Setting up the server ## Setting up the server
@@ -38,6 +38,19 @@ docker run \
Refer to the section *Automatic updating and tile expiry* to actually enable the updates while running the tile server. Refer to the section *Automatic updating and tile expiry* to actually enable the updates while running the tile server.
### Letting the container download the file
It is also possible to let the container download files for you rather than mounting them in advance by using the `DOWNLOAD_PBF` and `DOWNLOAD_POLY` parameters:
```
docker run \
-e DOWNLOAD_PBF=https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf \
-e DOWNLOAD_POLY=https://download.geofabrik.de/europe/luxembourg.poly \
-v openstreetmap-data:/var/lib/postgresql/12/main \
overv/openstreetmap-tile-server \
import
```
## Running the server ## Running the server
Run the server like this: Run the server like this:
@@ -225,7 +238,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -1,48 +0,0 @@
-- Extracted from https://github.com/gravitystorm/openstreetmap-carto
-- Comes with a CC0 license
-- These are optional but suggested indexes for rendering OpenStreetMap Carto
-- with a full planet database.
-- This file is generated with scripts/indexes.py
CREATE INDEX planet_osm_roads_admin
ON planet_osm_roads USING GIST (way)
WHERE boundary = 'administrative';
CREATE INDEX planet_osm_roads_roads_ref
ON planet_osm_roads USING GIST (way)
WHERE highway IS NOT NULL AND ref IS NOT NULL;
CREATE INDEX planet_osm_roads_admin_low
ON planet_osm_roads USING GIST (way)
WHERE boundary = 'administrative' AND admin_level IN ('0', '1', '2', '3', '4');
CREATE INDEX planet_osm_line_ferry
ON planet_osm_line USING GIST (way)
WHERE route = 'ferry';
CREATE INDEX planet_osm_line_river
ON planet_osm_line USING GIST (way)
WHERE waterway = 'river';
CREATE INDEX planet_osm_line_name
ON planet_osm_line USING GIST (way)
WHERE name IS NOT NULL;
CREATE INDEX planet_osm_polygon_water
ON planet_osm_polygon USING GIST (way)
WHERE waterway IN ('dock', 'riverbank', 'canal')
OR landuse IN ('reservoir', 'basin')
OR "natural" IN ('water', 'glacier');
CREATE INDEX planet_osm_polygon_nobuilding
ON planet_osm_polygon USING GIST (way)
WHERE building IS NULL;
CREATE INDEX planet_osm_polygon_name
ON planet_osm_polygon USING GIST (way)
WHERE name IS NOT NULL;
CREATE INDEX planet_osm_polygon_way_area_z10
ON planet_osm_polygon USING GIST (way)
WHERE way_area > 23300;
CREATE INDEX planet_osm_polygon_military
ON planet_osm_polygon USING GIST (way)
WHERE (landuse = 'military' OR military = 'danger_area') AND building IS NULL;
CREATE INDEX planet_osm_polygon_way_area_z6
ON planet_osm_polygon USING GIST (way)
WHERE way_area > 5980000;
CREATE INDEX planet_osm_point_place
ON planet_osm_point USING GIST (way)
WHERE place IS NOT NULL AND name IS NOT NULL;

View File

@@ -7,9 +7,7 @@ set -e
# and other things directly from this script when run from cron. # and other things directly from this script when run from cron.
# Change the actual location to wherever installed locally. # Change the actual location to wherever installed locally.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export PATH=.:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ACCOUNT=renderer ACCOUNT=renderer
cd /home/$ACCOUNT/src/mod_tile/
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Extra OSM2PGSQL_OPTIONS may need setting if a tag transform script is # Extra OSM2PGSQL_OPTIONS may need setting if a tag transform script is
@@ -22,7 +20,7 @@ OSM2PGSQL_BIN=osm2pgsql
TRIM_BIN=/home/$ACCOUNT/src/regional/trim_osc.py TRIM_BIN=/home/$ACCOUNT/src/regional/trim_osc.py
DBNAME=gis DBNAME=gis
OSM2PGSQL_OPTIONS="-d $DBNAME -G --hstore ${OSM2PGSQL_EXTRA_ARGS} --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style" OSM2PGSQL_OPTIONS="-d $DBNAME -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style ${OSM2PGSQL_EXTRA_ARGS}"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# When using trim_osc.py we can define either a bounding box (such as this # When using trim_osc.py we can define either a bounding box (such as this
@@ -111,7 +109,7 @@ if [ $# -eq 1 ] ; then
m_info "Initialising Osmosis replication system to $1" m_info "Initialising Osmosis replication system to $1"
mkdir $WORKOSM_DIR mkdir $WORKOSM_DIR
$OSMOSIS_BIN --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG" $OSMOSIS_BIN --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG"
wget "http://replicate-sequences.osm.mazdermind.de/?"$1"T00:00:00Z" -O $WORKOSM_DIR/state.txt wget "https://replicate-sequences.osm.mazdermind.de/?"$1"T00:00:00Z" -O $WORKOSM_DIR/state.txt
mv $WORKOSM_DIR/configuration.txt $WORKOSM_DIR/configuration_orig.txt mv $WORKOSM_DIR/configuration.txt $WORKOSM_DIR/configuration_orig.txt
sed "s!baseUrl=http://planet.openstreetmap.org/replication/minute!baseUrl=https://planet.openstreetmap.org/replication/minute!" $WORKOSM_DIR/configuration_orig.txt > $WORKOSM_DIR/configuration.txt sed "s!baseUrl=http://planet.openstreetmap.org/replication/minute!baseUrl=https://planet.openstreetmap.org/replication/minute!" $WORKOSM_DIR/configuration_orig.txt > $WORKOSM_DIR/configuration.txt
else else

27
run.sh
View File

@@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
set -x
function createPostgresConfig() { function createPostgresConfig() {
cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf cp /etc/postgresql/12/main/postgresql.custom.conf.tmpl /etc/postgresql/12/main/conf.d/postgresql.custom.conf
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/12/main/conf.d/postgresql.custom.conf
@@ -23,6 +21,8 @@ if [ "$#" -ne 1 ]; then
exit 1 exit 1
fi fi
set -x
if [ "$1" = "import" ]; then if [ "$1" = "import" ]; then
# Ensure that database directory is in right state # Ensure that database directory is in right state
chown postgres:postgres -R /var/lib/postgresql chown postgres:postgres -R /var/lib/postgresql
@@ -42,10 +42,19 @@ if [ "$1" = "import" ]; then
setPostgresPassword setPostgresPassword
# Download Luxembourg as sample if no data is provided # Download Luxembourg as sample if no data is provided
if [ ! -f /data.osm.pbf ]; then if [ ! -f /data.osm.pbf ] && [ -z "$DOWNLOAD_PBF" ]; then
echo "WARNING: No import file at /data.osm.pbf, so importing Luxembourg as example..." echo "WARNING: No import file at /data.osm.pbf, so importing Luxembourg as example..."
wget -nv http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf -O /data.osm.pbf DOWNLOAD_PBF="https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
wget -nv http://download.geofabrik.de/europe/luxembourg.poly -O /data.poly DOWNLOAD_POLY="https://download.geofabrik.de/europe/luxembourg.poly"
fi
if [ -n "$DOWNLOAD_PBF" ]; then
echo "INFO: Download PBF file: $DOWNLOAD_PBF"
wget $WGET_ARGS "$DOWNLOAD_PBF" -O /data.osm.pbf
if [ -n "$DOWNLOAD_POLY" ]; then
echo "INFO: Download PBF-POLY file: $DOWNLOAD_POLY"
wget $WGET_ARGS "$DOWNLOAD_POLY" -O /data.poly
fi
fi fi
if [ "$UPDATES" = "enabled" ]; then if [ "$UPDATES" = "enabled" ]; then
@@ -64,10 +73,14 @@ if [ "$1" = "import" ]; then
fi fi
# Import data # Import data
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} ${OSM2PGSQL_EXTRA_ARGS} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf ${OSM2PGSQL_EXTRA_ARGS}
# Create indexes # Create indexes
sudo -u postgres psql -d gis -f indexes.sql sudo -u postgres psql -d gis -f /home/renderer/src/openstreetmap-carto/indexes.sql
#Import external data
sudo chown -R renderer: /home/renderer/src
sudo -E -u renderer python3 /home/renderer/src/openstreetmap-carto/scripts/get-external-data.py -c /home/renderer/src/openstreetmap-carto/external-data.yml -D /home/renderer/src/openstreetmap-carto/data
# Register that data has changed for mod_tile caching purposes # Register that data has changed for mod_tile caching purposes
touch /var/lib/mod_tile/planet-import-complete touch /var/lib/mod_tile/planet-import-complete