Fetch2.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Trending-Places-in-OpenStreetMap 作者: geometalab 项目源码 文件源码
def process_item(out, min_cache_zoom, cache, link,
                 part_zoom, tiled_countries, all_countries,
                 min_zoom, max_zoom, skip_empty_tiles):
    stat = Stat()
    date = get_date_from_link(link)

    for line in lzma.LZMAFile(get_tile_usage_dump(link)):
        path, count = line.decode().strip().split()
        z, x, y = path.split('/')

        x = int(x)
        y = int(y)
        z = int(z)

        if min_zoom is not None and z < min_zoom:
            continue
        if max_zoom is not None and z > max_zoom:
            continue

        twest, tsouth, teast, tnorth = b = mercantile.bounds(x, y, z)
        country = detect_country_with_cache(
            path, b, x, y, z, part_zoom, tiled_countries, all_countries,
            min_cache_zoom, cache, stat)

        if skip_empty_tiles and country == '??':
            continue

        lat = tnorth + (tnorth - tsouth) / 2
        lon = twest + (teast - twest) / 2

        out.write(('%s,%s,%s,%s,%s,%s,%s,%s\n' % (
            date, z, x, y, count, lat, lon, country)).encode())
    stat.log_stats(date, cache)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号