Routing: merge the countries' extracts with osmium before Valhalla, which fails on overlapping extracts
This commit is contained in:
1 parent
92efe118b0
commit
acf5256c74
4 files changed
+85
-8
No files matched your search
+29
-1
@@ -71,11 +71,27 @@ class RoutingTest < Minitest::Test
|
||||
# Different countries do queue, and the running build's step still shows.
|
||||
File.write(File.join(@data, "geofabrik_cache", "CZ.osm.pbf"), "pbf")
|
||||
Maptool::PmtilesBuilder.set_selected_regions(@data, %w[SK CZ])
|
||||
Maptool::Routing.request_build(@data)
|
||||
with_osmium("cat \"$3\" \"$4\" > \"$6\"") { Maptool::Routing.request_build(@data) }
|
||||
assert File.exist?(File.join(@routing, "build-request.json"))
|
||||
assert_equal "routing graph (SK)", Maptool::Routing.build_status(@data)[:step]
|
||||
end
|
||||
|
||||
def test_several_countries_are_merged_into_one_file_for_valhalla
|
||||
%w[SK CZ].each { |code| File.write(File.join(@data, "geofabrik_cache", "#{code}.osm.pbf"), code) }
|
||||
Maptool::PmtilesBuilder.set_selected_regions(@data, %w[SK CZ])
|
||||
with_osmium("cat \"$3\" \"$4\" > \"$6\"") { Maptool::Routing.request_build(@data) }
|
||||
|
||||
request = JSON.parse(File.read(File.join(@routing, "build-request.json")))
|
||||
assert_equal ["routing/merged.osm.pbf", %w[SK CZ]], request.values_at("pbf", "regions")
|
||||
assert_equal "SKCZ", File.read(File.join(@data, "routing", "merged.osm.pbf"))
|
||||
|
||||
File.delete(File.join(@routing, "build-request.json"))
|
||||
with_osmium("echo broken >&2; exit 1") { Maptool::Routing.request_build(@data) }
|
||||
assert_equal "error", Maptool::Routing.build_status(@data)[:state]
|
||||
assert_includes Maptool::Routing.build_status(@data)[:message], "broken"
|
||||
refute File.exist?(File.join(@routing, "build-request.json"))
|
||||
end
|
||||
|
||||
def test_the_vehicle_is_validated_and_stored
|
||||
assert_equal Maptool::Routing::DEFAULT_VEHICLE, Maptool::Routing.vehicle(@data)
|
||||
Maptool::Routing.save_vehicle(@data, "height" => "3.4", "width" => "2.4", "length" => "8", "weight" => "4.2")
|
||||
@@ -118,6 +134,18 @@ class RoutingTest < Minitest::Test
|
||||
|
||||
private
|
||||
|
||||
# A stand-in osmium ($1 merge, $2 -O, $3.. inputs, then -o OUTPUT); waits for the merge thread.
|
||||
def with_osmium(script)
|
||||
bin = File.join(@data, "osmium")
|
||||
File.write(bin, "#!/bin/sh\n#{script}\n")
|
||||
File.chmod(0o755, bin)
|
||||
ENV["OSMIUM_BIN"] = bin
|
||||
yield
|
||||
sleep 0.02 while Maptool::Routing.build_status(@data)[:step] == "merging extracts with osmium"
|
||||
ensure
|
||||
ENV.delete("OSMIUM_BIN")
|
||||
end
|
||||
|
||||
# Answers one HTTP request with `response`; returns what was received.
|
||||
def serve_once(response)
|
||||
server = TCPServer.new("127.0.0.1", 0)
|
||||
|
||||
Reference in new issue
Block a user