Answer architecture round 3: fence's docstring says a locality needs entries in both child maps, and zcta_localities says what it maps to
This commit is contained in:
@@ -186,9 +186,9 @@ def main():
|
||||
regions = {c: {"code": c, "name": n, "population": population[c], "timezone": TIMEZONE} for c, n in region_names.items()}
|
||||
municipalities = {c: {"code": c, "name": n, "region": c[:2], "population": population[c]} for c, n in municipality_names.items()}
|
||||
kept, dropped = geo.fence(regions, municipalities, places, named, {k: l["codes"] for k, l in places.items()})
|
||||
geo.log_dropped(dropped["locality"], "no street or postal code")
|
||||
if dropped["municipality"]:
|
||||
sys.exit(f"municipalities without a locality: {sorted(dropped['municipality'])}")
|
||||
geo.log_dropped_localities(dropped["locality"])
|
||||
if dropped["municipality"] or dropped["region"]:
|
||||
sys.exit(f"left without a child: municipalities {sorted(dropped['municipality'])}, regions {sorted(dropped['region'])}")
|
||||
places = kept["locality"]
|
||||
|
||||
tsv.write(out / "region.tsv", ["code", "name", "population", "timezone"], [r for _, r in sorted(kept["region"].items())])
|
||||
|
||||
Reference in New Issue
Block a user