Offline regions for the whole world: the region list comes from Geofabrik's index (bin/geofabrik-regions-sync.mjs → geofabrik_regions.geojson, 193 countries plus subregions like the US states), keeping the European ISO codes; the picker folds it by continent with a search box and subregions under their country, flags for all of them
CI / check (push) Successful in 19s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-19 10:03:47 +01:00
1 parent df69886220
commit ff5924faf1
155 files changed
+5465 -113

No files matched your search

+2 -1
View File
@@ -445,7 +445,8 @@ class AppTest < Minitest::Test
def test_offline_regions_lists_available_and_selected
body = json_body(request.get("/api/offline-regions"))
assert_operator body["available"].size, :>, 0
assert_includes body["available"], { "code" => "SK", "name" => "Slovakia" }
assert_includes body["available"], { "code" => "SK", "name" => "Slovakia", "continent" => "europe", "parent" => nil }
assert_includes body["continents"], { "id" => "europe", "name" => "Europe" }
assert_equal [], body["selected"]
end
+19 -1
View File
@@ -15,7 +15,7 @@ require "fileutils"
# merge invoked, and with what").
#
# Country codes below are real ones from the vendored
# lib/maptool/data/europe_countries.geojson (Slovakia, Iceland, Spain) —
# lib/maptool/data/geofabrik_regions.geojson (Slovakia, Iceland, Spain) —
# chosen so their real bboxes fall cleanly inside/outside the fake
# manifest's chunk extents below, without needing a second fake geometry
# source.
@@ -181,6 +181,24 @@ class PmtilesBuilderTest < Minitest::Test
assert_includes codes, "IS"
end
# The whole world by continent, with subregions under their country —
# and the codes the old Europe-only list used still there.
def test_available_regions_cover_the_world_with_subregions
regions = Maptool::PmtilesBuilder.available_regions.to_h { |r| [r[:code], r] }
assert_equal({ code: "US", name: "United States of America", continent: "north-america", parent: nil }, regions["US"])
assert_equal({ code: "US-CA", name: "California", continent: "north-america", parent: "US" }, regions["US-CA"])
assert_equal "Trøndelag (Central Norway)", regions["NO-trondelag"][:name] # Geofabrik's HTML stripped
%w[AL AT BY BE BA BG HR CZ DK EE FI FR DE GR HU IS IE IT XK LV LT LU MD ME NL MK NO PL PT RO RU RS SK SI ES SE CH UA GB]
.each { |code| assert regions.key?(code), "#{code} missing" }
assert_equal %w[europe north-america central-america south-america asia russia africa australia-oceania antarctica],
Maptool::PmtilesBuilder.continents.map { |c| c["id"] }
end
def test_set_selected_regions_accepts_a_subregion
select_regions("US-UT")
assert_equal ["US-UT"], Maptool::PmtilesBuilder.selected_regions(@data_dir)
end
def test_selected_regions_defaults_to_empty
assert_empty Maptool::PmtilesBuilder.selected_regions(@data_dir)
end