// Load the county GIS Public School layer → enrollment_gis and // fish_capacity_permanent_gis, stored under 2024-25 (the count date the // ENROLLMNT field was measured to reflect; findings.md M.5). // Run: npx tsx scripts/loaders/miami/gis_schoolsite.ts import fs from "node:fs"; import { requireSource, startDataLoad, finishDataLoad, padSchoolNumber, schoolUniverse, upsertFacts, runMain, type Fact } from "./_lib"; const SCRIPT_PATH = "scripts/loaders/miami/gis_schoolsite.ts"; const SOURCE_ID = "mdc_gis_schoolsite"; const YEAR = "2024-25"; async function main() { const { filePath, prov } = requireSource(SOURCE_ID); const universe = await schoolUniverse(); const json = JSON.parse(fs.readFileSync(filePath, "utf-8")) as { features: { attributes: Record }[] }; const facts: Fact[] = []; let matched = 0; for (const f of json.features) { const num = padSchoolNumber(f.attributes.ID); if (!num || !universe.has(num)) continue; matched++; const cap = Number(f.attributes.CAPACITY); const enr = Number(f.attributes.ENROLLMNT); if (Number.isFinite(cap) && cap > 0) facts.push({ schoolNumber: num, year: YEAR, metricKey: "fish_capacity_permanent_gis", value: cap }); if (Number.isFinite(enr) && enr > 0) facts.push({ schoolNumber: num, year: YEAR, metricKey: "enrollment_gis", value: enr }); } const load = await startDataLoad({ sourceId: SOURCE_ID, sourceUrl: prov.url, sha256: prov.sha256, bytes: prov.bytes, yearCovered: YEAR, scriptPath: SCRIPT_PATH, notes: "ENROLLMNT vintage inferred as 2024-25 (between CCD Oct 2023 and the board's 2025-26 figures); CAPACITY = permanent FISH capacity for 200 of the 326 schools with both (61%; the first-fetch spot check found 7 of 9)." }); const res = await upsertFacts(facts, load.id); await finishDataLoad(load.id, { inserted: res.written, updated: 0, suppressed: 0 }, `${matched} of ${json.features.length} points matched the directory`); console.log(`[gis] ${res.written} facts for ${matched} schools`); } runMain(main);