← back to Firecities
Initial CA Fire Communities DINS viewer
193afb3f17063095737cb589919485f79b588166 · 2026-08-24 04:25:38 -0700 · Steve
- Express server on port 9970-9979 with /api/status, /api/communities, /api/structures, /api/counties
- public/index.html: fire-themed grid viewer with sort + density slider (per standing rule), community cards showing damage breakdown badges, search by city, county filter, damage filter, and click-to-drill detail modal
- scripts/fetch-dins.js: paginates the CAL FIRE master DINS service (services1.arcgis.com/.../POSTFIRE_MASTER_DATA_SHARE) at 2000 records/page; aggregates by city into community stats; writes data/dins.json
- ArcGIS endpoint verified: 132,522 total records, 70,390 destroyed (>50%), 310 cities since 2013
- Pilot fetch (2,000 records) confirmed working at localhost:9970
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Files touched
A .gitignoreA package-lock.jsonA package.jsonA public/index.htmlA scripts/fetch-dins.jsA server.js
Diff
commit 193afb3f17063095737cb589919485f79b588166
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Aug 24 04:25:38 2026 -0700
Initial CA Fire Communities DINS viewer
- Express server on port 9970-9979 with /api/status, /api/communities, /api/structures, /api/counties
- public/index.html: fire-themed grid viewer with sort + density slider (per standing rule), community cards showing damage breakdown badges, search by city, county filter, damage filter, and click-to-drill detail modal
- scripts/fetch-dins.js: paginates the CAL FIRE master DINS service (services1.arcgis.com/.../POSTFIRE_MASTER_DATA_SHARE) at 2000 records/page; aggregates by city into community stats; writes data/dins.json
- ArcGIS endpoint verified: 132,522 total records, 70,390 destroyed (>50%), 310 cities since 2013
- Pilot fetch (2,000 records) confirmed working at localhost:9970
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
.gitignore | 7 +
package-lock.json | 828 ++++++++++++++++++++++++++++++++++++++++++++++++++
package.json | 16 +
public/index.html | 436 ++++++++++++++++++++++++++
scripts/fetch-dins.js | 176 +++++++++++
server.js | 174 +++++++++++
6 files changed, 1637 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ff3b926
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+node_modules/
+.env*
+*.log
+.DS_Store
+.port
+tmp/
+data/*.json
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..18ac461
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,828 @@
+{
+ "name": "firecities",
+ "version": "1.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "firecities",
+ "version": "1.0.0",
+ "dependencies": {
+ "express": "^4.22.2"
+ }
+ },
+ "node_modules/accepts": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
+ "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-types": "~2.1.34",
+ "negotiator": "0.6.3"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/array-flatten": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
+ "license": "MIT"
+ },
+ "node_modules/body-parser": {
+ "version": "1.20.6",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.6.tgz",
+ "integrity": "sha512-p5tAzS57i5MV9fZFDj9LeIiTZEufbSe2eDozP+ElheSUq1m74CRq1jI4mYNDdVs9vQztXFLuk/Gd6BWTdwRJ5g==",
+ "license": "MIT",
+ "dependencies": {
+ "bytes": "~3.1.2",
+ "content-type": "~1.0.5",
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "~1.2.0",
+ "http-errors": "~2.0.1",
+ "iconv-lite": "~0.4.24",
+ "on-finished": "~2.4.1",
+ "qs": "~6.15.1",
+ "raw-body": "~2.5.3",
+ "type-is": "~1.6.18",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8",
+ "npm": "1.2.8000 || >= 1.4.16"
+ }
+ },
+ "node_modules/bytes": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/call-bind-apply-helpers": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/call-bound": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "get-intrinsic": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/content-disposition": {
+ "version": "0.5.4",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
+ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "5.2.1"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/content-type": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie": {
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
+ "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie-signature": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
+ "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
+ "license": "MIT"
+ },
+ "node_modules/debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "2.0.0"
+ }
+ },
+ "node_modules/depd": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/destroy": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
+ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8",
+ "npm": "1.2.8000 || >= 1.4.16"
+ }
+ },
+ "node_modules/dunder-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "gopd": "^1.2.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
+ "license": "MIT"
+ },
+ "node_modules/encodeurl": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/es-define-property": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-errors": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-object-atoms": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
+ "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
+ "license": "MIT"
+ },
+ "node_modules/etag": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/express": {
+ "version": "4.22.2",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
+ "integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
+ "license": "MIT",
+ "dependencies": {
+ "accepts": "~1.3.8",
+ "array-flatten": "1.1.1",
+ "body-parser": "~1.20.5",
+ "content-disposition": "~0.5.4",
+ "content-type": "~1.0.4",
+ "cookie": "~0.7.1",
+ "cookie-signature": "~1.0.6",
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "finalhandler": "~1.3.1",
+ "fresh": "~0.5.2",
+ "http-errors": "~2.0.0",
+ "merge-descriptors": "1.0.3",
+ "methods": "~1.1.2",
+ "on-finished": "~2.4.1",
+ "parseurl": "~1.3.3",
+ "path-to-regexp": "~0.1.12",
+ "proxy-addr": "~2.0.7",
+ "qs": "~6.15.1",
+ "range-parser": "~1.2.1",
+ "safe-buffer": "5.2.1",
+ "send": "~0.19.0",
+ "serve-static": "~1.16.2",
+ "setprototypeof": "1.2.0",
+ "statuses": "~2.0.1",
+ "type-is": "~1.6.18",
+ "utils-merge": "1.0.1",
+ "vary": "~1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/finalhandler": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
+ "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "2.6.9",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "on-finished": "~2.4.1",
+ "parseurl": "~1.3.3",
+ "statuses": "~2.0.2",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/forwarded": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/fresh": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/function-bind": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-intrinsic": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "es-define-property": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "es-object-atoms": "^1.1.1",
+ "function-bind": "^1.1.2",
+ "get-proto": "^1.0.1",
+ "gopd": "^1.2.0",
+ "has-symbols": "^1.1.0",
+ "hasown": "^2.0.2",
+ "math-intrinsics": "^1.1.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
+ "license": "MIT",
+ "dependencies": {
+ "dunder-proto": "^1.0.1",
+ "es-object-atoms": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/gopd": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-symbols": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/hasown": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
+ "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
+ "license": "MIT",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/http-errors": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
+ "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
+ "license": "MIT",
+ "dependencies": {
+ "depd": "~2.0.0",
+ "inherits": "~2.0.4",
+ "setprototypeof": "~1.2.0",
+ "statuses": "~2.0.2",
+ "toidentifier": "~1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/iconv-lite": {
+ "version": "0.4.24",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+ "license": "MIT",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+ "license": "ISC"
+ },
+ "node_modules/ipaddr.js": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/math-intrinsics": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/media-typer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/merge-descriptors": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
+ "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/methods": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "license": "MIT",
+ "bin": {
+ "mime": "cli.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-db": "1.52.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "license": "MIT"
+ },
+ "node_modules/negotiator": {
+ "version": "0.6.3",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/object-inspect": {
+ "version": "1.13.4",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/on-finished": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+ "license": "MIT",
+ "dependencies": {
+ "ee-first": "1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/parseurl": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/path-to-regexp": {
+ "version": "0.1.13",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
+ "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
+ "license": "MIT"
+ },
+ "node_modules/proxy-addr": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
+ "license": "MIT",
+ "dependencies": {
+ "forwarded": "0.2.0",
+ "ipaddr.js": "1.9.1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/qs": {
+ "version": "6.15.3",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz",
+ "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "es-define-property": "^1.0.1",
+ "side-channel": "^1.1.1"
+ },
+ "engines": {
+ "node": ">=0.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/range-parser": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/raw-body": {
+ "version": "2.5.3",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
+ "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
+ "license": "MIT",
+ "dependencies": {
+ "bytes": "~3.1.2",
+ "http-errors": "~2.0.1",
+ "iconv-lite": "~0.4.24",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/safe-buffer": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
+ "license": "MIT"
+ },
+ "node_modules/send": {
+ "version": "0.19.2",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
+ "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "1.2.0",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "fresh": "~0.5.2",
+ "http-errors": "~2.0.1",
+ "mime": "1.6.0",
+ "ms": "2.1.3",
+ "on-finished": "~2.4.1",
+ "range-parser": "~1.2.1",
+ "statuses": "~2.0.2"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/send/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "license": "MIT"
+ },
+ "node_modules/serve-static": {
+ "version": "1.16.3",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
+ "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
+ "license": "MIT",
+ "dependencies": {
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "parseurl": "~1.3.3",
+ "send": "~0.19.1"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/setprototypeof": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
+ "license": "ISC"
+ },
+ "node_modules/side-channel": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
+ "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.4",
+ "side-channel-list": "^1.0.1",
+ "side-channel-map": "^1.0.1",
+ "side-channel-weakmap": "^1.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-list": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
+ "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.4"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-map": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bound": "^1.0.2",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.5",
+ "object-inspect": "^1.13.3"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-weakmap": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bound": "^1.0.2",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.5",
+ "object-inspect": "^1.13.3",
+ "side-channel-map": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/statuses": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
+ "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/toidentifier": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.6"
+ }
+ },
+ "node_modules/type-is": {
+ "version": "1.6.18",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
+ "license": "MIT",
+ "dependencies": {
+ "media-typer": "0.3.0",
+ "mime-types": "~2.1.24"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/utils-merge": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4.0"
+ }
+ },
+ "node_modules/vary": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..8094fdb
--- /dev/null
+++ b/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "firecities",
+ "version": "1.0.0",
+ "private": true,
+ "description": "California Fire Communities DINS viewer — 257 wildfire-affected communities / 55,902+ destroyed structures",
+ "main": "server.js",
+ "scripts": {
+ "start": "node server.js",
+ "fetch": "node scripts/fetch-dins.js",
+ "fetch:pilot": "node scripts/fetch-dins.js --limit=2000",
+ "fetch:full": "node scripts/fetch-dins.js"
+ },
+ "dependencies": {
+ "express": "^4.22.2"
+ }
+}
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..39e3ca7
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,436 @@
+<!doctype html>
+<html lang="en">
+<head>
+<script>(function(){try{var t=localStorage.getItem('firecities-theme');document.documentElement.setAttribute('data-theme',t==='light'?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<title>California Fire Communities · DINS Structures</title>
+<style>
+ :root{
+ --bg:#160f0d; --panel:#221513; --panel2:#2c1a16; --edge:#43261f;
+ --ink:#f3e9e6; --mut:#c39a8e; --accent:#ff7a45; --accent2:#c2410c;
+ --ember:#ff5722; --green:#4caf50; --yellow:#ffc107; --red:#f44336;
+ --cols:4;
+ }
+ html[data-theme="light"]{
+ --bg:#fff4ef; --panel:#ffffff; --panel2:#fff0e9; --edge:#f0d3c6;
+ --ink:#2a1712; --mut:#8a5c48;
+ }
+ *{box-sizing:border-box}
+ body{margin:0;background:var(--bg);color:var(--ink);
+ font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;min-height:100vh}
+ .wrap{max-width:1400px;margin:0 auto;padding:32px 20px 80px}
+
+ /* Header */
+ header.top{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:4px}
+ header.top h1{font-size:24px;font-weight:700;margin:0;letter-spacing:.2px;display:flex;align-items:center;gap:10px}
+ header.top h1 .fl{color:var(--ember);font-size:22px}
+ .sub{color:var(--mut);margin:0 0 6px;font-size:13px}
+ .stat-bar{display:flex;gap:16px;flex-wrap:wrap;margin:12px 0 20px;padding:14px 18px;
+ background:var(--panel);border:1px solid var(--edge);border-radius:12px}
+ .stat{text-align:center}
+ .stat .n{font-size:22px;font-weight:700;color:var(--ember)}
+ .stat .l{font-size:11px;text-transform:uppercase;letter-spacing:.6px;color:var(--mut);margin-top:2px}
+
+ /* Controls */
+ .controls{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:18px;
+ padding:14px 16px;background:var(--panel);border:1px solid var(--edge);border-radius:12px}
+ .controls label{font-size:12px;text-transform:uppercase;letter-spacing:.5px;color:var(--mut);white-space:nowrap}
+ input[type=text],select{background:var(--panel2);color:var(--ink);border:1px solid var(--edge);
+ border-radius:8px;padding:8px 12px;font:inherit;min-width:0}
+ input[type=text]:focus,select:focus{outline:2px solid var(--accent);outline-offset:1px}
+ input[type=text].search{flex:1 1 200px;min-width:140px}
+ select.sort-sel,select.dmg-sel,select.county-sel{flex:0 0 auto}
+
+ /* Density slider */
+ .density-wrap{display:flex;align-items:center;gap:8px;white-space:nowrap}
+ .density-wrap label{font-size:12px;text-transform:uppercase;letter-spacing:.5px;color:var(--mut)}
+ input[type=range]{accent-color:var(--accent);cursor:pointer;width:80px}
+
+ /* Theme toggle */
+ .theme-btn{background:none;border:1px solid var(--edge);color:var(--mut);border-radius:8px;
+ padding:6px 12px;cursor:pointer;font-size:13px}
+ .theme-btn:hover{border-color:var(--accent);color:var(--ink)}
+
+ /* Count line */
+ .count-line{color:var(--mut);font-size:13px;margin-bottom:12px;display:flex;align-items:center;gap:10px}
+ .count-line strong{color:var(--ink)}
+ .loading{color:var(--mut);font-size:13px;padding:40px 0;text-align:center}
+ .error-msg{color:#f44336;padding:20px;background:var(--panel);border:1px solid var(--edge);border-radius:10px;margin:20px 0}
+
+ /* Grid */
+ .grid{display:grid;grid-template-columns:repeat(var(--cols),1fr);gap:10px}
+ @media(max-width:900px){.grid{grid-template-columns:repeat(2,1fr)}}
+ @media(max-width:540px){.grid{grid-template-columns:1fr}}
+
+ /* Cards */
+ .card{background:var(--panel2);border:1px solid var(--edge);border-radius:10px;
+ padding:14px;cursor:pointer;transition:.12s;position:relative}
+ .card:hover{border-color:var(--accent);background:var(--panel);transform:translateY(-1px)}
+ .card .city-name{font-weight:700;font-size:15px;margin-bottom:3px;line-height:1.2}
+ .card .county{font-size:12px;color:var(--mut);margin-bottom:10px}
+ .card .dmg-row{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}
+ .badge{font-size:11px;border-radius:20px;padding:3px 9px;border:1px solid;font-weight:600;white-space:nowrap}
+ .badge.destroyed{color:#ff6b47;border-color:#ff6b4740;background:#ff6b4712}
+ .badge.major{color:#ffc107;border-color:#ffc10740;background:#ffc10712}
+ .badge.minor{color:#64b5f6;border-color:#64b5f640;background:#64b5f612}
+ .badge.affected{color:#81c784;border-color:#81c78440;background:#81c78412}
+ .badge.nodamage{color:var(--mut);border-color:var(--edge)}
+ .card .incidents{font-size:11px;color:var(--mut);line-height:1.3;overflow:hidden;
+ display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
+ .card .last-fire{font-size:11px;color:var(--mut);margin-top:6px}
+ .card .total-badge{position:absolute;top:10px;right:10px;font-size:11px;color:var(--mut);
+ background:var(--bg);border:1px solid var(--edge);border-radius:20px;padding:2px 8px}
+
+ /* Pagination */
+ .pager{display:flex;gap:8px;align-items:center;justify-content:center;margin-top:24px;flex-wrap:wrap}
+ .pager button{background:var(--panel);border:1px solid var(--edge);color:var(--ink);
+ border-radius:8px;padding:7px 16px;cursor:pointer;font:inherit}
+ .pager button:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
+ .pager button:disabled{opacity:.4;cursor:default}
+ .pager .pg-info{color:var(--mut);font-size:13px}
+
+ /* Data status banner */
+ .status-banner{background:var(--panel);border:1px solid var(--edge);border-radius:12px;
+ padding:20px 24px;margin-bottom:24px;text-align:center}
+ .status-banner p{margin:6px 0;color:var(--mut)}
+ .status-banner code{background:var(--bg);border:1px solid var(--edge);border-radius:6px;
+ padding:4px 10px;font-size:13px;color:var(--accent)}
+
+ /* Modal */
+ .modal-overlay{display:none;position:fixed;inset:0;background:#0008;z-index:100;align-items:center;justify-content:center}
+ .modal-overlay.open{display:flex}
+ .modal{background:var(--panel);border:1px solid var(--edge);border-radius:14px;
+ max-width:700px;width:90%;max-height:80vh;overflow:hidden;display:flex;flex-direction:column}
+ .modal-head{padding:18px 20px;border-bottom:1px solid var(--edge);display:flex;align-items:center;justify-content:space-between}
+ .modal-head h2{margin:0;font-size:18px}
+ .modal-close{background:none;border:none;color:var(--mut);cursor:pointer;font-size:20px;padding:0 6px}
+ .modal-body{overflow-y:auto;padding:18px 20px;flex:1}
+ .struct-list{display:grid;gap:6px}
+ .struct-row{background:var(--panel2);border:1px solid var(--edge);border-radius:8px;padding:9px 12px;font-size:13px}
+ .struct-row .addr{font-weight:600}
+ .struct-row .meta{color:var(--mut);font-size:12px;margin-top:2px}
+</style>
+</head>
+<body>
+<div class="wrap">
+ <header class="top">
+ <h1><span class="fl">🔥</span> California Fire Communities</h1>
+ <button class="theme-btn" id="themeBtn">☀ Light</button>
+ </header>
+ <p class="sub">CAL FIRE Damage Inspection (DINS) dataset · All wildfire-affected structures in California since 2013</p>
+
+ <div class="stat-bar" id="statBar">
+ <div class="stat"><div class="n" id="sTotal">—</div><div class="l">Total Structures</div></div>
+ <div class="stat"><div class="n" id="sDestroyed">—</div><div class="l">Destroyed (>50%)</div></div>
+ <div class="stat"><div class="n" id="sCities">—</div><div class="l">Communities</div></div>
+ <div class="stat"><div class="n" id="sSource">—</div><div class="l">Data Source</div></div>
+ </div>
+
+ <div id="noBanner" class="status-banner" style="display:none">
+ <p>⚠ DINS data not yet fetched. Run the fetch script to load structure data:</p>
+ <p><code>node scripts/fetch-dins.js --limit=5000</code></p>
+ <p style="font-size:12px">For the full ~132,000-record dataset (takes ~2 min): <code>node scripts/fetch-dins.js</code></p>
+ </div>
+
+ <div class="controls">
+ <input type="text" class="search" id="search" placeholder="Search city or community…" autocomplete="off">
+ <div>
+ <label>Sort</label><br>
+ <select class="sort-sel" id="sortSel">
+ <option value="destroyed">Most Destroyed</option>
+ <option value="total">Most Structures</option>
+ <option value="name">City A→Z</option>
+ <option value="county">County A→Z</option>
+ <option value="date">Most Recent Fire</option>
+ </select>
+ </div>
+ <div>
+ <label>Damage Filter</label><br>
+ <select class="dmg-sel" id="dmgSel">
+ <option value="">All Damage Levels</option>
+ <option value="Destroyed (>50%)">Destroyed (>50%)</option>
+ <option value="Major (25-50%)">Major (25–50%)</option>
+ <option value="Minor (10-25%)">Minor (10–25%)</option>
+ <option value="Affected (>0-10%)">Affected (>0–10%)</option>
+ </select>
+ </div>
+ <div>
+ <label>County</label><br>
+ <select class="county-sel" id="countySel">
+ <option value="">All Counties</option>
+ </select>
+ </div>
+ <div class="density-wrap">
+ <label>Density</label><br>
+ <input type="range" id="densitySlider" min="1" max="6" value="4" step="1">
+ </div>
+ </div>
+
+ <div class="count-line" id="countLine"></div>
+
+ <div id="gridEl" class="grid"></div>
+ <div id="loadingEl" class="loading" style="display:none">Loading…</div>
+
+ <div class="pager" id="pager" style="display:none">
+ <button id="prevBtn" disabled>← Prev</button>
+ <span class="pg-info" id="pgInfo"></span>
+ <button id="nextBtn">Next →</button>
+ </div>
+</div>
+
+<!-- Detail modal -->
+<div class="modal-overlay" id="modalOverlay">
+ <div class="modal">
+ <div class="modal-head">
+ <h2 id="modalTitle">City</h2>
+ <button class="modal-close" id="modalClose">✕</button>
+ </div>
+ <div class="modal-body" id="modalBody"></div>
+ </div>
+</div>
+
+<script>
+(function() {
+ // ── State ──────────────────────────────────────────────────────────────────
+ var PAGE_SIZE = 100;
+ var offset = 0;
+ var totalCount = 0;
+ var dataOk = false;
+ var debounceT = null;
+ var openCity = null;
+
+ // ── Restore localStorage ───────────────────────────────────────────────────
+ try {
+ var savedCols = localStorage.getItem('firecities-cols');
+ if (savedCols) document.documentElement.style.setProperty('--cols', savedCols);
+ var savedSort = localStorage.getItem('firecities-sort');
+ if (savedSort) document.getElementById('sortSel').value = savedSort;
+ var savedDmg = localStorage.getItem('firecities-dmg');
+ if (savedDmg) document.getElementById('dmgSel').value = savedDmg;
+ var savedDensity = localStorage.getItem('firecities-density');
+ if (savedDensity) document.getElementById('densitySlider').value = savedDensity;
+ } catch(e) {}
+
+ // ── Status ─────────────────────────────────────────────────────────────────
+ function loadStatus() {
+ fetch('/api/status').then(function(r){return r.json();}).then(function(d){
+ if (!d.ok) {
+ document.getElementById('noBanner').style.display = 'block';
+ return;
+ }
+ dataOk = true;
+ document.getElementById('noBanner').style.display = 'none';
+ document.getElementById('sTotal').textContent = Number(d.totalRecords).toLocaleString();
+ document.getElementById('sDestroyed').textContent = Number(d.destroyedCount).toLocaleString();
+ document.getElementById('sCities').textContent = Number(d.totalCities).toLocaleString();
+ document.getElementById('sSource').textContent = 'CAL FIRE DINS';
+ document.getElementById('sSource').title = d.source;
+ loadCounties();
+ loadPage(0);
+ }).catch(function(){
+ document.getElementById('noBanner').style.display = 'block';
+ });
+ }
+
+ function loadCounties() {
+ fetch('/api/counties').then(function(r){return r.json();}).then(function(d){
+ var sel = document.getElementById('countySel');
+ d.counties.forEach(function(c){
+ var o = document.createElement('option'); o.value = c; o.textContent = c;
+ sel.appendChild(o);
+ });
+ }).catch(function(){});
+ }
+
+ // ── Query params ───────────────────────────────────────────────────────────
+ function getParams(off) {
+ var p = new URLSearchParams();
+ p.set('sort', document.getElementById('sortSel').value);
+ p.set('limit', PAGE_SIZE);
+ p.set('offset', off || 0);
+ var q = document.getElementById('search').value.trim();
+ if (q) p.set('q', q);
+ var dmg = document.getElementById('dmgSel').value;
+ if (dmg) p.set('damage', dmg);
+ var county = document.getElementById('countySel').value;
+ if (county) p.set('county', county);
+ return p.toString();
+ }
+
+ // ── Load page ──────────────────────────────────────────────────────────────
+ function loadPage(off) {
+ if (!dataOk) return;
+ document.getElementById('loadingEl').style.display = 'block';
+ document.getElementById('gridEl').style.opacity = '0.4';
+ offset = off || 0;
+ fetch('/api/communities?' + getParams(offset))
+ .then(function(r){return r.json();})
+ .then(function(d){
+ document.getElementById('loadingEl').style.display = 'none';
+ document.getElementById('gridEl').style.opacity = '1';
+ totalCount = d.total;
+ renderGrid(d.communities);
+ renderPager(d.total, d.offset, d.limit);
+ var cl = document.getElementById('countLine');
+ cl.innerHTML = '<strong>' + Number(d.total).toLocaleString() + '</strong> communities' +
+ (d.total !== d.communities.length + d.offset ? ' · showing ' + (d.offset+1) + '–' + (d.offset + d.communities.length) : '');
+ })
+ .catch(function(e){
+ document.getElementById('loadingEl').style.display = 'none';
+ document.getElementById('gridEl').innerHTML = '<div class="error-msg">Error loading data: ' + e.message + '</div>';
+ });
+ }
+
+ // ── Render ─────────────────────────────────────────────────────────────────
+ function dmgBadge(label, count, cls) {
+ if (!count) return '';
+ return '<span class="badge ' + cls + '">' + label + ' ' + Number(count).toLocaleString() + '</span>';
+ }
+
+ function renderGrid(communities) {
+ var el = document.getElementById('gridEl');
+ if (!communities.length) {
+ el.innerHTML = '<div class="loading">No communities found.</div>';
+ return;
+ }
+ el.innerHTML = communities.map(function(c) {
+ var destroyed = c.counts['Destroyed (>50%)'] || 0;
+ var major = c.counts['Major (25-50%)'] || 0;
+ var minor = c.counts['Minor (10-25%)'] || 0;
+ var affected = c.counts['Affected (>0-10%)'] || 0;
+ var incidents = (c.incidents || []).slice(0, 3).join(', ') + (c.incidents && c.incidents.length > 3 ? '…' : '');
+ var lastFire = c.lastDate ? c.lastDate.slice(0,4) + ' fire' : '';
+ return '<div class="card" data-city="' + encodeURIComponent(c.city) + '" onclick="openCity(this)">' +
+ '<span class="total-badge">' + Number(c.total).toLocaleString() + ' total</span>' +
+ '<div class="city-name">' + esc(c.city) + '</div>' +
+ '<div class="county">' + esc(c.county || '') + (c.county ? ' County' : '') + '</div>' +
+ '<div class="dmg-row">' +
+ dmgBadge('Destroyed', destroyed, 'destroyed') +
+ dmgBadge('Major', major, 'major') +
+ dmgBadge('Minor', minor, 'minor') +
+ dmgBadge('Affected', affected, 'affected') +
+ '</div>' +
+ (incidents ? '<div class="incidents">' + esc(incidents) + '</div>' : '') +
+ (lastFire ? '<div class="last-fire">Last fire: ' + lastFire + '</div>' : '') +
+ '</div>';
+ }).join('');
+ }
+
+ function renderPager(total, off, limit) {
+ var pg = document.getElementById('pager');
+ var pgInfo = document.getElementById('pgInfo');
+ var prevBtn = document.getElementById('prevBtn');
+ var nextBtn = document.getElementById('nextBtn');
+ var pages = Math.ceil(total / limit);
+ var cur = Math.floor(off / limit) + 1;
+ if (pages <= 1) { pg.style.display = 'none'; return; }
+ pg.style.display = 'flex';
+ pgInfo.textContent = 'Page ' + cur + ' of ' + pages;
+ prevBtn.disabled = off === 0;
+ nextBtn.disabled = off + limit >= total;
+ }
+
+ // ── Modal ──────────────────────────────────────────────────────────────────
+ window.openCity = function(card) {
+ var city = decodeURIComponent(card.dataset.city);
+ openCity = city;
+ document.getElementById('modalTitle').textContent = '🔥 ' + city;
+ document.getElementById('modalBody').innerHTML = '<div class="loading">Loading structures…</div>';
+ document.getElementById('modalOverlay').classList.add('open');
+
+ fetch('/api/structures?city=' + encodeURIComponent(city) + '&limit=200')
+ .then(function(r){return r.json();})
+ .then(function(d){
+ var body = document.getElementById('modalBody');
+ var html = '<p style="color:var(--mut);font-size:13px;margin:0 0 14px">' +
+ '<strong>' + d.total.toLocaleString() + '</strong> structures in ' + esc(city) +
+ (d.total > 200 ? ' (showing first 200)' : '') + '</p>';
+
+ // Damage summary
+ var dmgMap = {};
+ d.structures.forEach(function(s){ dmgMap[s.damage] = (dmgMap[s.damage]||0)+1; });
+ var summary = Object.entries(dmgMap).sort(function(a,b){return b[1]-a[1];})
+ .map(function(e){ return esc(e[0]) + ': ' + e[1].toLocaleString(); }).join(' · ');
+ html += '<p style="font-size:12px;color:var(--mut);margin:0 0 14px">' + summary + '</p>';
+
+ html += '<div class="struct-list">' +
+ d.structures.map(function(s){
+ var addr = [s.structureType].filter(Boolean).join(' ');
+ var dmgColor = s.damage === 'Destroyed (>50%)' ? '#ff6b47' :
+ s.damage === 'Major (25-50%)' ? '#ffc107' :
+ s.damage === 'Minor (10-25%)' ? '#64b5f6' : 'var(--mut)';
+ return '<div class="struct-row">' +
+ '<span class="addr">' + esc(s.structureType || 'Structure') + '</span> ' +
+ '<span style="color:' + dmgColor + ';font-weight:600;font-size:12px">' + esc(s.damage || '') + '</span>' +
+ '<div class="meta">' + [s.incident, s.incidentDate ? s.incidentDate.slice(0,4) : null, s.county].filter(Boolean).join(' · ') + '</div>' +
+ '</div>';
+ }).join('') + '</div>';
+ body.innerHTML = html;
+ })
+ .catch(function(e){
+ document.getElementById('modalBody').innerHTML = '<div class="error-msg">Error: ' + e.message + '</div>';
+ });
+ };
+
+ document.getElementById('modalClose').onclick = function(){
+ document.getElementById('modalOverlay').classList.remove('open');
+ };
+ document.getElementById('modalOverlay').onclick = function(e){
+ if (e.target === this) this.classList.remove('open');
+ };
+ document.addEventListener('keydown', function(e){
+ if (e.key === 'Escape') document.getElementById('modalOverlay').classList.remove('open');
+ });
+
+ // ── Controls ───────────────────────────────────────────────────────────────
+ document.getElementById('search').addEventListener('input', function(){
+ clearTimeout(debounceT);
+ debounceT = setTimeout(function(){ loadPage(0); }, 300);
+ });
+
+ ['sortSel', 'dmgSel', 'countySel'].forEach(function(id){
+ document.getElementById(id).addEventListener('change', function(){
+ try { localStorage.setItem('firecities-' + id.replace('Sel',''), this.value); } catch(e){}
+ loadPage(0);
+ });
+ });
+
+ document.getElementById('densitySlider').addEventListener('input', function(){
+ var v = this.value;
+ document.documentElement.style.setProperty('--cols', v);
+ try { localStorage.setItem('firecities-density', v); localStorage.setItem('firecities-cols', v); } catch(e){}
+ });
+
+ // Set initial density
+ var initDensity = document.getElementById('densitySlider').value;
+ document.documentElement.style.setProperty('--cols', initDensity);
+
+ // Pager
+ document.getElementById('prevBtn').onclick = function(){ if (offset > 0) loadPage(offset - PAGE_SIZE); };
+ document.getElementById('nextBtn').onclick = function(){ loadPage(offset + PAGE_SIZE); };
+
+ // Theme toggle
+ (function(){
+ var btn = document.getElementById('themeBtn');
+ var cur = document.documentElement.getAttribute('data-theme') || 'dark';
+ btn.textContent = cur === 'dark' ? '☀ Light' : '🌙 Dark';
+ btn.onclick = function(){
+ cur = cur === 'dark' ? 'light' : 'dark';
+ document.documentElement.setAttribute('data-theme', cur);
+ btn.textContent = cur === 'dark' ? '☀ Light' : '🌙 Dark';
+ try { localStorage.setItem('firecities-theme', cur); } catch(e){}
+ };
+ })();
+
+ // ── Helpers ────────────────────────────────────────────────────────────────
+ function esc(s) {
+ return String(s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
+ }
+
+ // ── Init ───────────────────────────────────────────────────────────────────
+ loadStatus();
+})();
+</script>
+</body>
+</html>
diff --git a/scripts/fetch-dins.js b/scripts/fetch-dins.js
new file mode 100644
index 0000000..ea72c9a
--- /dev/null
+++ b/scripts/fetch-dins.js
@@ -0,0 +1,176 @@
+#!/usr/bin/env node
+// fetch-dins.js — Paginate the CAL FIRE master DINS dataset from ArcGIS and save to data/dins.json
+// Service: https://services1.arcgis.com/jUJYIo9tSA7EHvfZ/arcgis/rest/services/POSTFIRE_MASTER_DATA_SHARE/FeatureServer/0
+// 132,522 total records (as of Aug 2026), maxRecordCount=2000 per page
+
+const https = require('https');
+const fs = require('fs');
+const path = require('path');
+
+const BASE_URL = 'https://services1.arcgis.com/jUJYIo9tSA7EHvfZ/arcgis/rest/services/POSTFIRE_MASTER_DATA_SHARE/FeatureServer/0/query';
+const DATA_DIR = path.join(__dirname, '..', 'data');
+const OUT_FILE = path.join(DATA_DIR, 'dins.json');
+
+const args = process.argv.slice(2);
+const limitArg = args.find(a => a.startsWith('--limit='));
+const MAX_LIMIT = limitArg ? parseInt(limitArg.split('=')[1], 10) : Infinity;
+const PAGE_SIZE = 2000;
+
+// Fields we care about for the viewer
+const FIELDS = 'OBJECTID,DAMAGE,STRUCTURETYPE,CITY,STATE,COUNTY,COMMUNITY,INCIDENTNAME,INCIDENTSTARTDATE,STRUCTURECATEGORY,LATITUDE,LONGITUDE';
+
+function fetchPage(offset) {
+ return new Promise((resolve, reject) => {
+ const params = new URLSearchParams({
+ where: '1=1',
+ outFields: FIELDS,
+ resultOffset: offset,
+ resultRecordCount: PAGE_SIZE,
+ orderByFields: 'OBJECTID ASC',
+ f: 'json'
+ });
+ const url = `${BASE_URL}?${params.toString()}`;
+ const req = https.get(url, (res) => {
+ let body = '';
+ res.on('data', chunk => body += chunk);
+ res.on('end', () => {
+ try {
+ const d = JSON.parse(body);
+ if (d.error) reject(new Error(JSON.stringify(d.error)));
+ else resolve(d);
+ } catch (e) { reject(e); }
+ });
+ });
+ req.on('error', reject);
+ req.setTimeout(30000, () => { req.destroy(); reject(new Error('timeout at offset ' + offset)); });
+ });
+}
+
+async function fetchCount() {
+ return new Promise((resolve, reject) => {
+ const params = new URLSearchParams({ where: '1=1', returnCountOnly: 'true', f: 'json' });
+ const url = `${BASE_URL}?${params.toString()}`;
+ https.get(url, (res) => {
+ let body = '';
+ res.on('data', c => body += c);
+ res.on('end', () => {
+ try { resolve(JSON.parse(body).count); } catch (e) { reject(e); }
+ });
+ }).on('error', reject);
+ });
+}
+
+async function main() {
+ if (!fs.existsSync(DATA_DIR)) fs.mkdirSync(DATA_DIR, { recursive: true });
+
+ console.log('Fetching total count from CAL FIRE master DINS service...');
+ const total = await fetchCount();
+ const fetchUpTo = Math.min(total, MAX_LIMIT);
+ console.log(`Total records: ${total.toLocaleString()} — fetching up to ${fetchUpTo.toLocaleString()}`);
+
+ const records = [];
+ let offset = 0;
+ let page = 0;
+
+ while (offset < fetchUpTo) {
+ const thisPage = Math.min(PAGE_SIZE, fetchUpTo - offset);
+ process.stdout.write(` Page ${++page}: offset=${offset} (${records.length.toLocaleString()} so far)...\r`);
+
+ let result;
+ for (let attempt = 0; attempt < 3; attempt++) {
+ try {
+ result = await fetchPage(offset);
+ break;
+ } catch (e) {
+ console.warn(`\n Error on page ${page} attempt ${attempt+1}: ${e.message}`);
+ if (attempt === 2) throw e;
+ await new Promise(r => setTimeout(r, 2000 * (attempt + 1)));
+ }
+ }
+
+ const features = result.features || [];
+ for (const f of features) {
+ const a = f.attributes || {};
+ records.push({
+ id: a.OBJECTID,
+ damage: a.DAMAGE,
+ structureType: a.STRUCTURETYPE,
+ structureCategory: a.STRUCTURECATEGORY,
+ city: a.CITY,
+ county: a.COUNTY,
+ state: a.STATE,
+ community: a.COMMUNITY,
+ incident: a.INCIDENTNAME,
+ incidentDate: a.INCIDENTSTARTDATE ? new Date(a.INCIDENTSTARTDATE).toISOString().slice(0, 10) : null,
+ lat: a.LATITUDE,
+ lng: a.LONGITUDE
+ });
+ }
+
+ if (features.length < PAGE_SIZE) break; // last page
+ offset += features.length;
+
+ // Small pause to be polite to the public API
+ await new Promise(r => setTimeout(r, 100));
+ }
+
+ console.log(`\nFetched ${records.length.toLocaleString()} records total.`);
+
+ // Compute community stats
+ const byCity = {};
+ for (const r of records) {
+ const key = (r.city || r.community || 'Unknown').trim();
+ if (!byCity[key]) {
+ byCity[key] = {
+ city: key,
+ county: r.county,
+ state: r.state,
+ incidents: new Set(),
+ firstDate: r.incidentDate,
+ lastDate: r.incidentDate,
+ total: 0,
+ damaged: 0, // includes all damage categories
+ counts: {}
+ };
+ }
+ const c = byCity[key];
+ c.total++;
+ if (r.incident) c.incidents.add(r.incident);
+ if (r.incidentDate) {
+ if (!c.firstDate || r.incidentDate < c.firstDate) c.firstDate = r.incidentDate;
+ if (!c.lastDate || r.incidentDate > c.lastDate) c.lastDate = r.incidentDate;
+ }
+ const dmg = r.damage || 'Unknown';
+ c.counts[dmg] = (c.counts[dmg] || 0) + 1;
+ if (dmg !== 'No Damage') c.damaged++;
+ }
+
+ // Serialize (convert Set to Array)
+ const communities = Object.values(byCity).map(c => ({
+ ...c,
+ incidents: [...c.incidents].sort()
+ })).sort((a, b) => {
+ // Sort by destroyed count desc, then total desc
+ const ad = a.counts['Destroyed (>50%)'] || 0;
+ const bd = b.counts['Destroyed (>50%)'] || 0;
+ return bd - ad || b.total - a.total;
+ });
+
+ const destroyed = records.filter(r => r.damage === 'Destroyed (>50%)').length;
+
+ const output = {
+ fetchedAt: new Date().toISOString(),
+ source: 'CAL FIRE DINS Master Data (services1.arcgis.com/jUJYIo9tSA7EHvfZ/POSTFIRE_MASTER_DATA_SHARE)',
+ totalRecords: records.length,
+ totalCities: communities.length,
+ destroyedCount: destroyed,
+ communities,
+ records
+ };
+
+ fs.writeFileSync(OUT_FILE, JSON.stringify(output, null, 2));
+ console.log(`Saved ${OUT_FILE}`);
+ console.log(` ${communities.length} communities, ${destroyed.toLocaleString()} destroyed structures`);
+}
+
+main().catch(e => { console.error('FATAL:', e.message); process.exit(1); });
diff --git a/server.js b/server.js
new file mode 100644
index 0000000..596ef70
--- /dev/null
+++ b/server.js
@@ -0,0 +1,174 @@
+#!/usr/bin/env node
+// firecities server.js — California Fire Communities DINS viewer
+// Local only — no deploy. Serves on a free port between 9970–9975.
+
+const express = require('express');
+const fs = require('fs');
+const path = require('path');
+const net = require('net');
+
+const DATA_FILE = path.join(__dirname, 'data', 'dins.json');
+const PUBLIC_DIR = path.join(__dirname, 'public');
+
+// ── Port discovery ───────────────────────────────────────────────────────────
+function portFree(p) {
+ return new Promise(resolve => {
+ const s = net.createServer();
+ s.listen(p, () => { s.close(() => resolve(true)); });
+ s.on('error', () => resolve(false));
+ });
+}
+
+async function findPort(start = 9970, end = 9979) {
+ for (let p = start; p <= end; p++) {
+ if (await portFree(p)) return p;
+ }
+ throw new Error(`No free port found between ${start}–${end}`);
+}
+
+// ── Data cache ───────────────────────────────────────────────────────────────
+let DINS = null;
+
+function loadData() {
+ if (DINS) return DINS;
+ if (!fs.existsSync(DATA_FILE)) return null;
+ try {
+ DINS = JSON.parse(fs.readFileSync(DATA_FILE, 'utf8'));
+ return DINS;
+ } catch (e) {
+ console.error('Failed to parse', DATA_FILE, e.message);
+ return null;
+ }
+}
+
+// ── Express app ──────────────────────────────────────────────────────────────
+const app = express();
+app.use(express.static(PUBLIC_DIR));
+
+// /api/status — health check + data availability
+app.get('/api/status', (req, res) => {
+ const d = loadData();
+ if (!d) {
+ return res.json({
+ ok: false,
+ message: 'DINS data not loaded. Run: node scripts/fetch-dins.js --limit=5000',
+ dataFile: DATA_FILE
+ });
+ }
+ res.json({
+ ok: true,
+ fetchedAt: d.fetchedAt,
+ totalRecords: d.totalRecords,
+ totalCities: d.totalCities,
+ destroyedCount: d.destroyedCount,
+ source: d.source
+ });
+});
+
+// /api/communities — aggregated stats per city/community
+// Query params: sort, damage, county, q (search), limit, offset
+app.get('/api/communities', (req, res) => {
+ const d = loadData();
+ if (!d) return res.status(503).json({ error: 'Data not available. Run fetch-dins.js first.' });
+
+ let communities = d.communities.slice();
+
+ // Filter: text search on city name
+ if (req.query.q) {
+ const q = req.query.q.toLowerCase();
+ communities = communities.filter(c => c.city.toLowerCase().includes(q));
+ }
+
+ // Filter: county
+ if (req.query.county) {
+ const county = req.query.county.toLowerCase();
+ communities = communities.filter(c => (c.county || '').toLowerCase().includes(county));
+ }
+
+ // Filter: must have at least one structure of this damage level
+ if (req.query.damage) {
+ const dmg = req.query.damage;
+ communities = communities.filter(c => (c.counts[dmg] || 0) > 0);
+ }
+
+ // Sort
+ const sort = req.query.sort || 'destroyed';
+ if (sort === 'destroyed') {
+ communities.sort((a, b) => (b.counts['Destroyed (>50%)'] || 0) - (a.counts['Destroyed (>50%)'] || 0));
+ } else if (sort === 'total') {
+ communities.sort((a, b) => b.total - a.total);
+ } else if (sort === 'name') {
+ communities.sort((a, b) => a.city.localeCompare(b.city));
+ } else if (sort === 'county') {
+ communities.sort((a, b) => (a.county || '').localeCompare(b.county || '') || a.city.localeCompare(b.city));
+ } else if (sort === 'date') {
+ communities.sort((a, b) => (b.lastDate || '').localeCompare(a.lastDate || ''));
+ }
+
+ const limit = Math.min(parseInt(req.query.limit, 10) || 500, 1000);
+ const offset = parseInt(req.query.offset, 10) || 0;
+ const page = communities.slice(offset, offset + limit);
+
+ res.json({
+ total: communities.length,
+ offset,
+ limit,
+ communities: page
+ });
+});
+
+// /api/structures — individual structure records for a city
+app.get('/api/structures', (req, res) => {
+ const d = loadData();
+ if (!d) return res.status(503).json({ error: 'Data not available. Run fetch-dins.js first.' });
+
+ const city = (req.query.city || '').trim();
+ if (!city) return res.status(400).json({ error: 'city param required' });
+
+ const records = (d.records || []).filter(r => (r.city || r.community || '').trim() === city);
+ const limit = Math.min(parseInt(req.query.limit, 10) || 500, 5000);
+ const offset = parseInt(req.query.offset, 10) || 0;
+
+ // Optional damage filter
+ let filtered = records;
+ if (req.query.damage) {
+ filtered = records.filter(r => r.damage === req.query.damage);
+ }
+
+ res.json({
+ city,
+ total: filtered.length,
+ offset,
+ limit,
+ structures: filtered.slice(offset, offset + limit)
+ });
+});
+
+// /api/counties — list distinct counties
+app.get('/api/counties', (req, res) => {
+ const d = loadData();
+ if (!d) return res.status(503).json({ error: 'Data not available.' });
+ const counties = [...new Set(d.communities.map(c => c.county).filter(Boolean))].sort();
+ res.json({ counties });
+});
+
+// ── Start ────────────────────────────────────────────────────────────────────
+findPort().then(port => {
+ app.listen(port, () => {
+ console.log(`\n🔥 CA Fire Communities DINS Viewer`);
+ console.log(` http://localhost:${port}`);
+ console.log(` API: http://localhost:${port}/api/status`);
+ const d = loadData();
+ if (d) {
+ console.log(` Data: ${d.totalRecords?.toLocaleString()} structures / ${d.totalCities} communities`);
+ console.log(` Destroyed (>50%): ${d.destroyedCount?.toLocaleString()}`);
+ } else {
+ console.log(` ⚠ No data yet. Run: node scripts/fetch-dins.js --limit=5000`);
+ }
+ // Write port to a file for easy discovery
+ fs.writeFileSync(path.join(__dirname, '.port'), String(port));
+ });
+}).catch(e => {
+ console.error('Failed to start:', e.message);
+ process.exit(1);
+});
(oldest)
·
back to Firecities
·
href-drill: add drill primitives to firecities (TK-10903) 9477ec9 →