4

Is there a way to install OpenMapTiles server without docker? I need to use this on redhat linux and docker needs to be enterprise version in order to use it on redhat. Please let me know.

Thanks

1 Answers1

1

You just need to manually perform all scripts they run inside their separate docker containers. They set up 1 database server by running the commands in https://github.com/openmaptiles/openmaptiles-tools/blob/master/docker/postgis/Dockerfile and https://github.com/openmaptiles/openmaptiles-tools/blob/master/docker/postgis/initdb-postgis.sh

And then continue to download data in a few different docker files by running some commands, this is a pattern that comes back again and again, run the commands in the Dockerfile and the scripts in for all these subfolders in https://github.com/openmaptiles/openmaptiles-tools/tree/master/docker in the order they appear in the documentation at https://github.com/openmaptiles/openmaptiles/blob/master/README.md

If you're on ubuntu this should be pretty straightforward.

I don't have access to a redhat linux instance, but after translating those ubuntu commands I got something that worked on centos7, so should work on your RHEL7:

(This needs some serious cleanup, I do not recommend using this in a nice production system. Someone should package these commands up in rpm's and push them to a repository (I didn't have the time at the moment and I'm not sure if someone would actually want to do this, let me know if you would be interested in having rpm's of these tools))


# install dependencies

# Install PostgreSQL and PostGIS
yum -y install epel-release
rpm -ivh https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
yum install postgis30_11 postgresql11-server postgis30_11-client
yum install postgresql11-devel postgis30_11-docs postgis30_11-utils pgrouting_11

# tools needed later
yum install boost169-devel libffi-devel openssl-devel protobuf-lite-devel sparsehash-devel leveldb-devel golang-bin utf8proc-devel sqlite pandoc lbzip2 vim libpng libtiff libjpeg freetype gdal cairo pycairo sqlite geos boost curl libcurl libicu bzip2-devel libpng-devel libtiff-devel zlib-devel libjpeg-devel libxml2-devel python-setuptools proj-devel proj proj-epsg proj-nad freetype-devel libicu-devel gdal-devel sqlite-devel libcurl-devel cairo-devel pycairo-devel geos-devel protobuf-devel protobuf-c-devel lua-devel cmake proj boost-thread proj-devel autoconf automake libtool pkgconfig ragel gtk-doc glib2 glib2-devel libpng libpng-devel libwebp libtool-ltdl-devel python-devel harfbuzz harfbuzz-devel harfbuzz-icu boost-devel cabextract xorg-x11-font-utils fontconfig perl-DBD-Pg mesa-libGLU-devel graphviz sqlite3 aria2 osmctools python3 wget

# GCC++ 14 standards are required for Mapnik so we shall install the Dev Toolset from the CentOS Software Collections
yum install centos-release-scl
yum install devtoolset-6
scl enable devtoolset-6 bash

export JOBS=$(nproc)


# Initialise PostgreSQL and Basic Setup
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11.service
cd /var/lib/pgsql/11
vim data/postgresql.conf

    # Add the IP addresses on which the server should listen for connections
    listen_addresses = 'localhost,192.168.1.1'

systemctl start postgresql-11.service


vim /etc/profile.d/pgsql.sh
    $ export PATH=$PATH:/usr/pgsql-11/bin:/usr/pgsql-11/lib:/usr/local/lib
source /etc/profile.d/pgsql.sh


git clone https://github.com/loretoparisi/kakasi.git
cd kakasi
./configure && make
make install
vim /etc/ld.so.conf.d/libkakasi.conf
 /usr/lib64
 /usr/local/lib

ldconfig
cd ..

git clone https://github.com/openmaptiles/mapnik-german-l10n.git
cd mapnik-german-l10n
make
make install

su - postgres
psql --dbname="openmaptiles" <<-'EOSQL'
    CREATE DATABASE template_postgis;
    UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
EOSQL


# i don't find this step anywhere, but it is needed
psql
CREATE DATABASE openmaptiles;

for db in template_postgis "openmaptiles"; do
psql --dbname="$db" <<-'EOSQL'
    CREATE EXTENSION postgis;
    CREATE EXTENSION hstore;
    CREATE EXTENSION unaccent;
    CREATE EXTENSION fuzzystrmatch;
    CREATE EXTENSION osml10n;
EOSQL
done


