115 lines
3.3 KiB
Markdown
Executable File
115 lines
3.3 KiB
Markdown
Executable File
# Maps
|
||
|
||
MRS comes with a self-hosted tile server to provide offline maps using [TileServer GL](https://github.com/maptiler/tileserver-gl).
|
||
|
||
While everything comes pre-configured this guide will walkthrough the setup + integration.
|
||
|
||
## Table of Contents
|
||
- [MRS](../README.md)
|
||
- [Maps](#maps)
|
||
- [Usage]()
|
||
- [Adding Maps]()
|
||
- [Adding Contours]()
|
||
|
||
## Usage
|
||
|
||
The TileServer can be viewed at http://localhost:5000
|
||
|
||
Other applications can use the tileserver by configure the application to use:
|
||
- **Raster**: http://localhost:8080/data/{id}/{z}/{x}/{y}.png
|
||
- **Vector**: http://localhost:8080/data/{id}/{z}/{x}/{y}.pbf
|
||
|
||
|
||
### Commands
|
||
- **Setup:** `docker run -d --name maps --restart unless-stopped -p 5000:8080 -v /media/maps/tiles:/data -v /media/maps/styles:/styles maptiler/tileserver-gl:v4.11.0`
|
||
- **Restart:** `docker restart maps`
|
||
- **Start:** `docker start maps`
|
||
- **Stop:** `docker stop maps`
|
||
|
||
## Adding Maps / Styles
|
||
|
||
TileServer GL works with both vector & raster map tiles.
|
||
1. [Download](https://www.maptiler.com/on-prem-datasets/planet/) map tiles
|
||
2. Upload tiles file to `/media/maps/tiles`
|
||
3. Upload styles to `/media/maps/styles`
|
||
4. Reboot TileServer GL: `docker restart maps`
|
||
|
||
## Adding Contours
|
||
|
||
All topographic maps I have found cost thousands of dollars. With that in mind, these instructions will compile our own topographic layer we can add to any tileset.
|
||
|
||
### 1. 📁 Download Topographic Data
|
||
|
||
Topography data sets can be downloaded from [OpenTopography](https://portal.opentopography.org/dataCatalog).
|
||
|
||
Follow the instructions to sign up & download **GEBCO Global Bathymetry and Topography**
|
||
|
||
### 2. 📦 Tooling Setup
|
||
|
||
```bash
|
||
sudo apt update
|
||
sudo apt install -y gdal-bin build-essential sqlite3 libsqlite3-dev git wget unzip docker.io zlib1g-dev
|
||
git clone https://github.com/mapbox/tippecanoe.git
|
||
cd tippecanoe
|
||
make -j$(nproc)
|
||
sudo make install
|
||
cd ..
|
||
```
|
||
|
||
### 3. 🌄 Generate Global 50 m Contours
|
||
|
||
> This step is heavy, dont run on Pi — expect 60–90 GB raw GeoJSON before being compressed to ~2-4 GB
|
||
|
||
```bash
|
||
gdal_contour -f GeoJSONSeq
|
||
-a ele \ # elevation attribute
|
||
-i 50 \ # interval (50 m)
|
||
GEBCOIceTopo.vrt global_50.geojsonl
|
||
|
||
tippecanoe -o contours_50m.mbtiles \
|
||
-Z0 -z12 \ # min/max zoom levels
|
||
--drop-densest-as-needed \ # keep tiles small
|
||
--extend-zooms-if-still-dropping \ # avoid data loss
|
||
--layer=contour \ # layer name
|
||
--read-parallel --reorder \ # faster + optimized
|
||
global_50.geojsonl
|
||
```
|
||
|
||
### 4. 🎨 Add contours to style
|
||
|
||
Create / Modify a style.json
|
||
```json
|
||
{
|
||
"version": 8,
|
||
"name": "Terrain",
|
||
"sources": {
|
||
...
|
||
"contours": {
|
||
"type": "vector",
|
||
"url": "mbtiles://contours_50m.mbtiles"
|
||
}
|
||
},
|
||
"layers": [
|
||
...
|
||
{
|
||
"id": "contours-major",
|
||
"type": "line",
|
||
"source": "contours",
|
||
"source-layer": "contour",
|
||
"minzoom": 0,
|
||
"maxzoom": 6,
|
||
"filter": [">=", "ele", 1000],
|
||
"paint": { "line-color": "#888", "line-width": 0.4 }
|
||
},
|
||
{
|
||
"id": "contours-detailed",
|
||
"type": "line",
|
||
"source": "contours",
|
||
"source-layer": "contour",
|
||
"minzoom": 7,
|
||
"paint": { "line-color": "#666", "line-width": 0.3 }
|
||
}
|
||
]
|
||
}
|
||
```
|