Answer product-owner round 1: a Swedish street is a street's name, Lexington, Ventura and Lynchburg ship by their postal names, and the README names Honolulu

This commit is contained in:
2026-10-11 19:02:37 +02:00
committed by Lillem4n
parent d3d9547876
commit 5cfa89c8ab
5 changed files with 14 additions and 40 deletions
+11 -1
View File
@@ -38,6 +38,10 @@ TIMEZONE = "Europe/Stockholm"
ONE_POSITION = {"Stockholm", "Göteborg", "Malmö"}
# A tätort's floor: "minst 200 invånare", docs/research/research-geo-se.md, Lantmäteriet → Ortnamn.
UNMATCHED_POPULATION = 200
# Not a street: a road number, a ferry route, a cycle path or road association's label, a placeholder, or two names
# or a description in one.
NOT_A_STREET = re.compile(r"^(Europaväg|Länsväg|Riksväg) \d|^Färjeled |\b(GC|SMF|VSF)\b|^NN$|, ")
PARTICLES = {"af", "de", "von"}
def scb_codes(cache):
@@ -161,12 +165,18 @@ def localities(codes, tatorter, municipalities, population):
return out
def street_name(name):
"""Whether name is a street's, opening with a capital or a nobiliary particle and with no word spelled in capitals."""
opening = name[0].isupper() or name.split()[0] in PARTICLES
return opening and not NOT_A_STREET.search(name) and not any(len(w) >= 5 and w.isupper() for w in name.split())
def streets(segments, codes, localities, share, minimum):
"""The names with most segments per locality, each segment at its nearest code centroid."""
nearest = geo.Nearest((r["lat"], r["lon"], r["locality"]) for r in codes if r["lat"] is not None and r["locality"] in localities)
count = collections.Counter()
for name, lat, lon in segments:
if name[0].isalpha():
if street_name(name):
count[(nearest.find(lat, lon), name)] += 1
return geo.top_streets(count, share, minimum, "segments")