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

+7 -4
View File
@@ -433,13 +433,16 @@ module Maptool
send_file path, type: "application/geo+json"
end
# The search box's local half (public/js/search.js) — every saved
# layer, shown or not, plus offline hiking trails. Read-only and
# login-free like the tree listing: viewing needs no account.
# The search box's local half (public/js/search.js) — saved layers
# (shown or not), offline hiking trails, the offline place index and
# Kiwix; lat/lng (the map center) puts nearer places first. Read-only
# and login-free like the tree listing: viewing needs no account.
get "/api/search" do
sources = params[:sources].to_s.split(",")
sources = Search::SOURCES.keys if sources.empty?
json results: Search.query(params[:q], gpx_store: GPX_STORE, data_dir: DATA_DIR, sources: sources)
center = params[:lat] && params[:lng] ? [params[:lat].to_f, params[:lng].to_f] : nil
json results: Search.query(params[:q], gpx_store: GPX_STORE, data_dir: DATA_DIR, sources: sources,
center: center, kiwix_url: KIWIX_URL)
end
# Pinged once per page load (public/js/map.js) — url is a same-origin