Skip to content

Commit adf9409

Browse files
author
Olesia Solonko
committed
update Global Tsunami Hazard map service: remove rate fileds, enlarge plots, enlarge info window
1 parent 9d3803b commit adf9409

File tree

3 files changed

+45
-18
lines changed

3 files changed

+45
-18
lines changed

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ TIPPE_IMAGE := emotionalcities/tippecanoe
1616

1717
# Other flags
1818
LOCAL ?= false # Set to 'true' to build and run with the local frontend image
19+
NOCACHE ?= false # Set to 'true' to force rebuild without cache
1920

2021
# Paths
2122
DATA_DIR := $(CURDIR)/data
@@ -63,12 +64,17 @@ docker-up-%: ## Start a specific service
6364
$(COMPOSE) --project-name $(PROJECT_NAME) up -d $*
6465

6566
# Build and run with local or remote frontend image
66-
docker-build-frontend: ## Build local frontend Docker image
67+
docker-build-frontend: ## Build local frontend Docker image (use NOCACHE=true to force rebuild)
6768
@echo "Building local frontend Docker image..."
68-
docker build -t $(FRONTEND_IMAGE_LOCAL) ./$(FRONTEND_DIR)
69+
@if [ "$(NOCACHE)" = "true" ]; then \
70+
echo "Building WITHOUT cache..."; \
71+
docker build --no-cache -t $(FRONTEND_IMAGE_LOCAL) ./$(FRONTEND_DIR); \
72+
else \
73+
docker build -t $(FRONTEND_IMAGE_LOCAL) ./$(FRONTEND_DIR); \
74+
fi
6975

7076
# Unified run target (use LOCAL=true to prefer the locally-built frontend image)
71-
docker-run: ## Run the stack (use LOCAL=true for local frontend build)
77+
docker-run: ## Run the stack (use LOCAL=true for local frontend build, NOCACHE=true to force rebuild)
7278
@if [ "$(LOCAL)" = "true" ]; then \
7379
echo "Building and running with local images..."; \
7480
$(MAKE) docker-build-frontend; \
@@ -115,4 +121,4 @@ hazard-tiles: ## Generate vector tiles for Global Hazard Points via Docker
115121
--force --maximum-zoom=15 \
116122
--extend-zooms-if-still-dropping \
117123
--no-tile-compression \
118-
/data/hazard/global-hazard-points.geojson
124+
/data/hazard/global-hazard-points.geojson

frontend/src/index.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
border-radius: 8px;
6060
box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
6161
font-family: 'Roboto', 'Arial', sans-serif;
62-
max-width: 480px;
63-
max-height: 80vh;
62+
max-width: 800px;
63+
max-height: 85vh;
6464
overflow-y: auto;
6565
background: white;
6666
}
@@ -99,6 +99,8 @@
9999
margin: 12px 0;
100100
border-radius: 4px;
101101
background: #fafafa;
102+
max-width: 100%;
103+
height: auto;
102104
}
103105

104106
.popup-table {
@@ -371,7 +373,7 @@
371373
}
372374

373375
.info-content.expanded {
374-
max-height: 500px;
376+
max-height: 700px;
375377
padding: 16px;
376378
}
377379

@@ -437,7 +439,8 @@
437439
.info-reference-link {
438440
color: #1a73e8;
439441
text-decoration: none;
440-
word-break: break-all;
442+
word-break: break-word;
443+
overflow-wrap: anywhere;
441444
}
442445