# these 3 commands start a docker container that downlaods data
#make import-water
#make import-natural-earth
#make import-lakelines


cd
mkdir data
cd data
wget --quiet http://osmdata.openstreetmap.de/download/water-polygons-split-3857.zip
unzip -oj water-polygons-split-3857.zip

su - postgres

ogr2ogr -progress  -f Postgresql  -s_srs EPSG:3857   -t_srs EPSG:3857 -lco OVERWRITE=YES -lco GEOMETRY_NAME=geometry -nln "osm_ocean_polygon"  -nlt geometry  --config PG_USE_COPY YES PG:"dbname=openmaptiles" "/root/data/water_polygons.shp"


wget --quiet http://naciscdn.org/naturalearth/packages/natural_earth_vector.sqlite.zip
unzip -oj natural_earth_vector.sqlite.zip -d . '*natural_earth_vector.sqlite'
wget https://raw.githubusercontent.com/openmaptiles/openmaptiles-tools/master/docker/import-natural-earth/clean-natural-earth.sh
hmod +x clean-natural-earth.sh
NATURAL_EARTH_DB=./natural_earth_vector.sqlite ./clean-natural-earth.sh



ogr2ogr  -progress  -f Postgresql  -s_srs EPSG:4326  -t_srs EPSG:3857  -clipsrc -180.1 -85.0511 180.1 85.0511  -lco GEOMETRY_NAME=geometry  -lco OVERWRITE=YES  -lco DIM=2  -nlt GEOMETRY  -overwrite  PG:"dbname=openmaptiles"  "natural_earth_vector.sqlite"


wget https://github.com/lukasmartinelli/osm-lakelines/releases/download/v0.9/lake_centerline.geojson


ogr2ogr -progress -f Postgresql -s_srs EPSG:4326 -t_srs EPSG:3857 -lco OVERWRITE=YES -overwrite -nln "lake_centerline"  PG:"dbname=openmaptiles"  "lake_centerline.geojson"

quit

cd data
#get some pbf
wget https://download.geofabrik.de/europe/belgium-latest.osm.pbf

# make import-osm
export GOPATH=~/.go
mkdir -p $GOPATH/src/github.com/omniscale/imposm3
#export IMPOSM_REPO="https://github.com/openmaptiles/imposm3.git"
export IMPOSM_REPO="https://github.com/omniscale/imposm3.git"
#export  IMPOSM_VERSION="v2017-10-18"
export IMPOSM_VERSION="v0.8.1"

cd  $GOPATH/src/github.com/omniscale/imposm3
go get github.com/tools/godep
go get -u github.com/golang/protobuf/protoc-gen-go
git clone --quiet --depth 1 $IMPOSM_REPO -b $IMPOSM_VERSION $GOPATH/src/github.com/omniscale/imposm3


make build

/usr/local/bin/generate-imposm3 /root/openmaptiles/openmaptiles.yaml > mapping.yaml
export DIFF_DIR=~/data/import
mkdir $DIFF_DIR
export IMPOSM_CACHE_DIR=/tmp/cache
mkdir $IMPOSM_CACHE_DIR
wget https://raw.githubusercontent.com/openmaptiles/openmaptiles-tools/master/docker/import-osm/config.json
./imposm import -connection "postgis://postgres@localhost/openmaptiles" -mapping mapping.yaml -overwritecache -diffdir "$DIFF_DIR" -cachedir "$IMPOSM_CACHE_DIR" -read "$pbf_file" -deployproduction -write $diff_flag  -config "$CONFIG_JSON"


# make import-borders

cd
git clone https://github.com/mapbox/protozero
cd protozero
mkdir build
cd build
cmake ..
make -j ${JOBS}
make install
cd
git clone https://github.com/osmcode/libosmium.git
cd libosmium
mkdir build
cmake ..
make -j ${JOBS}
make install
cd
git clone https://github.com/pnorman/osmborder.git
cd osmborder
mkdir build
cmake ..
make -j ${JOBS}
make install
cd
git clone https://github.com/openmaptiles/openmaptiles-tools.git
cd openmaptiles-tools/bin
export PGHOST=localhost
export PGDATABASE=openmaptiles
export PGUSER=postgres
export PGPASSWORD=
./import-borders ~/data/belgium-latest.osm.pbf

