Prerequisites:
- Install Docker Engine from here.
Step 1: Get GitHub repository
git clone --depth 1 git@github.com:kaaninan/BAUV-Maps.git
cd BAUV-Maps
Step 2: Copy maps (mbtiles) to src/tileserver/tilesets
folder. See: Included Maps section and src/tileserver/config.json
.
Step 3: Build the docker image with the following command:
docker build -t mapserver .
Note: Add --platform linux/amd64
option if using Apple M1.
See: Releases
This release includes prebuild docker image. It could be used without building the docker image.
Step 1: Import the docker image with the following command:
docker pull kaaninan/bauv-maps
Run the docker image with the following command:
docker run -d -p 8000:8000 -p 8001:8001 --restart always kaaninan/bauv-maps --public_url http://SERVERIPADDRESS:8000
If you want to run the server on localhost ignore the --public_url
option.
To see the map previews, go to http://localhost:8000, change localhost to your server IP address if you are running the server on a remote server.
To see docker logs, run the following command:
docker logs -f containerID
Create Ubuntu 20.04 droplet, connect to the server with SSH and run the following commands:
# Install Docker
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt install -y docker-ce
# Enable Port Forwarding
sudo ufw allow 8000/tcp
sudo ufw allow 8001/tcp
Then, follow the steps in the Build section. If you want to clone the repository, add server ssh key to deploy keys.
Name | Description | Type |
---|---|---|
turkey-osm.mbtiles | OpenStreetMap data for Turkey | Vector |
TR402921.mbtiles | Istanbul Bosphorus | Vector |
G1111_1.mbtiles | Istanbul Bosphorus | Raster |
Port | Description | Tool |
---|---|---|
8000 | Tile server for mbtiles, styles and fonts | tileserver-gl |
8001 | SVG files for Nautical Maps | express |
You can edit the maps and styles in the src/tileserver/tilesets
and src/tileserver/styles
folder.
Note: With current configuration, styles are used on frontend side. If you want to use styles on backend side, you need to edit the src/tileserver/config.json
file. But IP address of the server should be known before building the docker image.
You can add nautical maps in the src/tileserver/tilesets
folder. The maps should be in the .mbtiles
format.
Then, you should edit the src/tileserver/config.json
file. Add the following line to the tilesets
array:
"data": {
"turkey-osm": {
"mbtiles": "turkey-osm.mbtiles"
},
// Add the following lines
"your-map-id": {
"mbtiles": "your-map.mbtiles"
}
// End of the lines
}
After adding the map, you should rebuild the docker image and run it again.
If you want to use a different IP address or domain, you can change the IP address in the following files:
src/tileserver/styles/*.json
src/tileserver/config.json
src/index.js
- Download OpenStreetMaps data from here. For example the Turkey map.
- Use tilemaker for making vector tiles from the map data (osm.pbf). Download tilemaker prebuild binaries from here.
- For include sea tiles, create a directory called coastline in the same place you're running tilemaker from, and then save the files from https://osmdata.openstreetmap.de/download/water-polygons-split-4326.zip in it, such that tilemaker can find a file at coastline/water_polygons.shp
- Directory structure should be as follows:
map
├── coastline
│ └── ...
├── build
│ └── tilemaker
├── resources
| ├── config-example.json |
| ├---------------------n |
| ├── process-example.lua |
│ └── process-openmaptiles.lua
└── turkey-latest.osm.pbf
- Convert the map data to vector tiles with the following command:
chmod +x build/tilemaker
./build/tilemaker --input turkey-latest.osm.pbf --output turkey.mbtiles --process resources/process-openmaptiles.lua --config resources/config-openmaptiles.json
Prerequisites:
- GDAL 3
First, convert to GTiff format so QGIS can read it. Then, convert to MBTiles format so MapLibre GL can read it.
gdal_translate -of GTiff -expand rgba MAP.KAP out.tif
Then, use QGIS Generate XYZ tiles (MBTiles)
tool to convert the KAP format to MBTiles format. Set maximum zoom level to 15 and DPI to 600.
TODO: add screenshot
ogr2ogr is a command line tool to convert simple features data between file formats. It is part of the GDAL project. It is used to convert the S57 format to MBTiles format. Depth data included.
ogr2ogr OUT.mbtiles -f "mbtiles" -oo SPLIT_MULTIPOINT=ON -oo ADD_SOUNDG_DEPTH=ON MAP_NAME.000 -skipfailures -dsco MINZOOM=0 -dsco MAXZOOM=16
For viewing .mbtiles data there are two tools available:
- tileserver-gl
- mbview (alternative)
We will use express for serving svg icons for the map.
tileserver-gl, serves both raster and vector mbtiles and fonts. It supports style files. It can display maps with style files or raw within itself. But it works with a specific node version. (v10.17.0) Use nvm for installing node.
mbview uses the MapBox GL JS library to render the tiles. It uses the MapBox Map as the base layer. For this you need to create an account and get an access token. It can be used to quickly look at the mbtiles file. Also, if there is a style file on the web, it can be used as a source of mbview.