Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data/processed/manhattan_buildings.json filter=lfs diff=lfs merge=lfs -text
data/processed/manhattan_network.json filter=lfs diff=lfs merge=lfs -text
data/raw/manhattan_osm_buildings.json filter=lfs diff=lfs merge=lfs -text
29 changes: 19 additions & 10 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SimulationResult -> ranked hotspots / downloadable JSON / restrained local web U
- `fire_spread.buildings`: converts preserved direct OSM XML map tiles into projected building footprints and height-confidence records.
- `fire_spread.propagation`: configurable edge traversal and event-driven spread.
- `fire_spread.cli`: a small command-line entry point for repeatable runs.
- `fire_spread.web`: local HTTP API and small static UI for scenario controls, network view, 2.5D building rendering, and hotspot output.
- `fire_spread.web`: local HTTP API and small static UI for scenario controls, interactive 3D network/building rendering, and hotspot output.
- `tests`: contract tests for graph validation, directional links, modifiers, horizon handling, deterministic results, OSM conversion, and building provenance.
- `data/raw`: preserved source city files and provenance records.
- `data/processed`: normalized network artifacts and derived simulation outputs.
Expand Down Expand Up @@ -60,9 +60,18 @@ SimulationResult -> ranked hotspots / downloadable JSON / restrained local web U
}
```

Coordinates are projected/local meters in normalized data. The Polatlı adapter uses a local equirectangular projection centered on the Nominatim town-relation result, with the source WGS84 coordinates retained in node metadata.
Coordinates are projected/local meters in normalized data. The Manhattan and Polatlı adapters use a local equirectangular projection centered on each study area, with the source WGS84 coordinates retained in node metadata.

## Real starting dataset: Polatlı, Ankara
## Current starting dataset: Manhattan Island, New York

- Source: OpenStreetMap road and building geometry retrieved from the public Overpass API.
- Coverage: `40.7000,-74.0200` to `40.8825,-73.9065`, covering Manhattan Island and its immediate shoreline.
- Normalized graph: 147,121 nodes and 161,601 links from 30,935 highway ways.
- Building layer: 157,202 OSM building/building-part footprints; 116,917 have explicit height tags, 2,171 have level estimates, and 38,114 are footprint-only.
- Files: `data/raw/manhattan_osm_roads.json`, `data/raw/manhattan_osm_buildings.json`, `data/raw/manhattan_metadata.json`, `data/raw/manhattan_buildings_metadata.json`, `data/processed/manhattan_network.json`, and `data/processed/manhattan_buildings.json`.
- License: OpenStreetMap data © OpenStreetMap contributors, ODbL 1.0. Query, coverage, origin, and height policy are preserved in the metadata files and normalized outputs.

## Legacy regression dataset: Polatlı, Ankara

- Source: OpenStreetMap road geometry retrieved from the public Overpass API.
- Coverage: `39.54,32.08` to `39.63,32.22`, covering the Polatlı urban area and immediate outskirts rather than the full administrative district.
Expand All @@ -75,17 +84,17 @@ Coordinates are projected/local meters in normalized data. The Polatlı adapter

## Current boundary decision

The street graph remains the only spatial input to fire propagation. The OSM building layer is currently presentation-only: it drives the 2.5D viewer but does not alter spread speed, connectivity, or hotspot scores.
The street graph remains the connectivity input to fire propagation. The web UI now offers an experimental QUIC-URB-inspired urban-wind layer: OSM building footprints are rasterized into a regular obstacle grid, and sampled local wind speed/direction alter edge spread speed. This is a transparent diagnostic heuristic, not a fluid solver. The web result also derives an adjacency layer that marks buildings near an activated road segment or ignition node as burning for 3D visualization.

The viewer exposes orthographic and perspective projections plus a clearly labeled vertical exaggeration control. Unknown building heights remain flat in source-only mode; the optional 3 m massing fallback is a visualization assumption, not a measured height.
The viewer exposes orthographic and perspective 3D cameras plus a clearly labeled vertical exaggeration control. Unknown building heights remain flat in source-only mode; the optional 3 m massing fallback is a visualization assumption, not a measured height. OSM `height`, `building:levels`, `min_height`, and roof metadata are preserved for rendering; sparse OSM node `ele` values are also carried when present.

## Simulation phases

1. **Baseline graph:** load and validate a normalized network; reject missing endpoints, duplicate IDs, non-positive lengths, and invalid parameter ranges.
2. **Deterministic propagation:** simulate one or more ignition nodes over a finite time horizon; preserve earliest arrival per node and link interval.
3. **Hotspot ranking:** rank links by normalized advancement score and nodes by arrival/exposure metrics.
4. **City ingestion:** retrieve and preserve the Polatlı OSM extract, reproject to local meters, split ways at geometry vertices, preserve one-way/surface/width tags, and validate topology.
5. **Current web UI:** run real scenarios against the Polatlı graph, show the full network and activated links, and allow JSON result download.
4. **City ingestion:** retrieve and preserve a city OSM extract, reproject to local meters, split ways at geometry vertices, preserve one-way/surface/width tags, and validate topology.
5. **Current web UI:** run real scenarios against the Manhattan graph, show the detailed 3D building layer, activated links, and local flow-vector fields, and allow JSON result download.
6. **Calibration:** compare modeled travel times and spread patterns against historical incidents or expert-labelled scenarios; keep calibrated coefficients versioned.
7. **Scenario analysis:** support multiple ignitions, barriers/closures, time-varying wind, fuel/moisture rasters, and repeated stochastic runs only when validated data exists. Building footprints and 3D tags may become simulation inputs only after their effect is specified and validated.
8. **Presentation:** export GeoJSON and extend the current map view with a timestamp slider and richer city layers after the baseline is validated.
Expand All @@ -100,9 +109,9 @@ The viewer exposes orthographic and perspective projections plus a clearly label

## Definition of done for the current baseline

- The preserved Polatlı OSM road and building extracts load from disk through source-specific adapters.
- A normalized Polatlı graph and building layer are available with provenance, local-meter coordinates, and height-source labels.
- The preserved Manhattan OSM road and building extracts load from disk through source-specific adapters.
- A normalized Manhattan graph and detailed building layer are available with provenance, local-meter coordinates, and height-source labels.
- A CLI and local web UI run real propagation scenarios against the road graph.
- The UI offers orthographic and perspective 2.5D views without feeding unvalidated building heights into propagation.
- The UI offers orthographic and perspective 3D views without feeding unvalidated building heights into propagation.
- Outputs include arrival times, activated links, ranked advancement scores, and dataset/scenario provenance.
- Tests cover the observable baseline contracts, OSM conversion, and building conversion boundaries.
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ A small, reproducible baseline for simulating an advancing fire front over urban

## Status

The repository contains a runnable baseline against a preserved real OpenStreetMap extract for Polatlı, Ankara:
The repository contains a runnable baseline against a preserved real OpenStreetMap extract for Manhattan Island, New York. The earlier Polatlı extract remains available as a smaller regression dataset:

- validated normalized city-network model;
- 1,837 downloaded OSM highway ways with geometry;
- 12,266 normalized nodes and 13,920 street/alley links;
- 12,151 OSM building/building-part footprints for the 2.5D viewer;
- 30,935 downloaded OSM highway ways with geometry;
- 147,121 normalized nodes and 161,601 street/alley links;
- 157,202 OSM building/building-part footprints with height provenance for the 3D viewer;
- configurable heuristic spread modifiers;
- deterministic event-driven propagation;
- JSON input/output CLI;
- local web UI with orthographic/perspective 2.5D views, hotspot ranking, and result download;
- local web UI with interactive WebGL 3D views, hotspot ranking, and result download;
- contract tests and a small hand-authored network used only for unit tests.

The architecture and staged roadmap are in [`PLAN.md`](PLAN.md). The current model is for exploration and ranking only; it is not a validated fire-behavior or life-safety system.

The current milestone is simulation-first: the real street/alley graph drives propagation. OSM building footprints and height tags are currently presentation-only and do not alter spread calculations.
The current milestone is simulation-first: the real street/alley graph drives propagation. The web UI now includes an explicitly labeled, experimental QUIC-URB-inspired urban-wind layer that rasterizes OSM footprints and heights, then changes local wind speed and direction along graph links. It is a diagnostic approximation, not the QUIC-URB solver.

## Run the sample

Expand All @@ -39,29 +39,37 @@ python -m fire_spread --network examples/sample_city.json --ignition A --horizon

Write a result file with `--output path/to/result.json`.

## Run the real Polatlı dataset
## Run the Manhattan dataset

```text
python -m fire_spread --network data/processed/manhattan_network.json --ignition osm:40.7911145:-73.9631218 --horizon-minutes 60 --output data/processed/manhattan_result.json
```

The default web dataset is Manhattan Island. Its study area is `40.7000,-74.0200` to `40.8825,-73.9065`; the normalized origin is the center of that bbox. The current extract contains 147,121 nodes, 161,601 links, and 157,202 building/building-part footprints.

## Run the legacy Polatlı dataset

```text
python -m fire_spread --network data/processed/polatli_network.json --ignition osm:39.5852148:32.1436842 --horizon-minutes 60 --output data/processed/polatli_result.json
```

The default ignition node used by the web UI is the normalized node nearest the Polatlı town-center origin. The exact graph node ID is reported by the UI and `/api/status`.
The legacy dataset's default ignition node is the normalized node nearest the Polatlı town-center origin. The exact graph node ID is reported by the UI and `/api/status`.

The raw Overpass road response is preserved at `data/raw/polatli_osm_roads.json`. The building layer is preserved as direct OSM API XML tiles under `data/raw/polatli_osm_map_tiles/`. Queries, bounding boxes, source, license, coordinate origin, and height policy are recorded in `data/raw/polatli_metadata.json` and `data/raw/polatli_buildings_metadata.json`.

## Run the local web UI

```text
python -m fire_spread.web --dataset data/processed/polatli_network.json --buildings data/processed/polatli_buildings.json --host 127.0.0.1 --port 8000
python -m fire_spread.web --dataset data/processed/manhattan_network.json --buildings data/processed/manhattan_buildings.json --host 127.0.0.1 --port 8000
```

On Windows, double-click [`launch_polatli_ui.bat`](launch_polatli_ui.bat). It creates `.venv` on the first run, installs the project, starts the server with the real Polatlı network and building layer, and opens the browser automatically. Press `Ctrl+C` in the launcher window to stop it.
On Windows, double-click [`launch_manhattan_ui.bat`](launch_manhattan_ui.bat). It creates `.venv` on the first run, installs the project, starts the server with the Manhattan network and detailed building layer, and opens the browser automatically. Press `Ctrl+C` in the launcher window to stop it. The older launcher now also points at Manhattan for compatibility.

The launcher intentionally prefers the `python` command on `PATH`; `py -3` can select an older installed interpreter even when `python --version` reports 3.11.9.

Open `http://127.0.0.1:8000`. The UI reads the real local graph and building layer, allows a node ignition and parameterized run, supports orthographic and perspective projections, offers source-only or explicitly labeled 3 m massing fallback heights, shows activated links, ranks advancement scores, and downloads the exact JSON result returned by the simulation.
Open `http://127.0.0.1:8000`. The UI reads the real local graph and building layer, extrudes every OSM footprint into a 3D scene, applies tagged heights and `building:levels` estimates, highlights buildings adjacent to the advancing front in bright red, offers source-only or explicitly labeled 3 m massing fallback heights, applies the optional QUIC-URB-inspired urban-wind grid, and can draw a local flow-vector graph around the selected node. It also shows activated links, ranks advancement scores, and downloads the exact JSON result returned by the simulation.