443446
.info-reference-link:hover {
@@ -682,13 +685,18 @@
682685
@media (max-width: 768px) {
683686
.maplibregl-popup-content {
684687
max-width: calc(100vw - 32px);
685-
max-height: 70vh;
688+
max-height: 75vh;
686689
}
687690

688691
.hazard-popup {
689692
padding: 12px;
690693
}
691694

695+
.hazard-popup canvas {
696+
width: 100% !important;
697+
height: auto !important;
698+
}
699+
692700
.popup-table {
693701
font-size: 12px;
694702
}
@@ -705,7 +713,9 @@
705713
gap: 8px;
706714
}
707715

708-
.map-info.expanded,
716+
.map-info.expanded {
717+
max-width: 500px;
718+
}
709719
.map-legend {
710720
min-width: auto;
711721
max-width: none;
@@ -813,6 +823,7 @@
813823
</div>
814824

815825
<div class="info-instructions">
826+
<p>The tsunami run-up heights displayed at shoreline locations have been estimated by interpolating from values from the nearest offshore hazard points using an Inverse Distance Weighted (IDW) method</p>
816827
<h4>How to Use:</h4>
817828
<ul>
818829
<li>Find dataset readme file here: <a href="https://zenodo.org/records/16964551" target="_blank"

frontend/src/js/hazard-layer.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
2828
id: "hazard-pt", // Using the ID you mentioned
2929
type: "circle",
3030
source: "global-hazard-source",
31-
"source-layer": "globalhazardpoints", // Make sure this matches the layer name in your vector tiles
31+
"source-layer": "globalhazardpoints", // FIXED: Use the correct layer name from your vector tiles
3232
layout: {
3333
visibility: "visible", // Explicitly set to visible
3434
},
@@ -114,9 +114,9 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
114114
const properties = e.features[0].properties;
115115
const featureId = properties.id || Date.now();
116116

117-
// Build limited properties table (first 7 items)
117+
// Build limited properties table (first 7 items), excluding rate fields
118118
const propertyEntries = Object.entries(properties).filter(
119-
([key]) => key !== "id" && key !== "fid"
119+
([key]) => key !== "id" && key !== "fid" && !key.toLowerCase().includes("rate")
120120
);
121121
const visibleProperties = propertyEntries.slice(0, 7);
122122
const hiddenProperties = propertyEntries.slice(7);
@@ -135,10 +135,11 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
135135
const canvasId = `rate-chart-${featureId}`;
136136
const downloadId = `download-${featureId}`;
137137

138+
// UPDATED: Increased canvas size from 400x160 to 650x350
138139
const html = `
139140
<div class="hazard-popup">
140141
<h3>Global Hazard Point</h3>
141-
<canvas id="${canvasId}" width="400" height="160"></canvas>
142+
<canvas id="${canvasId}" width="650" height="350"></canvas>
142143
<button class="download-btn" id="${downloadId}">Download CSV</button>
143144
<details class="properties-details">
144145
<summary>Properties (${propertyEntries.length} total)</summary>
@@ -154,9 +155,10 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
154155
<div class="popup-hint">💡 Press <kbd>ESC</kbd> to close this popup</div>
155156
</div>`;
156157

158+
// UPDATED: Increased popup maxWidth from 480px to 750px
157159
// Create popup with improved configuration to prevent jumping
158160
currentPopup = new maplibregl.Popup({
159-
maxWidth: "480px",
161+
maxWidth: "750px",
160162
className: "chart-popup",
161163
closeOnClick: false,
162164
closeOnMove: false,
@@ -313,8 +315,16 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
313315
const downloadBtn = document.getElementById(downloadId);
314316
if (downloadBtn) {
315317
downloadBtn.addEventListener("click", () => {
316-
const header = Object.keys(properties).join(",");
317-
const values = Object.values(properties).join(",");
318+
// Filter out rate fields from CSV export
319+
const filteredProperties = Object.entries(properties)
320+
.filter(([key]) => !key.toLowerCase().includes("rate"))
321+
.reduce((obj, [key, value]) => {
322+
obj[key] = value;
323+
return obj;
324+
}, {});
325+
326+
const header = Object.keys(filteredProperties).join(",");
327+
const values = Object.values(filteredProperties).join(",");
318328
const csv = `${header}\n${values}`;
319329
const blob = new Blob([csv], { type: "text/csv" });
320330
const link = document.createElement("a");
@@ -382,4 +392,4 @@ function addGlobalHazardTiles(map, apiBaseUrl = "http://localhost:5000") {
382392
console.error("Failed to add Global Hazard Points layer:", error);
383393
return false;
384394
}
385-
}
395+
}

0 commit comments

Comments
 (0)