Search: look through all saved layers and offline hiking trails
GET /api/search (lib/maptool/search.rb) matches feature name and description, case- and diacritics-insensitive, across every file in Tracks & Points (shown or not) and every offline hiking-trails country. Parsed features are cached in memory per file by mtime. The search box now queries local sources and Nominatim side by side, labels each result with where it was found, lets you untick sources, and switches a result's layer on if it was off before zooming to it.
This commit is contained in:
1 parent
2611713489
commit
0051a0337c
10 files changed
+316
-21
No files matched your search
@@ -13,6 +13,7 @@ require_relative "lib/maptool/livetrack_client"
|
||||
require_relative "lib/maptool/kiwix"
|
||||
require_relative "lib/maptool/plugins"
|
||||
require_relative "lib/maptool/pmtiles_builder"
|
||||
require_relative "lib/maptool/search"
|
||||
|
||||
module Maptool
|
||||
# Only /login, /auth/callback and /logout ever write to session
|
||||
@@ -419,6 +420,15 @@ 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.
|
||||
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)
|
||||
end
|
||||
|
||||
# Pinged once per page load (public/js/map.js) — url is a same-origin
|
||||
# path (not kiwix-serve's own address, which the browser can't reach
|
||||
# directly behind the reverse proxy in front of this app), proxied by
|
||||
|
||||
Reference in new issue
Block a user