Skip to content

armgit / Aleph

Public Imported from GitHub
0

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

Improve capture time estimates and resolution controls

Belluxxaedaad24606f
diff --git a/aleph.py b/aleph.py
index e81f1bf..3a588d9 100644
--- a/aleph.py
+++ b/aleph.py
@@ -40,9 +40,6 @@ def describe(run):
maps = estimate["osm_maps"]
message = f"{maps:,} OSM {'map' if maps == 1 else 'maps'} and {estimate['terrain_tiles']:,} terrain tiles"
print(f" {label:<15}{message}", file=sys.stderr)
- if estimate["seconds"] is None:
- print(" Download time depends on panorama tile counts; progress is shown during capture.", file=sys.stderr)
- return
minutes, seconds = divmod(estimate["seconds"], 60)
hours, minutes = divmod(minutes, 60)
duration = f"{hours} hr {minutes} min" if hours else f"{minutes} min {seconds} sec" if minutes else f"{seconds} sec"
diff --git a/src/assets/app.js b/src/assets/app.js
index fd7733b..7665991 100644
--- a/src/assets/app.js
+++ b/src/assets/app.js
@@ -11,7 +11,8 @@ const state = {config: null, captures: [], selected: null, map: null, ready: nul
const form = $("capture-form");
const maxDrawLatitude = 85.0511287; // Remain inside Mercator bounds after rounding to seven decimals.
const names = {streetview: "STREET VIEW", satellite: "SATELLITE", osm: "OSM + TERRAIN"};
-const resolutionNames = ["Extra low", "Very low", "Low", "Medium", "High", "Very high", "Extra high"];
+const resolutionNames = ["Lowest", "Very low", "Low", "Medium", "High", "Very high", "Maximum"];
+const sphereResolutionNames = ["Lowest", "Low", "Medium", "High", "Very high", "Maximum"];
const layerGroups = {satellite: ["satellite"], buildings: ["buildings", "building-outlines"],
roads: ["road-casing", "roads"], water: ["land", "water", "water-lines"], photos: ["stops"]};
const contextRoadFilter = ["all", ["==", ["geometry-type"], "LineString"],
@@ -727,6 +728,10 @@ function renderCapturePanel() {
}
function renderResolution() {
+ const sphere = form.elements.sphere_zoom;
+ const sphereLabel = sphereResolutionNames[sphere.valueAsNumber];
+ $("sphere-resolution-value").value = sphereLabel;
+ sphere.setAttribute("aria-valuetext", sphereLabel);
const input = form.elements.satellite_zoom;
const label = resolutionNames[input.valueAsNumber - Number(input.min)];
$("resolution-value").value = label;
@@ -975,7 +980,7 @@ function showPlan(plan) {
if (!state.composing) return;
state.plan = plan;
const estimate = plan.estimate;
- $("plan-duration").textContent = estimate.seconds === null ? "Download time depends on sphere resolution" : `About ${durationLabel(estimate.seconds)}`;
+ $("plan-duration").textContent = `About ${durationLabel(estimate.seconds)}`;
const counts = $("plan-counts");
counts.replaceChildren();
const row = (label, value) => {
@@ -1122,6 +1127,7 @@ function bindEvents() {
$("close-plan").addEventListener("click", () => closeCapture());
$("edit-plan").addEventListener("click", editPlan);
$("satellite-resolution").addEventListener("input", renderResolution);
+ $("sphere-zoom").addEventListener("input", renderResolution);
form.addEventListener("change", renderCapturePanel);
$("search").addEventListener("input", renderLibrary);
$("refresh").addEventListener("click", () => refreshLibrary(true).catch((error) => notice(error.message)));
diff --git a/src/assets/index.html b/src/assets/index.html
index 6c2efa7..912b1d4 100644
--- a/src/assets/index.html
+++ b/src/assets/index.html
@@ -106,23 +106,27 @@
<h3 class="settings-divider"><svg viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5"/></svg>Satellite</h3>
<div class="resolution-heading"><label for="satellite-resolution">Satellite resolution</label><output id="resolution-value" for="satellite-resolution"></output></div>
<input id="satellite-resolution" class="resolution-slider" name="satellite_zoom" type="range" min="15" max="21" step="1">
- <div class="resolution-scale" aria-hidden="true"><span>Low</span><span>High</span></div>
+ <div class="resolution-scale" aria-hidden="true"><span>Lowest</span><span>Maximum</span></div>
<output id="satellite-patches" class="patch-estimate" for="satellite-resolution" aria-live="polite" hidden></output>
</div>
<div class="settings-group" data-source="streetview">
<h3 class="settings-divider"><svg viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M3 7h4l2-3h6l2 3h4v13H3Z"/><circle cx="12" cy="13" r="4"/></svg>Street View</h3>
<div class="settings-grid">
- <label>Capture type<select name="full_sphere"><option value="false">Left and right photos</option><option value="true">Full sphere (360°)</option></select></label>
+ <label>Capture type<select name="full_sphere"><option value="false">Left and right</option><option value="true">Full sphere (360°)</option></select></label>
<label>Photo spacing (m)<input name="step" type="number" min="0" step="any" required></label>
<label>Field of view (°)<input name="fov" type="number" min="5" max="175" step="1" required></label>
- <label id="sphere-resolution" hidden>Sphere resolution<select name="sphere_zoom"><option value="0">0 — Lowest</option><option value="1">1 — Low</option><option value="2">2 — Medium</option><option value="3">3 — High</option><option value="4">4 — Very high</option><option value="5">5 — Maximum</option></select></label>
+ </div>
+ <div id="sphere-resolution" hidden>
+ <div class="resolution-heading"><label for="sphere-zoom">Sphere resolution</label><output id="sphere-resolution-value" for="sphere-zoom"></output></div>
+ <input id="sphere-zoom" class="resolution-slider" name="sphere_zoom" type="range" min="0" max="5" step="1" value="3">
+ <div class="resolution-scale" aria-hidden="true"><span>Lowest</span><span>Maximum</span></div>
</div>
</div>
</fieldset>
<details id="advanced-settings" class="settings">
<summary>Advanced</summary>
<div class="settings-group" data-source="satellite">
- <h3 class="settings-divider">Satellite</h3>
+ <h3 class="settings-divider"><svg viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5"/></svg>Satellite</h3>
<div class="settings-grid">
<label>Tile format<select name="satellite_format"><option value="jpg">JPEG</option><option value="png">PNG</option></select></label>
</div>
diff --git a/src/assets/style.css b/src/assets/style.css
index 0facc82..e281181 100644
--- a/src/assets/style.css
+++ b/src/assets/style.css
@@ -339,6 +339,7 @@ a { color: inherit; text-underline-offset: 3px; }
.resolution-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.resolution-heading output { color: var(--ink); font: 10px var(--mono); }
.resolution-slider { display: block; width: 100%; margin: 8px 0 3px; }
+#sphere-resolution { margin-top: 16px; }
.resolution-scale { display: flex; justify-content: space-between; font: 9px/1.4 var(--mono); color: var(--muted); }
.patch-estimate { display: block; margin-top: 6px; color: var(--ink); font: 10px/1.4 var(--mono); text-align: center; }
.settings-group:not([hidden]) + .settings-group:not([hidden]), .settings > .settings-group:not([hidden]) { margin-top: 22px; }
diff --git a/src/capture.py b/src/capture.py
index 1042d94..4373ad2 100644
--- a/src/capture.py
+++ b/src/capture.py
@@ -40,6 +40,11 @@ DEFAULT_OPTIONS = dict(
delay=0, satellite_zoom=18, satellite_format="jpg", terrain_zoom=14,
)
+# Average connection speed / hardware timings, just to give an idea to the user, not precise
+REQUEST_SECONDS = dict(metadata=0.17, photo=0.46, sphere_tile=0.27, satellite_tile=0.25, terrain_tile=1.39)
+SPHERE_TILES = (1, 2, 8, 32, 128, 512)
+OSM_EXPORT_SECONDS = 10
+
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.",
@@ -137,22 +142,28 @@ def total(stage):
def estimate(run):
- """Estimate remaining downloads using observed download time with average internet connection"""
- counts = dict(streetview_photos=0, streetview_stops=0, satellite_tiles=0,
+ """Estimate remaining work from measured request costs and typical sphere sizes.
+
+ Excludes planning, initial regional PBF downloads, and final merged exports.
+ Partly downloaded spheres are counted in full; their cached tiles may save time.
+ """
+ counts = dict(streetview_photos=0, streetview_stops=0, streetview_tiles=0, satellite_tiles=0,
terrain_tiles=0, osm_maps=0)
- metadata_requests = 0
- sphere_pending = False
+ metadata_requests = thumbnail_requests = 0
for stage in run["stages"]:
remaining = total(stage) - len(stage["results"])
if stage["mode"] == "streetview":
counts["streetview_photos"] = remaining
- sphere_pending = bool(stage.get("full_sphere") and remaining)
per_stop = 1 if stage.get("full_sphere") else 2
+ if stage.get("full_sphere"):
+ counts["streetview_tiles"] = remaining * SPHERE_TILES[run["options"]["sphere_zoom"]]
+ else:
+ thumbnail_requests = remaining
samples = stage["samples"][len(stage["results"]) // per_stop:]
counts["streetview_stops"] = len(samples)
previous = None # Metadata is fetched again when resuming a run.
for sample in samples:
- if sample["pano_id"] != previous:
+ if stage.get("full_sphere") or sample["pano_id"] != previous:
metadata_requests += 1
previous = sample["pano_id"]
elif stage["mode"] == "satellite":
@@ -161,15 +172,13 @@ def estimate(run):
counts["osm_maps"] = int(not any(item["filename"] == "map.osm"
for item in stage["results"]))
counts["terrain_tiles"] = remaining - counts["osm_maps"]
- requests = (counts["streetview_photos"] + metadata_requests
- + counts["satellite_tiles"] + counts["terrain_tiles"])
- download_seconds = (counts["streetview_photos"] * 0.55
- + counts["satellite_tiles"] * 0.37
- + counts["terrain_tiles"] * 1.1 + counts["osm_maps"] * 30)
- delay_seconds = max(0, requests - 1) * run["options"]["delay"]
- # Native tile dimensions are learned during capture, so a sphere ETA is
- # unavailable at planning time. Do not apply the two-thumbnail timings.
- return dict(counts, seconds=None if sphere_pending else math.ceil(download_seconds + delay_seconds))
+ requests = dict(metadata=metadata_requests, photo=thumbnail_requests,
+ sphere_tile=counts["streetview_tiles"], satellite_tile=counts["satellite_tiles"],
+ terrain_tile=counts["terrain_tiles"])
+ download_seconds = sum(count * REQUEST_SECONDS[kind] for kind, count in requests.items())
+ download_seconds += counts["osm_maps"] * OSM_EXPORT_SECONDS
+ delay_seconds = max(0, sum(requests.values()) - 1) * run["options"]["delay"]
+ return dict(counts, seconds=math.ceil(download_seconds + delay_seconds))
def photos(run, after=0):
diff --git a/tests/test_capture.py b/tests/test_capture.py
index 72299ee..4a53c31 100644
--- a/tests/test_capture.py
+++ b/tests/test_capture.py
@@ -166,7 +166,7 @@ class CaptureTests(unittest.TestCase):
run = self.sphere_run()
self.assertEqual(capture.total(run["stages"][0]), 1)
self.assertEqual(capture.estimate(run)["streetview_stops"], 1)
- self.assertIsNone(capture.estimate(run)["seconds"])
+ self.assertGreater(capture.estimate(run)["seconds"], 0)
client = Mock()
client.get.side_effect = [sphere_metadata(), sphere_tile("red"), sphere_tile("green"), KeyboardInterrupt()]
with self.assertRaises(KeyboardInterrupt):