fix and conversions
This commit is contained in:
@@ -66,3 +66,24 @@ func (s *CarpoolServiceServerImpl) GetUserPlanning(ctx context.Context, req *pro
|
||||
RoutesByDates: results,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *CarpoolServiceServerImpl) GetPlannedTrip(ctx context.Context, req *proto.GetPlannedTripRequest) (*proto.GetPlannedTripResponse, error) {
|
||||
planned_trip, err := s.Handler.GetPlannedTrip(req.Id)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "could not retrieve planned trip - %s", err.Error())
|
||||
}
|
||||
|
||||
planned_trip.Route.ExtraMembers["departure_date"] = planned_trip.DepartureDate
|
||||
|
||||
serialized, err := planned_trip.Route.FeatureCollection().MarshalJSON()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("grpc GetPlannedTrip - could not serialize feature collection")
|
||||
return nil, status.Errorf(codes.Internal, "could not serialize feature collection")
|
||||
}
|
||||
|
||||
return &proto.GetPlannedTripResponse{
|
||||
PlannedTrip: &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(serialized),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -53,6 +53,14 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
|
||||
driverDepartureLng := j.Route.Features[0].Point().Lon()
|
||||
driverArrivalLat := j.Route.Features[1].Point().Lat()
|
||||
driverArrivalLng := j.Route.Features[1].Point().Lon()
|
||||
var driverDepartureAddress *string
|
||||
if dda := j.Route.Features[0].Properties.MustString("label", ""); dda != "" {
|
||||
driverDepartureAddress = &dda
|
||||
}
|
||||
var driverArrivalAddress *string
|
||||
if daa := j.Route.Features[1].Properties.MustString("label", ""); daa != "" {
|
||||
driverArrivalAddress = &daa
|
||||
}
|
||||
duration := time.Duration(0)
|
||||
var distance *int64
|
||||
if len(j.Itinerary.Legs) > 2 {
|
||||
@@ -67,21 +75,24 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
|
||||
Operator: usermap["operator"].(string),
|
||||
Alias: usermap["alias"].(string),
|
||||
},
|
||||
Operator: "ridygo.fr",
|
||||
PassengerPickupLat: req.DepartureLat,
|
||||
PassengerPickupLng: req.DepartureLng,
|
||||
PassengerDropLat: req.ArrivalLat,
|
||||
PassengerDropLng: req.ArrivalLng,
|
||||
DriverDepartureLat: &driverDepartureLat,
|
||||
DriverDepartureLng: &driverDepartureLng,
|
||||
DriverArrivalLat: &driverArrivalLat,
|
||||
DriverArrivalLng: &driverArrivalLng,
|
||||
Duration: int64(duration),
|
||||
Distance: distance,
|
||||
Id: journeyId,
|
||||
PassengerPickupDate: timestamppb.New(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)),
|
||||
DriverDepartureDate: timestamppb.New(j.DepartureDate),
|
||||
Type: proto.CarpoolServiceJourneyType_PLANNED,
|
||||
Operator: "ridygo.fr",
|
||||
PassengerPickupLat: req.DepartureLat,
|
||||
PassengerPickupLng: req.DepartureLng,
|
||||
PassengerDropLat: req.ArrivalLat,
|
||||
PassengerDropLng: req.ArrivalLng,
|
||||
DriverDepartureLat: &driverDepartureLat,
|
||||
DriverDepartureLng: &driverDepartureLng,
|
||||
DriverArrivalLat: &driverArrivalLat,
|
||||
DriverArrivalLng: &driverArrivalLng,
|
||||
DriverDepartureAddress: driverDepartureAddress,
|
||||
DriverArrivalAddress: driverArrivalAddress,
|
||||
Duration: int64(duration),
|
||||
Distance: distance,
|
||||
Id: journeyId,
|
||||
PassengerPickupDate: timestamppb.New(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)),
|
||||
DriverDepartureDate: timestamppb.New(j.DepartureDate),
|
||||
Type: proto.CarpoolServiceJourneyType_PLANNED,
|
||||
JourneyPolyline: &j.Itinerary.Summary.Polyline,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -121,10 +132,17 @@ func (s *CarpoolServiceServerImpl) PassengerJourneys(ctx context.Context, req *p
|
||||
passengerArrivalLat := j.Route.Features[1].Point().Lat()
|
||||
passengerArrivalLng := j.Route.Features[1].Point().Lon()
|
||||
passengerDepartureDate := timestamppb.New(j.DepartureDate)
|
||||
var passengerPickupAddress *string
|
||||
if ppa := j.Route.Features[0].Properties.MustString("label", ""); ppa != "" {
|
||||
passengerPickupAddress = &ppa
|
||||
}
|
||||
var passengerDropAddress *string
|
||||
if pda := j.Route.Features[0].Properties.MustString("label", ""); pda != "" {
|
||||
passengerDropAddress = &pda
|
||||
}
|
||||
driverDepartureDate := timestamppb.New(j.DepartureDate.Add(-j.Itinerary.Legs[0].Duration))
|
||||
duration := time.Duration(0)
|
||||
var distance *int64
|
||||
log.Debug().Any("itinerary", j.Itinerary).Msg("debug itinerary")
|
||||
if len(j.Itinerary.Legs) > 2 {
|
||||
duration = j.Itinerary.Legs[1].Duration / time.Second
|
||||
dist := int64(j.Itinerary.Legs[1].Distance)
|
||||
@@ -137,21 +155,24 @@ func (s *CarpoolServiceServerImpl) PassengerJourneys(ctx context.Context, req *p
|
||||
Operator: usermap["operator"].(string),
|
||||
Alias: usermap["alias"].(string),
|
||||
},
|
||||
Operator: "ridygo.fr",
|
||||
PassengerPickupLat: passengerDepartureLat,
|
||||
PassengerPickupLng: passengerDepartureLng,
|
||||
PassengerDropLat: passengerArrivalLat,
|
||||
PassengerDropLng: passengerArrivalLng,
|
||||
DriverDepartureLat: &req.DepartureLat,
|
||||
DriverDepartureLng: &req.DepartureLng,
|
||||
DriverArrivalLat: &req.ArrivalLat,
|
||||
DriverArrivalLng: &req.ArrivalLng,
|
||||
Duration: int64(duration),
|
||||
Distance: distance,
|
||||
Id: journeyId,
|
||||
PassengerPickupDate: passengerDepartureDate,
|
||||
DriverDepartureDate: driverDepartureDate,
|
||||
Type: proto.CarpoolServiceJourneyType_PLANNED,
|
||||
Operator: "ridygo.fr",
|
||||
PassengerPickupLat: passengerDepartureLat,
|
||||
PassengerPickupLng: passengerDepartureLng,
|
||||
PassengerDropLat: passengerArrivalLat,
|
||||
PassengerDropLng: passengerArrivalLng,
|
||||
PassengerPickupAddress: passengerPickupAddress,
|
||||
PassengerDropAddress: passengerDropAddress,
|
||||
DriverDepartureLat: &req.DepartureLat,
|
||||
DriverDepartureLng: &req.DepartureLng,
|
||||
DriverArrivalLat: &req.ArrivalLat,
|
||||
DriverArrivalLng: &req.ArrivalLng,
|
||||
Duration: int64(duration),
|
||||
Distance: distance,
|
||||
Id: journeyId,
|
||||
PassengerPickupDate: passengerDepartureDate,
|
||||
DriverDepartureDate: driverDepartureDate,
|
||||
Type: proto.CarpoolServiceJourneyType_PLANNED,
|
||||
JourneyPolyline: &j.Itinerary.Summary.Polyline,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user