Skip to content

Commit 1b41351

Browse files
committed
fix layer mismatch
1 parent c5f7a9d commit 1b41351

3 files changed

Lines changed: 45 additions & 18 deletions

File tree

Makefile

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
COMPOSE ?= docker compose
44
FRONTEND_DIR := frontend
55
PYTHON ?= python3
6+
# ----- Container images -----
67
FRONTEND_IMAGE_LOCAL := local/global-tsunami-risk-map-frontend:latest
78
FRONTEND_IMAGE_REMOTE := ghcr.io/yejiyang/global-tsunami-risk-map-frontend:latest
9+
10+
# Utility containers for data processing (avoid local installs)
11+
GDAL_IMAGE := osgeo/gdal:alpine-small-latest
12+
TIPPE_IMAGE := emotionalcities/tippecanoe
13+
14+
# Other flags
815
LOCAL ?= false # Set to 'true' to build and run with the local frontend image
916

17+
# Paths
18+
DATA_DIR := $(CURDIR)/data
19+
1020
.PHONY: help docker-build docker-up docker-down docker-logs docker-clean \
1121
docker-up-% docker-rebuild-% frontend-build frontend-serve \
12-
docker-build-frontend docker-run-local docker-run
22+
docker-build-frontend docker-run-local docker-run \
23+
hazard-fgb hazard-tiles
1324

1425
.DEFAULT_GOAL := help
1526

@@ -78,3 +89,25 @@ frontend-build: ## Build frontend assets
7889
frontend-serve: ## Build and serve frontend locally
7990
@echo "Serving frontend locally on http://localhost:8080"
8091
cd $(FRONTEND_DIR)/src && $(PYTHON) -m http.server 8080
92+
93+
# -----------------------------------------------------------------------------
94+
# Data processing helpers (Hazard dataset)
95+
# -----------------------------------------------------------------------------
96+
97+
# Convert GeoJSON → FlatGeobuf using GDAL inside a lightweight container
98+
hazard-fgb: ## Generate FlatGeobuf for Global Hazard Points via Docker
99+
@echo "[hazard-fgb] Converting GeoJSON to FlatGeobuf (containerised GDAL)…"
100+
docker run --rm -v $(DATA_DIR):/data $(GDAL_IMAGE) \
101+
ogr2ogr -f FlatGeobuf /data/hazard/global-hazard-points.fgb \
102+
/data/hazard/global-hazard-points.geojson -nln GlobalHazardPoints
103+
104+
# Create vector tiles (MVT) with tippecanoe inside a container
105+
hazard-tiles: ## Generate vector tiles for Global Hazard Points via Docker
106+
@echo "[hazard-tiles] Building vector tiles with tippecanoe (containerised)…"
107+
docker run --rm -v $(DATA_DIR):/data $(TIPPE_IMAGE) \
108+
tippecanoe -r1 -pk -pf \
109+
--output-to-directory=/data/tiles/global-hazard-2/ \
110+
--force --maximum-zoom=15 \
111+
--extend-zooms-if-still-dropping \
112+
--no-tile-compression \
113+
/data/hazard/global-hazard-points.geojson

data/hazard/README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,23 @@ should ideally be kept out of version control.
88

99
## Generate the FlatGeobuf
1010

11-
Convert the GeoJSON to FlatGeobuf for efficient serving:
11+
You no longer need a local GDAL installation. Run the helper target which
12+
launches a lightweight GDAL container under the hood:
1213

1314
```bash
14-
ogr2ogr -f FlatGeobuf \
15-
data/hazard/global-hazard-points.fgb \
16-
data/hazard/global-hazard-points.geojson -nln GlobalHazardPoints
15+
make hazard-fgb # invokes docker-run gdal → FlatGeobuf
1716
```
1817

1918
## Generate Vector Tiles
2019

21-
Create Mapbox Vector Tiles with [tippecanoe](https://github.com/mapbox/tippecanoe):
20+
Vector tile generation is performed with a Dockerised build of
21+
[tippecanoe](https://github.com/mapbox/tippecanoe); simply run:
2222

2323
```bash
24-
tippecanoe \
25-
-r1 -pk -pf \
26-
--output-to-directory=data/tiles/global-hazard/ \
27-
--force \
28-
--maximum-zoom=15 \
29-
--extend-zooms-if-still-dropping \
30-
--no-tile-compression \
31-
data/hazard/global-hazard-points.geojson
24+
make hazard-tiles # containerised tippecanoe builds MVT tiles
3225
```
3326

34-
This produces a directory `data/tiles/hazard_points/` containing zoom levels `0`
35-
through `15` and a `metadata.json` file. Once generated, the tiles are served by
36-
pygeoapi using the `MVT-tippecanoe` provider defined in `pygeoapi/pygeoapi-config.yml`.
27+
This produces the directory `data/tiles/global-hazard/` containing zoom levels
28+
`0``15` plus a `metadata.json` file. Once generated, the tiles are served by
29+
pygeoapi using the `MVT-tippecanoe` provider defined in
30+
`pygeoapi/pygeoapi-config.yml`.

frontend/src/js/hazard-layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
2323
id: "hazard-pt", // Using the ID you mentioned
2424
type: "circle",
2525
source: "global-hazard-source",
26-
"source-layer": "hazard_points_with_id", // Make sure this matches the layer name in your vector tiles
26+
"source-layer": "globalhazardpoints", // Make sure this matches the layer name in your vector tiles
2727
layout: {
2828
visibility: "visible", // Explicitly set to visible
2929
},

0 commit comments

Comments
 (0)