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
This commit is contained in:
1 parent
df69886220
commit
ff5924faf1
155 files changed
+5465
-113
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user