Map navigation: use the mouse wheel to zoom, drag with the left button to pan, and hold `Shift` while dragging (or use the right mouse button) to rotate. `Reset view` restores the fitted scene.
Map navigation: use the mouse wheel or `E`/`Q` to zoom, drag with the left button to orbit, hold `Shift` while dragging (or use the right mouse button) to pan, use `W`/`A`/`S`/`D` to pan, and use the arrow keys to rotate. The scene has no distance fog; `Reset view` restores the fitted scene.


Vertical exaggeration is a visual control only. It changes how height is displayed, not the stored OSM heights or fire propagation calculations.
Expand Down
3 changes: 3 additions & 0 deletions data/processed/manhattan_buildings.json
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/processed/manhattan_network.json
Git LFS file not shown
21 changes: 21 additions & 0 deletions data/raw/manhattan_buildings_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"dataset": "Manhattan Island OSM building footprints and 3D tags",
"provider": "OpenStreetMap contributors",
"source_api": "Overpass API",
"source_url": "https://overpass.kumi.systems/api/interpreter",
"license": "OpenStreetMap data © OpenStreetMap contributors, ODbL 1.0",
"bbox": {
"south": 40.7,
"west": -74.02,
"north": 40.8825,
"east": -73.9065
},
"bbox_description": "Same Manhattan Island study area as the street graph",
"query": "[out:json][timeout:600];(way[building](40.7000,-74.0200,40.8825,-73.9065);way[\"building:part\"](40.7000,-74.0200,40.8825,-73.9065););out body geom;",
"origin": {
"latitude": 40.79125,
"longitude": -73.96325,
"source": "center of the Manhattan Island study bbox"
},
"height_policy": "Use height tag when present; otherwise estimate building:levels at 3 metres per level; otherwise retain footprint with height 0 and mark footprint_only"
}
21 changes: 21 additions & 0 deletions data/raw/manhattan_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"dataset": "Manhattan Island urban street network",
"provider": "OpenStreetMap contributors",
"source_api": "Overpass API",
"source_url": "https://overpass.kumi.systems/api/interpreter",
"license": "OpenStreetMap data © OpenStreetMap contributors, ODbL 1.0",
"bbox": {
"south": 40.7,
"west": -74.02,
"north": 40.8825,
"east": -73.9065
},
"bbox_description": "Manhattan Island and immediate shoreline study area",
"query": "[out:json][timeout:300];way[highway~\"^(motorway|trunk|primary|secondary|tertiary|unclassified|residential|living_street|service|road|track|pedestrian)$\"](40.7000,-74.0200,40.8825,-73.9065);out body geom;",
"origin": {
"latitude": 40.79125,
"longitude": -73.96325,
"source": "center of the Manhattan Island study bbox"
},
"downloaded_for": "urban-fire-spread detailed city replacement"
}
3 changes: 3 additions & 0 deletions data/raw/manhattan_osm_buildings.json
Git LFS file not shown
Loading