Search the offline map and Wikipedia, nearest results first
CI / check (push) Successful in 26s
CI / deploy (push) Successful in 33s

Every named OSM object in each country's Geofabrik extract goes into a
SQLite FTS5 index (data/places/<CODE>.sqlite, lib/maptool/places.rb),
built as the last offline-build step or on its own with
rake places:index. Kiwix full-text search is another source; clicking a
hit opens the article. Results from every source are sorted by distance
from the map center (settlements weighted closer) and show it; each
source is queried separately so a slow one doesn't hold up the list.
This commit is contained in:
randy committed 2026-11-12 12:13:13 +01:00
1 parent ba9c40ac3d
commit 3f973a26d7
14 files changed
+549 -90

No files matched your search

+11
View File
@@ -35,6 +35,17 @@ class SearchTest < Minitest::Test
assert_equal [17.0, 48.0, 18.0, 49.0], track[:bbox]
end
def test_with_a_map_center_results_come_nearest_first_with_their_distance
camps = { "type" => "FeatureCollection", "features" => [
point("Kemp far", 21.0, 48.7), point("Kemp near", 17.1, 48.15),
] }
@store.save(folder: "", filename: "more.geojson", io: StringIO.new(JSON.generate(camps)))
results = search("kemp", center: [48.14, 17.10])
assert_equal ["Kemp near", "Kemp far", "Kemp Košice"], results.map { |r| r[:name] }
assert_in_delta 1.3, results.first[:distance_km], 0.2
end
def test_source_filter_and_blank_query
assert_empty search("snp", sources: ["layers"])
assert_empty search(" ")