|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -euo pipefail |
3 | 3 |
|
4 | | -REL="${1:-2026-02-18.0}" |
5 | | -BBOX="${2:-7.408446,43.722901,7.4405,43.752481}" |
6 | | -OUT="data/sources/${3:-monaco.parquet}" |
| 4 | +STAC_CATALOG="https://stac.overturemaps.org/catalog.json" |
| 5 | +DEFAULT_BBOX="7.408446,43.722901,7.4405,43.752481" |
| 6 | +DEFAULT_OUT="data/sources/monaco.parquet" |
| 7 | + |
| 8 | +usage() { |
| 9 | + cat <<EOF |
| 10 | +Usage: $0 [RELEASE] [BBOX] [OUTPUT] |
| 11 | +
|
| 12 | +Downloads Overture Maps data for a bounding box as a Parquet file. |
| 13 | +
|
| 14 | +Arguments: |
| 15 | + RELEASE Overture release version (default: latest, from ${STAC_CATALOG}) |
| 16 | + BBOX xmin,ymin,xmax,ymax in WGS84 (default: ${DEFAULT_BBOX}) |
| 17 | + OUTPUT Output file path (default: ${DEFAULT_OUT}) |
| 18 | +
|
| 19 | +Example: |
| 20 | + $0 2026-06-17.0 -122.52,37.70,-122.35,37.83 data/sources/sf.parquet |
| 21 | +EOF |
| 22 | +} |
| 23 | + |
| 24 | +latest_release() { |
| 25 | + # A network failure yields empty output rather than aborting under `set -e`, |
| 26 | + # so the caller can report it. |
| 27 | + duckdb -noheader -list -c \ |
| 28 | + "SELECT latest FROM read_json('${STAC_CATALOG}')" 2>/dev/null || true |
| 29 | +} |
| 30 | + |
| 31 | +if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then |
| 32 | + usage |
| 33 | + exit 0 |
| 34 | +fi |
| 35 | + |
| 36 | +REL="${1:-$(latest_release)}" |
| 37 | +if [[ -z "$REL" ]]; then |
| 38 | + echo "Could not determine the latest release from ${STAC_CATALOG}; pass one explicitly." >&2 |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | +BBOX="${2:-$DEFAULT_BBOX}" |
| 42 | +OUT="${3:-$DEFAULT_OUT}" |
7 | 43 |
|
8 | 44 | IFS=',' read -r XMIN YMIN XMAX YMAX <<< "$BBOX" |
9 | 45 |
|
|
0 commit comments