use steps for waypoints in routing service

This commit is contained in:
Asim Aslam
2021-04-26 15:06:04 +01:00
parent d119807d1c
commit 334336ca6f

View File

@@ -62,16 +62,21 @@ func (o *OSRM) Route(ctx context.Context, req *pb.RouteRequest, rsp *pb.RouteRes
return errors.InternalServerError("routing.route", "failed to get route: %v", err.Error()) return errors.InternalServerError("routing.route", "failed to get route: %v", err.Error())
} }
for _, waypoint := range resp.Waypoints { for _, routes := range resp.Routes {
for _, leg := range routes.Legs {
for _, step := range leg.Steps {
for _, intersect := range step.Intersections {
rsp.Waypoints = append(rsp.Waypoints, &pb.Waypoint{ rsp.Waypoints = append(rsp.Waypoints, &pb.Waypoint{
Name: waypoint.Name, Name: step.Name,
Distance: float64(waypoint.Distance),
Location: &pb.Point{ Location: &pb.Point{
Latitude: waypoint.Location.Lat(), Latitude: intersect.Location.Lat(),
Longitude: waypoint.Location.Lng(), Longitude: intersect.Location.Lng(),
}, },
}) })
} }
}
}
}
return nil return nil
} }