oxedyne/fe2o3/fe2o3_geom/tests/data/protomaps/make_sample.py
1.3 KiB, 1 run
created by r1870400018:60832, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | # A small real PMTiles archive, written by the reference Python writer (pmtiles 3.8.1), |
| 2 | # holding real Protomaps tiles: two Perth tiles and one open-ocean content addressed as a run |
| 3 | # of three. Tiles are stored gzipped, as the planet stores them. |
| 4 | import gzip, sys, json |
| 5 | sys.path.insert(0, 'site') |
| 6 | from pmtiles.writer import write |
| 7 | from pmtiles.tile import zxy_to_tileid, TileType, Compression |
| 8 | |
| 9 | OUT = sys.argv[1] |
| 10 | SRC = sys.argv[2] |
| 11 | tiles = {} |
| 12 | for (z, x, y) in [(15, 26930, 19457), (13, 6729, 4865)]: |
| 13 | tiles[zxy_to_tileid(z, x, y)] = gzip.compress(open(f'{SRC}/protomaps_{z}_{x}_{y}.mvt', 'rb').read(), mtime=0) |
| 14 | ocean = gzip.compress(open(f'{SRC}/protomaps_12_2958_2545.mvt', 'rb').read(), mtime=0) |
| 15 | base = zxy_to_tileid(12, 2958, 2545) |
| 16 | for k in range(3): |
| 17 | tiles[base + k] = ocean |
| 18 | with write(OUT) as w: |
| 19 | for tid in sorted(tiles): |
| 20 | w.write_tile(tid, tiles[tid]) |
| 21 | w.finalize({ |
| 22 | 'tile_type': TileType.MVT, 'tile_compression': Compression.GZIP, |
| 23 | 'min_lon_e7': 1156000000, 'min_lat_e7': -326000000, |
| 24 | 'max_lon_e7': 1163000000, 'max_lat_e7': -316000000, |
| 25 | 'center_zoom': 13, 'center_lon_e7': 1158571000, 'center_lat_e7': -319535000, |
| 26 | }, {'attribution': '© OpenStreetMap contributors', 'name': 'fe2o3 sample'}) |
| 27 | print(OUT, [ (t, len(tiles[t])) for t in sorted(tiles)]) |