kopia lustrzana https://github.com/osm2vectortiles/osm2vectortiles
Support replacing tile sources
rodzic
ab549f743f
commit
96b1ad2b23
|
@ -1,9 +1,34 @@
|
|||
FROM node:0.12.7
|
||||
FROM node:0.10
|
||||
MAINTAINER Lukas Martinelli <me@lukasmartinelli.ch>
|
||||
|
||||
RUN npm install -g tessera
|
||||
RUN npm install -g mbtiles tilelive-tmstyle tilelive-tmsource
|
||||
# make sure the mapbox fonts are available on the system
|
||||
RUN mkdir -p /tmp/mapbox-studio-default-fonts && \
|
||||
mkdir -p /fonts && \
|
||||
git clone https://github.com/mapbox/mapbox-studio-default-fonts.git /tmp/mapbox-studio-default-fonts && \
|
||||
cp /tmp/mapbox-studio-default-fonts/**/*.otf /fonts && \
|
||||
cp /tmp/mapbox-studio-default-fonts/**/*.ttf /fonts && \
|
||||
rm -rf /tmp/mapbox-studio-default-fonts
|
||||
ENV MAPNIK_FONT_PATH=/fonts
|
||||
|
||||
# only install minimal amount of tessera packages
|
||||
# be careful as some tessera packages collide with itself
|
||||
RUN npm install -g tessera
|
||||
RUN npm install -g mbtiles \
|
||||
tilelive-tmstyle \
|
||||
tilelive-http
|
||||
|
||||
RUN mkdir -p /usr/src/app
|
||||
COPY run.sh /usr/src/app/
|
||||
|
||||
# mountpoint of custom mbtiles files and tm2 projects
|
||||
VOLUME /data
|
||||
WORKDIR /data
|
||||
EXPOSE 8080
|
||||
ENV SOURCE_DATA_DIR=/data
|
||||
|
||||
# destination of modified tm2 projects
|
||||
VOLUME /project
|
||||
ENV DEST_DATA_DIR=/project
|
||||
|
||||
EXPOSE 80
|
||||
ENV PORT=80
|
||||
|
||||
CMD ["/usr/src/app/run.sh"]
|
||||
|
|
|
@ -1,4 +1,36 @@
|
|||
Contains the vectortiles-server and rastertiles-server.
|
||||
# Tileserver
|
||||
|
||||
Render raster data from vector tiles and style projects
|
||||
on the fly with the help of [tessera](https://github.com/mojodna/tessera).
|
||||
|
||||
You plug in your vector tiles and style projects and
|
||||
you have a hosted tileserver.
|
||||
|
||||
## Kitematic Usage
|
||||
|
||||
## Docker Usage
|
||||
|
||||
Mount your `mbtiles` files and `tm2` style projects into the `/data` volume.
|
||||
If your `mbtiles` sources are named the same as your `tm2` project the
|
||||
script will automatically replace the source specified in the `data.yml`
|
||||
of your `tm2` project with the according `mbtiles` source.
|
||||
|
||||
Give the current folder contains the following files and directories.
|
||||
|
||||
```
|
||||
├── countries.tm2
|
||||
└── countries.mbtiles
|
||||
|
||||
```
|
||||
|
||||
You can run a docker container.
|
||||
|
||||
```
|
||||
docker run -p 8080:8080 -v $(pwd):/data osm2vectortiles/tileserver
|
||||
```
|
||||
|
||||
No visit `localhost:8080` to see a leaflet map of the rendered raster tiles.
|
||||
|
||||
|
||||
**Why tessera?**
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
source_data_dir=${SOURCE_DATA_DIR:-/data}
|
||||
dest_data_dir=${DEST_DATA_DIR:-/project}
|
||||
port=${PORT:-8080}
|
||||
cache_size=${CACHE_SIZE:-10}
|
||||
source_cache_size=${SOURCE_CACHE_SIZE:-10}
|
||||
|
||||
# find all tm2 projects but only the first project will be hosted for now
|
||||
for project_dir in "$source_data_dir"/*.tm2; do
|
||||
project_name="${project_dir##*/}"
|
||||
project_config_file="${project_dir%%/}/project.yml"
|
||||
vectortiles_name="${project_name%.tm2}.mbtiles"
|
||||
mbtiles_file="${source_data_dir%%/}/$vectortiles_name"
|
||||
|
||||
# project config will be copied to new folder because we
|
||||
# modify the source configuration of the style and don't want
|
||||
# that to effect the original file
|
||||
dest_project_dir="${dest_data_dir%%/}/$project_name"
|
||||
dest_project_config_file="${dest_project_dir%%/}/project.yml"
|
||||
cp -r "$project_dir" "$dest_project_dir"
|
||||
|
||||
# project.yml is single source of truth, therefore the mapnik
|
||||
# stylesheet is not necessary
|
||||
rm "${dest_project_dir%%/}/project.xml"
|
||||
|
||||
# replace external vector tile sources with mbtiles source
|
||||
# this allows developing rapidyl with an external source and then use the
|
||||
# mbtiles for dependency free deployment
|
||||
if [ -f "$mbtiles_file" ]; then
|
||||
replace_expr="s|source: \".*\"|source: \"mbtiles://$mbtiles_file\"|g"
|
||||
sed -e "$replace_expr" $project_config_file > $dest_project_config_file
|
||||
fi
|
||||
|
||||
exec tessera "tmstyle://$dest_project_dir" \
|
||||
--port $port \
|
||||
--cache-size $cache_size \
|
||||
--source-cache-size $source_cache_size
|
||||
done
|
Ładowanie…
Reference in New Issue