Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technologiestiftung/digital-twin-tile-server
https://github.com/technologiestiftung/digital-twin-tile-server
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/technologiestiftung/digital-twin-tile-server
- Owner: technologiestiftung
- License: mit
- Created: 2023-11-13T14:46:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-24T11:28:47.000Z (about 1 year ago)
- Last Synced: 2023-11-24T12:28:51.278Z (about 1 year ago)
- Language: Dockerfile
- Size: 195 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Digital Twin Tile Server
Super basic tile server for .pbf tiles. Using nginx as server.
## Prerequisites
- Docker
- Docker Hub Account
- Mapbox Account and token## Build
```bash
# Enable buildx
docker buildx create --use
# Building for multiple platforms
# Pushes directly to docker hub
docker buildx build --platform linux/amd64,linux/arm64 --push -t technologiestiftung/digital-twin-tile-server .
```## Usage
```bash
docker run --rm -p 8080:80 technologiestiftung/digital-twin-tile-server
```In your html page
```html
Mapbox GL JS
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
mapboxgl.accessToken = "YOUR MAPBOX TOKEN";
const map = new mapboxgl.Map({
container: "map",
style: "mapbox://styles/mapbox/streets-v11",
center: [13.405, 52.52],
zoom: 16,
});map.on("load", function () {
map.addSource("alkis", {
type: "vector",
tiles: [`${"http://localhost:8080"}/tiles/{z}/{x}/{y}.pbf`],
minzoom: 15,
maxzoom: 17,
promoteId: "UUID",
});map.addLayer({
id: "building-floors",
type: "fill",
source: "alkis",
"source-layer": "alkis",
paint: {
"fill-color": "#088",
"fill-opacity": 1,
},
});
});
map.on("sourcedata", function (e) {
console.log("Source data:", e);
if (e.sourceId === "alkis" && map.isSourceLoaded("alkis")) {
var features = map.querySourceFeatures("alkis");
console.log("Is source loaded:", map.isSourceLoaded("alkis"));
console.log("Loaded features:", features);
var features = map.querySourceFeatures("alkis");
console.log("Features:", features);
var tileData = map.getSource("alkis")._tiles;
console.log("Tile data:", tileData);
}
});map.on("error", function (e) {
console.error("Map error", e.error);
});
```
## Development
Download the "ALKIS Berlin Gebäude" from the FIS Broker https://fbinter.stadt-berlin.de/fb/index.jsp
Direkt link https://datenbox.stadt-berlin.de/filr/public-link/file-download/8a8ae3ab7d6bf5e5017e2f19c3fc5dc2/14254/8799702476865788292/SHP_BE_ALKIS.7z and extract it.Copy flowing files from the archive to your `/shp` folder
```plain
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.cpg
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.dbf
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.prj
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.sbn
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.sbx
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.shp
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.shp.xml
2023-10-10_SHP_BE_ALKIS/SHP_BE_ALKIS_processed/Gebaeude_Bauteile_Flaechen.shx
```Build the image
```bash
docker build -t technologiestiftung/digital-twin-tile-server .
```Run the image
```bash
docker run --rm -p 8080:80 technologiestiftung/digital-twin-tile-server
```## Gotchas
- When building the tiles with tippicanoe you need to name the layer using the `--layer` flag. This is the name that has to be used as `source-layer` value when adding the layer with Mapbox.
- Never forget CORS headers## Todo
- [ ] Download/extract/discard shapefiles in Docker build stage
- [ ] Build on CI
- [ ] Research better ways to serve the tiles then nginx
- [ ] tbd