gravitystorm / openstreetmap-carto

A general-purpose OpenStreetMap mapnik style, in CartoCSS
Other
1.53k stars 819 forks source link

Can't generate tiles in Kosmtik using docker #4217

Open ajwittman opened 3 years ago

ajwittman commented 3 years ago

Expected behavior

Kosmtik should have ability to generate png tiles.

Actual behavior

Kosmtik does not have menu option to generate png tiles.

Temporary solution

Temporary solution is to install kosmtik-tiles-export and modify docker-startup.sh to automatically start tiles generation when called to do so. This can either be done by with the process outlined below:

1) Create Dockerfile.exportTiles:

FROM ubuntu:bionic

# Style dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
    ca-certificates curl gnupg postgresql-client python3 python3-distutils \
    fonts-hanazono fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted \
    mapnik-utils nodejs npm ttf-unifont unzip && rm -rf /var/lib/apt/lists/*

# Kosmtik with plugins, forcing prefix to /usr because bionic sets
# npm prefix to /usr/local, which breaks the install
RUN npm set prefix /usr && npm install -g kosmtik

WORKDIR /usr/lib/node_modules/kosmtik/
RUN kosmtik plugins --install kosmtik-overpass-layer \
                    --install kosmtik-fetch-remote \
                    --install kosmtik-overlay \
                    --install kosmtik-open-in-josm \
                    --install kosmtik-map-compare \
                    --install kosmtik-osm-data-overlay \
                    --install kosmtik-mapnik-reference \
                    --install kosmtik-geojson-overlay \
                    --install kosmtik-tiles-export \
    && cp /root/.config/kosmtik.yml /tmp/.kosmtik-config.yml

# Closing section
RUN mkdir -p /openstreetmap-carto
WORKDIR /openstreetmap-carto

USER 1000
CMD sh scripts/docker-startup.sh exportTiles

2) Edit scripts/docker-startup.sh and add the following section in the case select statement:

exportTiles)
  # Creating default Kosmtik settings file
  if [ ! -e ".kosmtik-config.yml" ]; then
    cp /tmp/.kosmtik-config.yml .kosmtik-config.yml
  fi
  export KOSMTIK_CONFIGPATH=".kosmtik-config.yml"

  # Starting Kosmtik tiles export
  kosmtik export project.mml --format tiles --tileFormat 'png' --output ~/openstreetmap-carto/outputDirectory --minZoom 1 --maxZoom 10 --workers 4
  ;;

3) Run commands: docker-compose up import docker-compose up exportTiles

jeisenbe commented 3 years ago

Are you suggesting that the Docker setup for this map style should be changed so that this option is included be default?

ajwittman commented 3 years ago

I think it would be nice to have the tile generation ability built in. It would probably make this project the easiest and quickest way by far to generate OSM tiles currently available. Up to you guys though, it’s not my project.