Get a structured dataset out of
       http://download.geonames.org/export/dump/cities1000.txt

def build_db():
    """Get a structured dataset out of
       http://download.geonames.org/export/dump/cities1000.txt
    """
    if not os.path.exists(MISC_PATH):
        os.makedirs(MISC_PATH)
    cities_path = os.path.join(MISC_PATH, "cities1000.txt")
    cities_msgpack = os.path.join(MISC_PATH, "cities1000.bin")
    if not os.path.isfile(cities_path):
        download()
    if not os.path.isfile(cities_msgpack):
        with open(cities_path) as f:
            lines = f.readlines()

        db = []
        for i, line in enumerate(lines):
            l = line.strip().split('\t')
            db.append({'latitude': float(l[4]),
                       'longitude': float(l[5]),
                       'linenr': i})
        packed = msgpack.packb(db, use_bin_type=True)
        with open(cities_msgpack, 'wb') as f:
            f.write(packed)
    else:
        with open(cities_msgpack, 'rb') as f:
            content = f.read()
        db = msgpack.unpackb(content)
    return db