Offline routing phase 1: valhalla container building from the offline map's extracts, status in the Offline data panel
This commit is contained in:
1 parent
6f5f11cb4d
commit
bf912b96e5
13 files changed
+455
-36
No files matched your search
@@ -8,6 +8,7 @@ require_relative "lib/maptool/gpx"
|
||||
require_relative "lib/maptool/fit"
|
||||
require_relative "lib/maptool/gpx_store"
|
||||
require_relative "lib/maptool/library"
|
||||
require_relative "lib/maptool/routing"
|
||||
require_relative "lib/maptool/gpsd_client"
|
||||
require_relative "lib/maptool/livetrack_store"
|
||||
require_relative "lib/maptool/livetrack_client"
|
||||
@@ -142,6 +143,9 @@ module Maptool
|
||||
# this app, so a browser can't reach kiwix-serve directly by any
|
||||
# hostname/port of its own. GET /kiwix/* below proxies to it instead.
|
||||
KIWIX_URL = ENV.fetch("KIWIX_URL", "")
|
||||
# The valhalla container (docker-compose.yaml), reached server side only.
|
||||
VALHALLA_URL = ENV.fetch("VALHALLA_URL", "")
|
||||
Routing.install_service_script(DATA_DIR)
|
||||
|
||||
# Login delegates to the Gitea instance the user already has an account
|
||||
# on, rather than maintaining a local username/password — see
|
||||
@@ -417,6 +421,32 @@ module Maptool
|
||||
json PmtilesBuilder.terrain_status
|
||||
end
|
||||
|
||||
# Offline routing (lib/maptool/routing.rb): the same status/build/
|
||||
# build-status/check-update shape as the two rows above, so the Offline
|
||||
# data panel shows it the same way. Valhalla builds in its own
|
||||
# container; these only hand it requests and read its status files.
|
||||
get "/api/routing-tiles" do
|
||||
json Routing.tiles_status(DATA_DIR, VALHALLA_URL)
|
||||
end
|
||||
|
||||
get "/api/routing-tiles/check-update" do
|
||||
json update_available: Routing.update_available?(DATA_DIR)
|
||||
end
|
||||
|
||||
post "/api/routing-tiles/build" do
|
||||
require_login!
|
||||
begin
|
||||
Routing.request_build(DATA_DIR)
|
||||
rescue PmtilesBuilder::BuildError => e
|
||||
halt 409, json(error: e.message)
|
||||
end
|
||||
json status: "started"
|
||||
end
|
||||
|
||||
get "/api/routing-tiles/build-status" do
|
||||
json Routing.build_status(DATA_DIR)
|
||||
end
|
||||
|
||||
# Same reasoning as DELETE /api/offline-tiles above.
|
||||
delete "/api/terrain-tiles" do
|
||||
require_login!
|
||||
|
||||
Reference in new issue
Block a user