|
| 1 | +""" |
| 2 | +Build conflated.pmtiles from the conflated POI dataset. |
| 3 | +
|
| 4 | +Output is a single-zoom PMTiles archive (z14) keyed by the config's |
| 5 | +``upload.pmtiles`` block. OpenLayers over-zooms z15-20 natively, and the site |
| 6 | +never renders below z14, so tiling extra zoom levels would just waste disk and |
| 7 | +wall time. |
| 8 | +
|
| 9 | +Intermediate FlatGeobuf is staged next to the output and deleted on success. |
| 10 | +""" |
| 11 | +from config_versioned import Config |
| 12 | + |
| 13 | +from openpois.io.pmtiles import build_pmtiles |
| 14 | + |
| 15 | +# ----------------------------------------------------------------------------- |
| 16 | +# Configuration |
| 17 | +# ----------------------------------------------------------------------------- |
| 18 | + |
| 19 | +config = Config("~/repos/openpois/config.yaml") |
| 20 | + |
| 21 | +INPUT_PATH = config.get_file_path("conflation", "conflated") |
| 22 | +OUTPUT_PATH = config.get_file_path("conflation", "pmtiles") |
| 23 | + |
| 24 | +LAYER_NAME = config.get("upload", "pmtiles", "conflated_layer_name") |
| 25 | +PROPERTIES = config.get("upload", "pmtiles", "conflated_properties") |
| 26 | +MIN_ZOOM = config.get("upload", "pmtiles", "min_zoom") |
| 27 | +MAX_ZOOM = config.get("upload", "pmtiles", "max_zoom") |
| 28 | +DROP_STRATEGY = config.get("upload", "pmtiles", "drop_strategy") |
| 29 | + |
| 30 | +# ----------------------------------------------------------------------------- |
| 31 | +# Main workflow |
| 32 | +# ----------------------------------------------------------------------------- |
| 33 | + |
| 34 | +if __name__ == "__main__": |
| 35 | + print(f"Building conflated PMTiles from {INPUT_PATH}") |
| 36 | + print(f" layer: {LAYER_NAME}") |
| 37 | + print(f" zooms: Z{MIN_ZOOM}-z{MAX_ZOOM}") |
| 38 | + print(f" drop: --{DROP_STRATEGY}") |
| 39 | + print(f" props: {', '.join(PROPERTIES)}") |
| 40 | + print(f" -> {OUTPUT_PATH}") |
| 41 | + |
| 42 | + stats = build_pmtiles( |
| 43 | + input_parquet = INPUT_PATH, |
| 44 | + output_pmtiles = OUTPUT_PATH, |
| 45 | + layer_name = LAYER_NAME, |
| 46 | + properties = PROPERTIES, |
| 47 | + min_zoom = MIN_ZOOM, |
| 48 | + max_zoom = MAX_ZOOM, |
| 49 | + drop_strategy = DROP_STRATEGY, |
| 50 | + ) |
| 51 | + |
| 52 | + print( |
| 53 | + f"Done. Wrote {stats['rows_written']:,} features, " |
| 54 | + f"{stats['pmtiles_bytes'] / 1e9:.2f} GB PMTiles." |
| 55 | + ) |
0 commit comments