| … | … | @@ -137,6 +137,10 @@ def main(): |
| 137 | 137 | ap.add_argument("--ty", type=int, default=None) |
| 138 | 138 | ap.add_argument("--out", default="/tmp/block.hblk") |
| 139 | 139 | ap.add_argument("--list", action="store_true") |
| 140 | ap.add_argument("--per-tile", metavar="OUTDIR", |
| 141 | help="write ONE .hblk per cached tile into OUTDIR") |
| 142 | ap.add_argument("--limit", type=int, default=0, |
| 143 | help="with --per-tile, stop after N tiles (0 = all)") |
| 140 | 144 | a = ap.parse_args() |
| 141 | 145 | |
| 142 | 146 | tiles = cached_tiles() |
| … | … | @@ -148,6 +152,32 @@ def main(): |
| 148 | 152 | + (f" e.g. --tx {s[len(s)//2][0]} --ty {s[len(s)//2][1]}" if s else "")) |
| 149 | 153 | return |
| 150 | 154 | |
| 155 | if a.per_tile: |
| 156 | # ONE TILE PER FILE, because the tile set is INCOMPLETE and GROWS. |
| 157 | # |
| 158 | # A stitched block is a SNAPSHOT: it fixes which tiles exist at bake |
| 159 | # time, and the 900 km world is 14,161 tiles of which 841 are generated. |
| 160 | # There is no solid 119x119 to stitch and there will not be one for a |
| 161 | # long time, so the engine has to load a LIST of tiles and treat the |
| 162 | # gaps as stubs rather than load one rectangle. |
| 163 | # |
| 164 | # Each file keeps its own 1 px apron and its own world origin, so a tile |
| 165 | # is self-describing and can be added at runtime without touching any |
| 166 | # other file. |
| 167 | os.makedirs(a.per_tile, exist_ok=True) |
| 168 | origins = sorted(tiles) |
| 169 | if a.limit: |
| 170 | origins = origins[:a.limit] |
| 171 | n_ok = 0 |
| 172 | for (tx, ty) in origins: |
| 173 | arr, ox, oz = stitch(tx, ty, 1) |
| 174 | write_hblk(os.path.join(a.per_tile, f"tile_{tx}_{ty}.hblk"), arr, ox, oz) |
| 175 | n_ok += 1 |
| 176 | print(f"wrote {n_ok} per-tile .hblk to {a.per_tile}") |
| 177 | print(f" each {arr.shape[0]}x{arr.shape[0]} px " |
| 178 | f"({TILE_PX}+2 apron) = {TILE_PX*MPP/1000:.2f} km of payload") |
| 179 | return |
| 180 | |
| 151 | 181 | if a.tx is None or a.ty is None: |
| 152 | 182 | s = solid_origins(tiles, a.n) |
| 153 | 183 | if not s: |