INNER CODE UNIT · Python

prepare_combos

Zverik/every_door · tools/add_taginfo.py:22

def prepare_combos(cur, tcur):
    cur.execute("create table combos (key text primary key, options text)")

    # 1. Values for keys
    cur.execute(
        "select distinct key from fields where typ in ('combo', 'typeCombo', 'semiCombo')")
    keys = [row[0] for row in cur]
    # Querying for all keys at once: we've got around 240, and sqlite supports up to 999.
    tcur.execute(
        """select key, value, count_nodes + count_ways from tags
        where key in ({}) and count_all >= 30"""
        .format(','.join('?' * len(keys))), keys)
    values = defaultdict(dict)  # key: {value: count}
    for row in tcur:
        if row[0] in KEEP_SEMICOLON:
            values[row[0]][row[1]] = row[2]
        else:
            for v in row[1].split(';'):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…