X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/e747b6c82a1b75ae654682ae8ba2057c9fc13521..5fde77fb90280da2c008bb5e8e83f6635b999715:/cookbooks/tile/files/default/bin/expire-tiles-single diff --git a/cookbooks/tile/files/default/bin/expire-tiles-single b/cookbooks/tile/files/default/bin/expire-tiles-single index 219c45dd4..431021b2e 100644 --- a/cookbooks/tile/files/default/bin/expire-tiles-single +++ b/cookbooks/tile/files/default/bin/expire-tiles-single @@ -12,8 +12,7 @@ EXPIRY_TIME = 946681200 # 2000-01-01 00:00:00 # width/height of the spherical mercator projection SIZE = 40075016.6855784 -proj_wsg84 = pyproj.Proj(init='epsg:4326') -proj_merc = pyproj.Proj(init='epsg:3857') +proj_transformer = pyproj.Transformer.from_crs('epsg:4326', 'epsg:3857', always_xy = True) class TileCollector(o.SimpleHandler): @@ -29,7 +28,7 @@ class TileCollector(o.SimpleHandler): return lat = max(-85, min(85.0, location.lat)) - x, y = pyproj.transform(proj_wsg84, proj_merc, location.lon, lat) + x, y = proj_transformer.transform(location.lon, lat) # renormalise into unit space [0,1] x = 0.5 + x / SIZE @@ -81,9 +80,10 @@ def xyz_to_meta(x, y, z, meta_size): def expire_meta(meta): """Expire the meta tile by setting the modified time back. """ - if os.path.exists(meta): - print("Expiring " + meta) + exists = os.path.exists(meta) + if exists: os.utime(meta, (EXPIRY_TIME, EXPIRY_TIME)) + return exists def expire_meta_tiles(options): @@ -107,8 +107,11 @@ def expire_meta_tiles(options): new_set.add((int(xy[0]/2), int(xy[1]/2), xy[2] - 1)) # expire all meta tiles + expired = 0 for meta in meta_set: - expire_meta(meta) + if expire_meta(meta): + expired += 1 + print("Expired {0} tiles at zoom {1}".format(expired, z)) # continue with parent tiles tile_set = new_set