Show build progress instead of a static "Building…"
terrain.pmtiles can take minutes (tiles fetched one at a time) with no way to tell a slow build from a stuck one. Now reports tiles_done/ tiles_total into the same status Hash the frontend already polls, and the panel shows elapsed time (both files) plus tile counts (terrain only) so the numbers visibly move every ~3s poll instead of sitting on one static string.
This commit is contained in:
1 parent
d72f8a3c94
commit
bbe9f38bda
3 files changed
+68
-8
No files matched your search
@@ -113,7 +113,34 @@ class PmtilesBuilderTest < Minitest::Test
|
||||
thread.join
|
||||
|
||||
assert_path_exists File.join(@data_dir, "terrain.pmtiles")
|
||||
assert_equal "done", Maptool::PmtilesBuilder.terrain_status[:state]
|
||||
status = Maptool::PmtilesBuilder.terrain_status
|
||||
assert_equal "done", status[:state]
|
||||
assert_operator status[:tiles_total], :>, 0
|
||||
assert_equal status[:tiles_total], status[:tiles_done]
|
||||
end
|
||||
|
||||
# fetch_tile blocks after the very first call so the "running" progress
|
||||
# can be observed mid-flight, deterministically, rather than only ever
|
||||
# seeing the final done/total once the (very fast, faked) build finishes.
|
||||
def test_build_terrain_reports_progress_while_running
|
||||
ENV["PMTILES_BIN"] = @pmtiles_ok
|
||||
gate = Queue.new
|
||||
first_call = true
|
||||
fetch_tile = lambda do |_z, _x, _y|
|
||||
gate.pop if first_call
|
||||
first_call = false
|
||||
"bytes"
|
||||
end
|
||||
thread = Maptool::PmtilesBuilder.build_terrain([48.140, 17.100, 48.141, 17.101], data_dir: @data_dir, fetch_tile: fetch_tile)
|
||||
|
||||
20.times { break if Maptool::PmtilesBuilder.terrain_status[:tiles_total]; sleep 0.01 }
|
||||
status = Maptool::PmtilesBuilder.terrain_status
|
||||
assert_equal "running", status[:state]
|
||||
assert_operator status[:tiles_total], :>, 0
|
||||
assert_equal 0, status[:tiles_done]
|
||||
ensure
|
||||
gate.push(nil)
|
||||
thread&.join
|
||||
end
|
||||
|
||||
def test_build_terrain_still_succeeds_when_some_tiles_are_missing
|
||||
|
||||
Reference in new issue
Block a user