# make import-wikidata
cd
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
tar xf Python-3.8.2
cd Python-3.8.2
./configure --enable-optimizations
make -j ${JOBS} altinstall
cd ~/openmaptiles-tools/bin
python3.8 -m pip install --upgrade pip
python3.8 -m pip install -r ../requirements.txt
export PYTHONPATH=$PYTHONPATH:$PWD/../
# workaround for asyncpg.exceptions.UndefinedTableError: relation "wd_names" does not exist
# see https://github.com/openmaptiles/openmaptiles/pull/785
su - postgres
psql openmaptiles
$ CREATE TABLE IF NOT EXISTS wd_names (id varchar(20) UNIQUE, page varchar(200) UNIQUE, labels hstore);
$ TRUNCATE wd_names;
$ quit
quit
python3.8 import-wikidata --user=postgres ../../openmaptiles/openmaptiles.yaml



#make
# openmaptiles-tools generate-tm2source openmaptiles.yaml
python3.8 generate-tm2source ../../openmaptiles/openmaptiles.yaml --port 5432 > tm2source.yaml
# openmaptiles-tools generate-sql openmaptiles.yaml
python3.8 generate-sql ../../openmaptiles/openmaptiles.yaml > openmaptiles.sql

#make import-sql
# openmaptiles-tools import-sql
export PSQL_OPTIONS=-a
export OMT_UTIL_DIR=../sql/
export VT_UTIL_DIR=../vt_util_sql/
mkdir $VT_UTIL_DIR
wget https://raw.githubusercontent.com/openmaptiles/postgis-vt-util/master/postgis-vt-util.sql
mv postgis-vt-util.sql ../vt_util_sql/
export SQL_DIR=$PWD

./import-sql

# make generate-tiles
- generate-vectortiles


yum install nodejs xdg-utils
cd
git clone git://github.com/mapnik/mapnik
cd mapnik
git checkout remotes/origin/v3.0.x
./bootstrap.sh
./configure BOOST_INCLUDES=/usr/include/boost169/ BOOST_LIBS=/usr/lib64/boost169/
git submodule sync
git submodule update --init
make -j ${JOBS}
make install
ldconfig

npm install --build-from-source=mapnik -g @mapbox/tiletype mapnik@3.7.2 @mapbox/mbtiles @mapbox/tilelive tilelive-tmsource @mapbox/tilelive-vector tilelive-bridge tilelive-mapnik

cp tm2source.yaml data.yml
sed -i "s|host: .*|host: \"localhost\"|g" data.yml
sed -i "s|port: .*|port: \"5432\"|g" data.yml
sed -i "s|dbname: .*|dbname: \"openmaptiles\"|g" data.yml
sed -i "s|user: .*|user: \"postgres\"|g" data.yml
sed -i "s|password: .*|password: \"$POSTGRES_HOST\"|g" data.yml

export BBOX="-180,-85.0511,180,85.0511"
export MIN_ZOOM=0
export MAX_ZOOM=14

tilelive-copy --scheme=pyramid --bounds=BBOX --timeout="18000000"  --concurrency="10"--minzoom=MIN_ZOOM --maxzoom=MAX_ZOOM "tmsource://$PWD" "mbtiles://root/data/tiles.mbtiles"

generate-metadata ~/data/tiles.mbtiles


Jens Timmerman
  • 9,316
  • 1
  • 42
  • 48
  • Not OP, and this wasn't a perfect fit for my use case, but it was close. You just saved me a huge amount of time. I wish I had more upvotes! – Nick Badger May 28 '20 at 02:31
  • 1
    That being said: is there a reason you used ``GEOMETRY_NAME=geometry-overwrite`` instead of ``GEOMETRY_NAME=geometry`` in the ogr2ogr step for the water polygons? It caused my sql import to fail for the water layer (note: if you need to fix this after the fact, some alter table rename column / alter index rename is a lot, lot faster than rebuilding the whole thing; you can't just rerun the ogr2ogr command because it won't recreate the table) – Nick Badger May 28 '20 at 03:20
  • Hi Nick, I didn't make those choices, they're like that in the OpenMapTiles docker configs – Jens Timmerman May 29 '20 at 20:10
  • @NickBadger I remove the `-overwrite` part here, since indeed, I had the same issue when trying to replicate this ;) – Jens Timmerman Jul 27 '20 at 16:23