Skip to content

armgit / Aleph

Public Imported from GitHub
0

Give satellite imagery, terrain data, buildings, streetview photos to your LLM

Fix tiles size mismatch + UI

Belluxx3d33cbb4ee9b
diff --git a/src/assets/app.js b/src/assets/app.js
index b2e3436..208acaf 100644
--- a/src/assets/app.js
+++ b/src/assets/app.js
@@ -135,7 +135,7 @@ function renderLibrary() {
const fragment = document.createDocumentFragment();
for (const run of state.captures) {
const currentJob = visibleJob && state.job.run_id === run.id;
- const status = currentJob ? state.job.state : run.state;
+ const status = state.job?.run_id === run.id ? state.job.state : run.state;
const coordinates = center(run.bounds).map((v) => v.toFixed(5)).join(", ");
if (term && !currentJob && !`${run.id} ${date(run.started_at)} ${coordinates} ${status}`.toLowerCase().includes(term)) continue;
const card = node("article", undefined, `capture-card${state.selected?.id === run.id ? " active" : ""}`);
@@ -150,7 +150,7 @@ function renderLibrary() {
button.append(heading, node("div", coordinates, "card-coordinates"), sources);
button.addEventListener("click", () => selectCapture(run.id).catch((error) => notice(error.message)));
const available = {
- resume: run.state !== "complete" || !run.exports_saved,
+ resume: status !== "complete",
export: Object.values(run.layers).some((layer) => layer.done),
};
const actions = $("capture-actions").content.firstElementChild.cloneNode(true);
@@ -199,9 +199,14 @@ async function refreshLibrary(initial = false) {
state.refreshing = true;
try {
const data = await api("/api/captures");
+ const changed = data.captures.length !== state.captures.length || data.captures.some((run, index) => {
+ const previous = state.captures[index];
+ return run.id !== previous.id || run.state !== previous.state || run.exports_saved !== previous.exports_saved;
+ });
state.captures = data.captures;
state.lastRefresh = Date.now();
- renderLibrary();
+ // Keep the active progress bar attached so polling does not restart its animation.
+ if (!state.job?.active || changed) renderLibrary();
if (initial && data.errors.length) notice(`${data.errors.length} capture folder(s) could not be read: ${data.errors[0].id}: ${data.errors[0].error}`);
if (state.composing) return;
if (initial && state.captures.length) await selectCapture(state.captures[0].id);
@@ -699,11 +704,8 @@ function renderCapturePanel() {
$("start-capture").hidden = planning;
if (planning) {
const job = state.job;
- $("planning-phase").textContent = job.total > 0 ? `${job.phase}: ${job.done.toLocaleString()} of ${job.total.toLocaleString()}` : job.phase;
- if (job.total > 0) {
- $("planning-meter").max = job.total;
- $("planning-meter").value = job.done;
- } else $("planning-meter").removeAttribute("value");
+ $("planning-phase").textContent = job.phase;
+ renderProgress("planning-meter", "planning-detail", job);
$("stop-planning").disabled = !job.active || job.state === "stopping";
}
const sources = form.querySelectorAll('input[name="include"]:checked').length;
@@ -1023,26 +1025,37 @@ async function confirmCapture() {
}
}
+function renderProgress(meterId, detailId, job) {
+ const meter = $(meterId);
+ const measured = job.total > 0;
+ const done = job.done || 0;
+ const percent = measured ? `${Math.floor(Math.max(0, Math.min(100, done / job.total * 100)))}%` : "—%";
+ let detail = measured ? `${done.toLocaleString()} / ${job.total.toLocaleString()}` : "Working…";
+ if (job.unit === "bytes") {
+ const mb = (value) => (value / 1_000_000).toLocaleString(undefined, {minimumFractionDigits: 1, maximumFractionDigits: 1});
+ detail = `${mb(done)} MB / ${measured ? mb(job.total) : "—"} MB`;
+ }
+ if (measured) {
+ meter.max = job.total;
+ meter.value = done;
+ } else meter.removeAttribute("value");
+ $(`${meterId}-percent`).textContent = percent;
+ $(detailId).textContent = detail;
+ meter.setAttribute("aria-valuetext", measured ? `${percent}, ${detail}` : detail);
+}
+
function renderJob(job) {
const previous = state.job;
state.job = job;
const panel = $("job");
const wasHidden = panel.hidden;
- panel.hidden = job.kind === "plan" || job.state === "idle";
+ panel.hidden = job.kind === "plan" || job.state === "idle" || job.state === "complete";
// Only announce changed phase text, not every polling response.
const phase = job.phase;
if ($("job-phase").textContent !== phase) $("job-phase").textContent = phase;
$("job-phase").title = phase;
- const measured = job.total > 0;
- const done = job.state === "complete" ? job.total : (job.done || 0);
$("job-meter").hidden = !job.active;
- $("job-detail").textContent = measured ? `${done.toLocaleString()} / ${job.total.toLocaleString()}` : "Working…";
- if (!measured && job.active) $("job-progress").removeAttribute("value");
- else {
- $("job-progress").max = job.total || 1;
- $("job-progress").value = done || 0;
- }
- $("job-progress").setAttribute("aria-valuetext", measured ? `Current step: ${done.toLocaleString()} of ${job.total.toLocaleString()}` : "Working");
+ renderProgress("job-progress", "job-detail", job);
$("stop-job").hidden = !job.active;
$("stop-job").disabled = job.state === "stopping";
const stopLabel = job.state === "stopping" ? "Stopping capture…" : "Stop capture";
diff --git a/src/assets/index.html b/src/assets/index.html
index 139ca82..0d2ac1d 100644
--- a/src/assets/index.html
+++ b/src/assets/index.html
@@ -62,8 +62,11 @@
<section id="job" class="job" aria-label="Capture progress" hidden>
<div class="job-summary" role="status" aria-atomic="true"><strong id="job-phase"></strong></div>
<div id="job-meter" class="job-meter">
- <progress id="job-progress" aria-labelledby="job-phase" aria-describedby="job-detail"></progress>
- <span id="job-detail"></span>
+ <div class="progress-row">
+ <progress id="job-progress" aria-labelledby="job-phase" aria-describedby="job-detail"></progress>
+ <span id="job-progress-percent" class="progress-percent" aria-hidden="true"></span>
+ </div>
+ <span id="job-detail" class="progress-detail"></span>
</div>
<div class="job-actions">
<button id="job-error" class="job-error" aria-label="Show capture error details" hidden>Details</button>
@@ -137,7 +140,11 @@
<p id="form-error" class="form-error" role="alert" hidden></p>
<section id="planning-progress" class="planning-progress" aria-label="Planning progress" hidden>
<strong id="planning-phase" role="status"></strong>
- <progress id="planning-meter" aria-labelledby="planning-phase"></progress>
+ <div class="progress-row">
+ <progress id="planning-meter" aria-labelledby="planning-phase" aria-describedby="planning-detail"></progress>
+ <span id="planning-meter-percent" class="progress-percent" aria-hidden="true"></span>
+ </div>
+ <span id="planning-detail" class="progress-detail"></span>
<button id="stop-planning" type="button">Stop planning</button>
</section>
<p id="capture-readiness" class="capture-readiness">Select an area on the map to continue.</p>
diff --git a/src/assets/style.css b/src/assets/style.css
index 5310fb8..0facc82 100644
--- a/src/assets/style.css
+++ b/src/assets/style.css
@@ -159,6 +159,9 @@ progress::-moz-progress-bar { background: var(--accent); }
progress:indeterminate { background: repeating-linear-gradient(135deg, var(--accent) 0 25%, var(--soft) 25% 50%); background-size: 16px 16px; animation: job-activity .8s linear infinite; }
progress:indeterminate::-webkit-progress-bar { background: transparent; }
progress:indeterminate::-moz-progress-bar { background: transparent; }
+.progress-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
+.progress-percent { min-width: 4ch; color: var(--muted); font: 9px var(--mono); text-align: right; }
+.progress-detail { color: var(--muted); font: 9px var(--mono); text-align: right; white-space: nowrap; }
a { color: inherit; text-underline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@@ -227,7 +230,6 @@ a { color: inherit; text-underline-offset: 3px; }
.card-actions .icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.job-meter { grid-column: 1 / -1; display: grid; gap: 6px; }
.job-error { border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
-#job-detail { color: var(--muted); font: 9px var(--mono); text-align: right; white-space: nowrap; }
/* Map controls */
.map-area { position: relative; flex: 1; min-height: 0; isolation: isolate; background: var(--map-background); }
diff --git a/src/capture.py b/src/capture.py
index 5eb00f9..cce020b 100644
--- a/src/capture.py
+++ b/src/capture.py
@@ -44,7 +44,7 @@ DEFAULT_OPTIONS = dict(
OSM_NOTES = {
"map": "OSM XML from Geofabrik with original tags and topology; coordinates are WGS84. Contributor names, IDs and changeset IDs are omitted by Geofabrik.",
"selection": "Selected ways are complete. Selected multipolygons include all available outer boundaries and holes, but members missing from the regional file remain unresolved. Other relations may also be incomplete. Objects may extend outside the rectangle; crossings without inside nodes and enclosing polygons may be absent.",
- "terrain": "Float32 heights in meters, EPSG:3857. Original compressed blocks retained without resampling. Full edge tiles extend beyond the rectangle. Tiles are checkpointed individually; terrain.tif is built after all terrain tiles are saved.",
+ "terrain": "Float32 heights in meters, EPSG:3857, without resampling. Full edge tiles extend beyond the rectangle. Tiles are checkpointed individually; terrain.tif is built after all terrain tiles are saved.",
"quality": "Terrain resolution, dates, accuracy and vertical reference vary by source. Higher zoom does not guarantee more detail.",
}
@@ -387,7 +387,7 @@ def save_preview(run, folder):
b"Photo headings are clockwise from north; left/right follow OSM node order.\n"
b"GeoJSON files record paths, photo locations, or satellite patch footprints.\n"
b"Satellite images are north-up Web Mercator, cropped to enclosing pixels.\n"
- b"terrain.tif is Float32 meters in EPSG:3857, with original source blocks.\n"
+ b"terrain.tif is Float32 meters in EPSG:3857, without resampling.\n"
b"Keep terrain/tiles/ for resume and offline export.\n"
b"Filenames in the manifest and GeoJSON are relative to this run folder.\n"
b"See manifest.json for settings, sources, imagery dates, and coverage notes.\n\n"
diff --git a/src/common.py b/src/common.py
index 8c4cbe4..86811c7 100644
--- a/src/common.py
+++ b/src/common.py
@@ -170,7 +170,7 @@ class Progress:
self.line = ""
self.width = 0
- def __call__(self, phase, done=0, total=None):
+ def __call__(self, phase, done=0, total=None, unit=None):
current = time.monotonic()
if self.phase != phase:
if not self.terminal:
@@ -183,6 +183,9 @@ class Progress:
eta = "--:--"
fraction = 0
steps = f"{done:,}/?" if total is None else f"{done:,}/{total:,}"
+ if unit == "bytes":
+ target = "?" if total is None else f"{total / 1_000_000:.1f}"
+ steps = f"{done / 1_000_000:.1f} MB / {target} MB"
if total is not None:
fraction = min(1, done / total) if total else 1
if done >= total:
@@ -199,7 +202,9 @@ class Progress:
else f"{minutes:02d}:{seconds:02d}"
)
- prefix, suffix = f"{phase} [", f"] {steps} - {eta}"
+ percent = f"{math.floor(fraction * 100)}%" if total is not None else "—%"
+ prefix = f"{phase} ["
+ suffix = f"] {percent} {steps}" + ("" if unit == "bytes" else f" - {eta}")
columns = shutil.get_terminal_size().columns - 1
width = min(24, max(1, columns - len(prefix) - len(suffix)))
full, part = divmod(int(fraction * width * 8), 8)
diff --git a/src/dashboard.py b/src/dashboard.py
index 74e7955..365f3bc 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -177,9 +177,9 @@ class Jobs:
self.update(state="stopping", phase="Stopping planning" if self.status.get("kind") == "plan" else "Saving progress")
raise KeyboardInterrupt()
- def progress(self, phase, done=0, total=None):
+ def progress(self, phase, done=0, total=None, unit=None):
self.cancel()
- self.update(phase=phase, done=done, total=total)
+ self.update(phase=phase, done=done, total=total, unit=unit)
def start(self, *, area=None, options=None, identity=None, plan_only=False, export_only=False,
plan_id=None):
@@ -234,7 +234,7 @@ class Jobs:
capture.export(run, folder, self.progress)
else:
capture.download(run, folder, client, self.progress)
- self.update(state="complete", phase="Exports rebuilt" if export_only else "Finished")
+ self.update(state="complete", phase="Complete")
except KeyboardInterrupt:
self.update(state="stopped", phase="Stopped")
except Exception as error:
diff --git a/src/osm.py b/src/osm.py
index 9c20eb4..e1f02e0 100644
--- a/src/osm.py
+++ b/src/osm.py
@@ -75,10 +75,10 @@ class Source:
refresh = self.client.refresh or not path.is_file()
with (atomic_path(path) if refresh else nullcontext(path)) as local:
if refresh:
- label = f"Downloading Geofabrik {props['name']} (regional file)"
- progress(label)
+ label = f"Downloading Geofabrik {props['name']}"
+ progress(label, 0, None, "bytes")
self.client.get(url, destination=local, timeout=180, user_agent=APP_AGENT,
- progress=lambda done, total: progress(label, done, total))
+ progress=lambda done, total: progress(label, done, total, "bytes"))
stamp = PBF(local, self.client.check_cancel).timestamp
self.regions[url] = path, dict(source_url=url, region=props["name"], osm_data_at=stamp or None)
return self.regions[url]
diff --git a/src/terrain.py b/src/terrain.py
index 74ffc15..1bd9463 100644
--- a/src/terrain.py
+++ b/src/terrain.py
@@ -1,17 +1,14 @@
-"""Join the provider's Float32 GeoTIFFs by copying their compressed blocks.
-
-Download tiles separately, then copy their blocks into one final mosaic.
-The intentionally narrow reader accepts only the provider's expected source format.
-"""
+"""Join Float32 GeoTIFFs, copying 256-pixel blocks and splitting larger ones."""
import math
import struct
+import zlib
from .common import atomic_path
from .geo import MERCATOR_RADIUS
TYPES = {1: "B", 2: "c", 3: "H", 4: "I", 5: "II", 11: "f", 12: "d"}
-COMPATIBLE = (258, 259, 262, 277, 284, 317, 322, 323, 339, 34735, 34736, 34737, 42113)
+COMPATIBLE = (258, 259, 262, 277, 284, 317, 339, 34735, 34736, 34737, 42113)
TIFF_LIMIT = 2**32
@@ -37,11 +34,13 @@ class TIFF:
size = struct.calcsize(self.order + TYPES[kind]) * length
raw = entry[8 : 8 + size] if size <= 4 else self.read(location, size)
self.tags[code] = kind, length, raw
- required = {258: 32, 339: 3, 277: 1, 262: 1, 322: 256, 323: 256}
+ required = {258: 32, 339: 3, 277: 1, 262: 1}
if any(self.value(key) != value for key, value in required.items()) or self.value(
259
) not in (1, 8, 32946):
raise ValueError("Expected tiled Float32 terrain.")
+ if (self.value(322), self.value(323)) not in ((256, 256), (512, 512)):
+ raise ValueError("Expected 256- or 512-pixel terrain blocks.")
if self.value(274, 1) != 1 or self.value(284, 1) != 1 or self.value(317, 1) not in (1, 3):
raise ValueError("Unsupported terrain layout.")
if any(key not in self.tags for key in (33550, 33922, 34735, 42113, 324, 325)):
@@ -71,6 +70,41 @@ class TIFF:
def value(self, code, default=None):
return self.values(code)[0] if code in self.tags else default
+ def blocks(self):
+ """Yield four 256-pixel blocks, preserving the source pixel encoding."""
+ if self.value(322) == 256:
+ for offset, size in zip(self.values(324), self.values(325)):
+ yield self.read(offset, size)
+ return
+ data = self.read(self.value(324), self.value(325))
+ compressed = self.value(259) != 1
+ if compressed:
+ data = zlib.decompress(data)
+ if len(data) != 512 * 512 * 4:
+ raise ValueError("Invalid terrain block size.")
+ blocks = [bytearray() for _ in range(4)]
+ for y in range(512):
+ row = data[y * 2048:(y + 1) * 2048]
+ left, right = blocks[y // 256 * 2:y // 256 * 2 + 2]
+ if self.value(317, 1) == 3:
+ # Float prediction differences span four byte planes per row.
+ # Rebase only the first byte of each half-plane after splitting.
+ carry = 0
+ for plane in range(4):
+ a = bytearray(row[plane * 512:plane * 512 + 256])
+ b = bytearray(row[plane * 512 + 256:(plane + 1) * 512])
+ a_sum, b_sum = sum(a), sum(b)
+ a[0] = (a[0] + carry) & 255
+ b[0] = (b[0] + a_sum) & 255
+ carry = b_sum
+ left.extend(a)
+ right.extend(b)
+ else:
+ left.extend(row[:1024])
+ right.extend(row[1024:])
+ for block in blocks:
+ yield zlib.compress(block) if compressed else block
+
def header(tags, order):
directory = bytearray(
@@ -110,14 +144,15 @@ def validate(source, tile):
):
raise ValueError("Terrain georeferencing does not match the download grid.")
offsets, sizes = source.values(324), source.values(325)
- if len(offsets) != 4 or len(sizes) != 4:
+ count = (512 // source.value(322)) ** 2
+ if len(offsets) != count or len(sizes) != count:
raise ValueError("Invalid terrain block directory.")
if any(not offset or not size or offset + size > source.size for offset, size in zip(offsets, sizes)):
raise ValueError("Missing or truncated saved terrain block.")
def merge(path, folder, results, grid, progress):
- """One source file open at a time; each compressed block is copied once."""
+ """One source file open at a time; usual 256-pixel blocks are copied as-is."""
columns, rows = grid["columns"], grid["rows"]
if len(results) != columns * rows:
raise ValueError("Download all terrain tiles before building terrain.tif.")
@@ -143,6 +178,8 @@ def merge(path, folder, results, grid, progress):
scale, west, north = origin(source, tile)
set_tag(256, 4, [columns * 512])
set_tag(257, 4, [rows * 512])
+ set_tag(322, 4, [256])
+ set_tag(323, 4, [256])
set_tag(33550, 12, [scale, scale, 0])
set_tag(33922, 12, [0, 0, 0, west, north, 0])
set_tag(324, 4, offsets)
@@ -150,12 +187,13 @@ def merge(path, folder, results, grid, progress):
output.write(header(tags, order))
elif order != source.order or compatible != signature:
raise ValueError("Terrain tile formats differ.")
- for j, (offset, size) in enumerate(zip(source.values(324), source.values(325))):
+ for j, data in enumerate(source.blocks()):
block = (row * 2 + j // 2) * columns * 2 + column * 2 + j % 2
+ size = len(data)
if output.tell() + size >= TIFF_LIMIT:
raise ValueError("Terrain exceeds the 4 GiB TIFF limit. Use a smaller area or lower terrain zoom.")
offsets[block], sizes[block] = output.tell(), size
- output.write(source.read(offset, size))
+ output.write(data)
progress("Building terrain.tif", i + 1, len(results))
set_tag(324, 4, offsets)
set_tag(325, 4, sizes)
diff --git a/tests/fixtures.py b/tests/fixtures.py
index bd8baed..dfe6662 100644
--- a/tests/fixtures.py
+++ b/tests/fixtures.py
@@ -22,10 +22,23 @@ def metadata(pano_id="panorama_0001", lat=0, lon=0):
]]]).encode()
-def terrain_bytes(x, y, zoom, heights=(1.25, -10.5, 200.75, -9999), *, order="<", raster_type=1):
- # Four independently compressed 256 x 256 Float32 blocks per provider tile.
- blocks = [zlib.compress(struct.pack(order + "f", height) * (256 * 256))
- for height in heights]
+def terrain_bytes(x, y, zoom, heights=(1.25, -10.5, 200.75, -9999), *, order="<", raster_type=1,
+ block_size=256, predictor=1):
+ quarters = [struct.pack(order + "f", height) * 256 for height in heights]
+ raw_blocks = ([row * 256 for row in quarters] if block_size == 256 else
+ [(quarters[0] + quarters[1]) * 256 + (quarters[2] + quarters[3]) * 256])
+ blocks = []
+ for raw in raw_blocks:
+ if predictor == 3:
+ # LibTIFF encodes the float predictor independently of our block splitter.
+ mode = "F;32F" if order == "<" else "F;32BF"
+ with Image.frombytes("F", (block_size, block_size), raw, "raw", mode) as image, BytesIO() as stream:
+ image.save(stream, format="TIFF", compression="tiff_adobe_deflate", tiffinfo={317: 3})
+ encoded = stream.getvalue()
+ with Image.open(stream) as saved:
+ raw = b"".join(zlib.decompress(encoded[offset:offset + size])
+ for offset, size in zip(saved.tag_v2[273], saved.tag_v2[279]))
+ blocks.append(zlib.compress(raw))
scale = 40075016.68557849 / (2**zoom * 512)
shift = scale / 2 if raster_type == 2 else 0
west = -20037508.342789244 + x * scale * 512 + shift
@@ -33,7 +46,8 @@ def terrain_bytes(x, y, zoom, heights=(1.25, -10.5, 200.75, -9999), *, order="<"
tags = {
256: (4, [512]), 257: (4, [512]), 258: (3, [32]), 259: (3, [8]),
262: (3, [1]), 277: (3, [1]), 284: (3, [1]),
- 322: (4, [256]), 323: (4, [256]), 324: (4, [0] * 4),
+ 317: (3, [predictor]),
+ 322: (4, [block_size]), 323: (4, [block_size]), 324: (4, [0] * len(blocks)),
325: (4, list(map(len, blocks))), 339: (3, [3]),
33550: (12, [scale, scale, 0]),
33922: (12, [0, 0, 0, west, north, 0]),
@@ -46,10 +60,10 @@ def terrain_bytes(x, y, zoom, heights=(1.25, -10.5, 200.75, -9999), *, order="<"
offset_location = None
for code, (kind, values) in sorted(tags.items()):
raw = values if kind == 2 else struct.pack(order + {3: "H", 4: "I", 12: "d"}[kind] * len(values), *values)
+ if code == 324:
+ offset_location = payload_start + len(payload) if len(raw) > 4 else 10 + len(entries) + 8
if len(raw) > 4:
location = payload_start + len(payload)
- if code == 324:
- offset_location = location
payload.extend(raw)
raw = struct.pack(order + "I", location)
entries.extend(struct.pack(order + "HHI", code, kind, len(values)) + raw.ljust(4, b"\0"))
@@ -59,5 +73,5 @@ def terrain_bytes(x, y, zoom, heights=(1.25, -10.5, 200.75, -9999), *, order="<"
for block in blocks:
offsets.append(len(data))
data.extend(block)
- struct.pack_into(order + "4I", data, offset_location, *offsets)
+ struct.pack_into(order + "I" * len(offsets), data, offset_location, *offsets)
return bytes(data)
diff --git a/tests/test_terrain.py b/tests/test_terrain.py
index 8c20c08..a1aeb78 100644
--- a/tests/test_terrain.py
+++ b/tests/test_terrain.py
@@ -47,6 +47,26 @@ class TerrainTests(unittest.TestCase):
block = zlib.compress(struct.pack(order + "f", height + 0.25) * (256 * 256))
self.assertEqual(data[offset:offset + size], block)
+ def test_mixed_block_sizes_preserve_every_float_pixel(self):
+ for order in ("<", ">"):
+ for predictor in (1, 3):
+ with self.subTest(order=order, predictor=predictor), tempfile.TemporaryDirectory() as directory:
+ folder = Path(directory)
+ results = []
+ for i, block_size in enumerate((512, 256, 256, 512)):
+ tile = dict(x=1 + i % 2, y=1 + i // 2, zoom=2, filename=f"{i}.tif")
+ (folder / tile["filename"]).write_bytes(terrain_bytes(
+ tile["x"], tile["y"], 2, order=order, block_size=block_size, predictor=predictor))
+ results.append(tile)
+ path = folder / "terrain.tif"
+ terrain.merge(path, folder, results, dict(x0=1, y0=1, zoom=2, columns=2, rows=2), Mock())
+ with Image.open(path) as mosaic:
+ self.assertEqual((mosaic.tag_v2[322], mosaic.tag_v2[323]), (256, 256))
+ for i, tile in enumerate(results):
+ x, y = i % 2 * 512, i // 2 * 512
+ with Image.open(folder / tile["filename"]) as source:
+ self.assertEqual(mosaic.crop((x, y, x + 512, y + 512)).tobytes(), source.tobytes())
+
def test_invalid_later_tile_leaves_previous_mosaic_intact(self):
corruptions = {
"wrong georeferencing": terrain_bytes(3, 1, 2),