Oregami
Repositories/oxedyne/fe2o3

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.
4import gzip, sys, json
5sys.path.insert(0, 'site')
6from pmtiles.writer import write
7from pmtiles.tile import zxy_to_tileid, TileType, Compression
8
9OUT = sys.argv[1]
10SRC = sys.argv[2]
11tiles = {}
12for (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)
14ocean = gzip.compress(open(f'{SRC}/protomaps_12_2958_2545.mvt', 'rb').read(), mtime=0)
15base = zxy_to_tileid(12, 2958, 2545)
16for k in range(3):
17 tiles[base + k] = ocean
18with 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'})
27print(OUT, [ (t, len(tiles[t])) for t in sorted(tiles)])