Simulation along the trip's route ("Simulate driving the route" when there is one, POST /api/sim/gnss {"trip": true}), random trips after it
This commit is contained in:
1 parent
07a4d363ec
commit
7fcac61c99
5 files changed
+38
-9
No files matched your search
@@ -38,14 +38,19 @@ module Maptool
|
||||
|
||||
# Drives from [lon, lat] until stopped — or, with bboxes
|
||||
# ([[west, south, east, north], ...], the offline countries) instead,
|
||||
# from a random place in one of them; each fix to the block:
|
||||
# from a random place in one of them; with a route (the trip's /api/route
|
||||
# Feature), that route from its start first, random trips after it;
|
||||
# each fix to the block:
|
||||
# { lat:, lon:, speed: m/s, satellites:, hdop: }.
|
||||
def start(lon = nil, lat = nil, bboxes: nil, &on_fix)
|
||||
def start(lon = nil, lat = nil, bboxes: nil, route: nil, &on_fix)
|
||||
stop
|
||||
@error = nil
|
||||
@mutex.synchronize do
|
||||
@thread = Thread.new do
|
||||
position, route = bboxes ? random_start(bboxes) : [[Float(lon), Float(lat)], nil]
|
||||
position, route = if route then [route[:geometry][:coordinates].first, route]
|
||||
elsif bboxes then random_start(bboxes)
|
||||
else [[Float(lon), Float(lat)], nil]
|
||||
end
|
||||
loop do
|
||||
position = drive(position, route, &on_fix)
|
||||
route = nil
|
||||
|
||||
Reference in new issue
Block a user