Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/mobility-core/src/Kernel/External/Maps/Interface/OSRM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ callOsrmMatch ::
SnapToRoadReq ->
m SnapToRoadResp
callOsrmMatch entityId osrmCfg req@(SnapToRoadReq wps distanceUnit calculateDistanceFrom) = do
let wps' =
if length wps == 1
then [head wps, head wps] -- OSRM requires at least 2 points or it will throw an error
else wps
let req' = req {points = wps'} :: SnapToRoadReq
let mbRadius = fmap (.getMeters) osrmCfg.radiusDeviation
res <- OSRM.callOsrmMatchAPI entityId req osrmCfg.osrmUrl mbRadius CAR (OSRM.PointsList wps)
res <- OSRM.callOsrmMatchAPI entityId req' osrmCfg.osrmUrl mbRadius CAR (OSRM.PointsList wps')
(dist, conf, interpolatedPts) <- OSRM.getResultOneRouteExpected res
pure $ case calculateDistanceFrom of
Just _ -> do
Expand Down