fix and conversions

This commit is contained in:
Arnaud Delcasse 2023-04-05 20:57:27 +02:00
parent 2f536dfb19
commit d8346a20be
14 changed files with 1212 additions and 958 deletions

View File

@ -27,7 +27,6 @@ func DistanceFromLineString(point orb.Point, lineString orb.LineString) (distanc
Float64("min distance", minDistance). Float64("min distance", minDistance).
Int("index", closest). Int("index", closest).
Any("point", point). Any("point", point).
Any("linestring", lineString).
Msg("minimum distance to polyline") Msg("minimum distance to polyline")
return minDistance, closest return minDistance, closest
} }

2
go.mod
View File

@ -2,7 +2,7 @@ module git.coopgo.io/coopgo-platform/carpool-service
go 1.18 go 1.18
// replace git.coopgo.io/coopgo-platform/routing-service => ../../coopgo-platform/routing-service/ replace git.coopgo.io/coopgo-platform/routing-service => ../../coopgo-platform/routing-service/
replace git.coopgo.io/coopgo-platform/carpool-service/interoperability/ocss => ./interoperability/ocss/ replace git.coopgo.io/coopgo-platform/carpool-service/interoperability/ocss => ./interoperability/ocss/

View File

@ -111,3 +111,13 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
return results, nil return results, nil
} }
func (h *CarpoolServiceHandler) GetPlannedTrip(id string) (*internal.PlannedRouteSchedule, error) {
planned_trip, err := h.Storage.GetRouteSchedule(id)
if err != nil {
log.Error().Str("planned trip id", id).Err(err).Msg("could not retrieve planned schedule")
return nil, err
}
return planned_trip, nil
}

View File

@ -62,9 +62,9 @@ func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival o
distanceFromDeparture, indexDeparture := geoutils.DistanceFromLineString(departure, ls) distanceFromDeparture, indexDeparture := geoutils.DistanceFromLineString(departure, ls)
distanceFromArrival, indexArrival := geoutils.DistanceFromLineString(arrival, ls) distanceFromArrival, indexArrival := geoutils.DistanceFromLineString(arrival, ls)
if indexArrival >= indexDeparture && distanceFromDeparture <= drad && distanceFromArrival < arad { if indexArrival >= indexDeparture && distanceFromDeparture <= drad && distanceFromArrival <= arad {
//routePoints := []orb.Point{r.Route.Features[0].Point(), departure, arrival, r.Route.Features[1].Point()} //routePoints := []orb.Point{r.Route.Features[0].Point(), departure, arrival, r.Route.Features[1].Point()}
routePoints := []orb.Point{departure, arrival} routePoints := []orb.Point{r.Route.Features[0].Point(), departure, arrival, r.Route.Features[1].Point()}
log.Debug().Any("route points", routePoints).Msg("calculate multipoint route") log.Debug().Any("route points", routePoints).Msg("calculate multipoint route")
itinerary, err := h.Routing.Route(routePoints) itinerary, err := h.Routing.Route(routePoints)
if err != nil { if err != nil {
@ -161,8 +161,8 @@ func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arriva
distanceFromArrival, indexArrival := geoutils.DistanceFromLineString(r.Route.Features[1].Point(), ls) distanceFromArrival, indexArrival := geoutils.DistanceFromLineString(r.Route.Features[1].Point(), ls)
if indexArrival >= indexDeparture && distanceFromDeparture <= drad && distanceFromArrival < arad { if indexArrival >= indexDeparture && distanceFromDeparture <= drad && distanceFromArrival < arad {
routePoints := []orb.Point{r.Route.Features[0].Point(), departure, arrival, r.Route.Features[0].Point()} routePoints := []orb.Point{r.Route.Features[0].Point(), departure, arrival, r.Route.Features[1].Point()}
itinerary, err := h.Routing.Route(routePoints) way, err := h.Routing.Route(routePoints)
if err != nil { if err != nil {
log.Error().Err(err).Msg("error getting route with viapoints") log.Error().Err(err).Msg("error getting route with viapoints")
continue continue
@ -171,7 +171,7 @@ func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arriva
ID: r.ID, ID: r.ID,
Route: r.Route, Route: r.Route,
DepartureDate: r.DepartureDate, DepartureDate: r.DepartureDate,
Itinerary: itinerary, Itinerary: way,
}) })
counted = counted + 1 counted = counted + 1
if counted == *count { if counted == *count {

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,7 @@ message CarpoolServicePassengerJourney {
} }
message CarpoolServiceDriverRegularTrip { message CarpoolServiceDriverRegularTrip {
string id = 1; optional string id = 1;
string operator = 2; string operator = 2;
double passenger_pickup_lat = 3; double passenger_pickup_lat = 3;
double passenger_pickup_lng = 4; double passenger_pickup_lng = 4;
@ -85,30 +85,26 @@ message CarpoolServiceDriverRegularTrip {
double passenger_drop_lng = 6; double passenger_drop_lng = 6;
optional string passenger_pickup_address = 7; optional string passenger_pickup_address = 7;
optional string passenger_drop_address = 8; optional string passenger_drop_address = 8;
int64 distance = 9; optional int64 distance = 9;
double driver_departure_lat = 10; optional double driver_departure_lat = 10;
double driver_departure_lng = 11; optional double driver_departure_lng = 11;
double driver_arrival_lat = 12; optional double driver_arrival_lat = 12;
double driver_arrival_lng = 13; optional double driver_arrival_lng = 13;
string driver_departure_address = 14; optional string driver_departure_address = 14;
string driver_arrival_address = 15; optional string driver_arrival_address = 15;
int64 duration = 16; int64 duration = 16;
string journey_polyline = 17; optional string journey_polyline = 17;
string web_url = 18; optional string web_url = 18;
CarpoolServiceUser driver = 19; CarpoolServiceUser driver = 19;
int64 departure_to_pickup_walking_distance = 20; optional int64 departure_to_pickup_walking_distance = 20;
int64 departure_to_pickup_walking_duration = 21; optional int64 departure_to_pickup_walking_duration = 21;
string departure_to_pickup_walking_polyline = 22; optional string departure_to_pickup_walking_polyline = 22;
int64 dropoff_to_arrival_walking_distance = 23; optional int64 dropoff_to_arrival_walking_distance = 23;
int64 dropoff_to_arrival_walking_duration = 24; optional int64 dropoff_to_arrival_walking_duration = 24;
string dropoff_to_arrival_walking_polyline = 25; optional string dropoff_to_arrival_walking_polyline = 25;
CarpoolServiceCar car = 26; optional CarpoolServiceCar car = 26;
google.protobuf.Timestamp passenger_pickup_date = 27; optional CarpoolServicePreferences preferences = 32;
google.protobuf.Timestamp driver_departure_date = 28; repeated CarpoolServiceSchedule schedules = 33;
CarpoolServiceJourneyType type = 29;
int64 requested_seats = 30;
CarpoolServicePreferences preferences = 32;
repeated CarpoolServiceJourneySchedule schedules = 33;
} }
message CarpoolServicePassengerRegularTrip { message CarpoolServicePassengerRegularTrip {
@ -118,21 +114,21 @@ message CarpoolServicePassengerRegularTrip {
double passenger_pickup_lng = 4; double passenger_pickup_lng = 4;
double passenger_drop_lat = 5; double passenger_drop_lat = 5;
double passenger_drop_lng = 6; double passenger_drop_lng = 6;
string passenger_pickup_address = 7; optional string passenger_pickup_address = 7;
string passenger_drop_address = 8; optional string passenger_drop_address = 8;
int64 distance = 9; optional int64 distance = 9;
double driver_departure_lat = 10; optional double driver_departure_lat = 10;
double driver_departure_lng = 11; optional double driver_departure_lng = 11;
double driver_arrival_lat = 12; optional double driver_arrival_lat = 12;
double driver_arrival_lng = 13; optional double driver_arrival_lng = 13;
string driver_departure_address = 14; optional string driver_departure_address = 14;
string driver_arrival_address = 15; optional string driver_arrival_address = 15;
int64 duration = 16; int64 duration = 16;
string journey_polyline = 17; optional string journey_polyline = 17;
string web_url = 18; optional string web_url = 18;
CarpoolServiceUser passenger = 19; CarpoolServiceUser passenger = 19;
CarpoolServicePreferences preferences = 32; optional CarpoolServicePreferences preferences = 32;
repeated CarpoolServiceJourneySchedule schedules = 33; repeated CarpoolServiceSchedule schedules = 33;
} }
message CarpoolServiceBooking { message CarpoolServiceBooking {
@ -144,15 +140,16 @@ message CarpoolServiceBooking {
double passenger_pickup_lng = 6; double passenger_pickup_lng = 6;
double passenger_drop_lat = 7; double passenger_drop_lat = 7;
double passenger_drop_lng = 8; double passenger_drop_lng = 8;
string passenger_pickup_address = 9; optional string passenger_pickup_address = 9;
string passenger_drop_address = 10; optional string passenger_drop_address = 10;
CarpoolServiceBookingStatus status = 11; CarpoolServiceBookingStatus status = 11;
int64 duration = 12; optional int64 distance = 12;
string web_url = 13; optional int64 duration = 13;
CarpoolServicePrice price = 14; optional string web_url = 14;
CarpoolServiceCar car = 15; CarpoolServicePrice price = 15;
string driver_journey_id = 16; optional CarpoolServiceCar car = 16;
string passenger_journey_id = 17; string driver_journey_id = 17;
string passenger_journey_id = 18;
} }
message CarpoolServicePreferences { message CarpoolServicePreferences {
@ -195,7 +192,7 @@ message CarpoolServiceSchedule {
message CarpoolServiceJourneySchedule { message CarpoolServiceJourneySchedule {
string id = 1; string id = 1;
google.protobuf.Timestamp passenger_pickup_date = 2; google.protobuf.Timestamp passenger_pickup_date = 2;
google.protobuf.Timestamp driver_departure_date = 3; optional google.protobuf.Timestamp driver_departure_date = 3;
optional string web_url = 4; optional string web_url = 4;
CarpoolServiceJourneyType type = 5; CarpoolServiceJourneyType type = 5;
} }

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ service CarpoolService {
rpc DeleteRegularRoutes(DeleteRegularRoutesRequest) returns (DeleteRegularRoutesResponse) {} rpc DeleteRegularRoutes(DeleteRegularRoutesRequest) returns (DeleteRegularRoutesResponse) {}
rpc GetUserPlanning(GetUserPlanningRequest) returns (GetUserPlanningResponse) {} rpc GetUserPlanning(GetUserPlanningRequest) returns (GetUserPlanningResponse) {}
rpc GetPlannedTrip(GetPlannedTripRequest) returns (GetPlannedTripResponse) {}
// OCSS-like interaction // OCSS-like interaction
rpc DriverJourneys(DriverJourneysRequest) returns (DriverJourneysResponse) {} rpc DriverJourneys(DriverJourneysRequest) returns (DriverJourneysResponse) {}
@ -46,6 +47,14 @@ message GetUserPlanningResponse {
map<string, CarpoolRoutesCollection> routes_by_dates = 1; map<string, CarpoolRoutesCollection> routes_by_dates = 1;
} }
message GetPlannedTripRequest {
string id = 1;
}
message GetPlannedTripResponse {
CarpoolFeatureCollection planned_trip = 1;
}
// OCSS-like interaction messages // OCSS-like interaction messages

View File

@ -27,6 +27,7 @@ type CarpoolServiceClient interface {
CreateRegularRoutes(ctx context.Context, in *CreateRegularRoutesRequest, opts ...grpc.CallOption) (*CreateRegularRoutesResponse, error) CreateRegularRoutes(ctx context.Context, in *CreateRegularRoutesRequest, opts ...grpc.CallOption) (*CreateRegularRoutesResponse, error)
DeleteRegularRoutes(ctx context.Context, in *DeleteRegularRoutesRequest, opts ...grpc.CallOption) (*DeleteRegularRoutesResponse, error) DeleteRegularRoutes(ctx context.Context, in *DeleteRegularRoutesRequest, opts ...grpc.CallOption) (*DeleteRegularRoutesResponse, error)
GetUserPlanning(ctx context.Context, in *GetUserPlanningRequest, opts ...grpc.CallOption) (*GetUserPlanningResponse, error) GetUserPlanning(ctx context.Context, in *GetUserPlanningRequest, opts ...grpc.CallOption) (*GetUserPlanningResponse, error)
GetPlannedTrip(ctx context.Context, in *GetPlannedTripRequest, opts ...grpc.CallOption) (*GetPlannedTripResponse, error)
// OCSS-like interaction // OCSS-like interaction
DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error) DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error)
PassengerJourneys(ctx context.Context, in *PassengerJourneysRequest, opts ...grpc.CallOption) (*PassengerJourneysResponse, error) PassengerJourneys(ctx context.Context, in *PassengerJourneysRequest, opts ...grpc.CallOption) (*PassengerJourneysResponse, error)
@ -72,6 +73,15 @@ func (c *carpoolServiceClient) GetUserPlanning(ctx context.Context, in *GetUserP
return out, nil return out, nil
} }
func (c *carpoolServiceClient) GetPlannedTrip(ctx context.Context, in *GetPlannedTripRequest, opts ...grpc.CallOption) (*GetPlannedTripResponse, error) {
out := new(GetPlannedTripResponse)
err := c.cc.Invoke(ctx, "/CarpoolService/GetPlannedTrip", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *carpoolServiceClient) DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error) { func (c *carpoolServiceClient) DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error) {
out := new(DriverJourneysResponse) out := new(DriverJourneysResponse)
err := c.cc.Invoke(ctx, "/CarpoolService/DriverJourneys", in, out, opts...) err := c.cc.Invoke(ctx, "/CarpoolService/DriverJourneys", in, out, opts...)
@ -144,6 +154,7 @@ type CarpoolServiceServer interface {
CreateRegularRoutes(context.Context, *CreateRegularRoutesRequest) (*CreateRegularRoutesResponse, error) CreateRegularRoutes(context.Context, *CreateRegularRoutesRequest) (*CreateRegularRoutesResponse, error)
DeleteRegularRoutes(context.Context, *DeleteRegularRoutesRequest) (*DeleteRegularRoutesResponse, error) DeleteRegularRoutes(context.Context, *DeleteRegularRoutesRequest) (*DeleteRegularRoutesResponse, error)
GetUserPlanning(context.Context, *GetUserPlanningRequest) (*GetUserPlanningResponse, error) GetUserPlanning(context.Context, *GetUserPlanningRequest) (*GetUserPlanningResponse, error)
GetPlannedTrip(context.Context, *GetPlannedTripRequest) (*GetPlannedTripResponse, error)
// OCSS-like interaction // OCSS-like interaction
DriverJourneys(context.Context, *DriverJourneysRequest) (*DriverJourneysResponse, error) DriverJourneys(context.Context, *DriverJourneysRequest) (*DriverJourneysResponse, error)
PassengerJourneys(context.Context, *PassengerJourneysRequest) (*PassengerJourneysResponse, error) PassengerJourneys(context.Context, *PassengerJourneysRequest) (*PassengerJourneysResponse, error)
@ -168,6 +179,9 @@ func (UnimplementedCarpoolServiceServer) DeleteRegularRoutes(context.Context, *D
func (UnimplementedCarpoolServiceServer) GetUserPlanning(context.Context, *GetUserPlanningRequest) (*GetUserPlanningResponse, error) { func (UnimplementedCarpoolServiceServer) GetUserPlanning(context.Context, *GetUserPlanningRequest) (*GetUserPlanningResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserPlanning not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetUserPlanning not implemented")
} }
func (UnimplementedCarpoolServiceServer) GetPlannedTrip(context.Context, *GetPlannedTripRequest) (*GetPlannedTripResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPlannedTrip not implemented")
}
func (UnimplementedCarpoolServiceServer) DriverJourneys(context.Context, *DriverJourneysRequest) (*DriverJourneysResponse, error) { func (UnimplementedCarpoolServiceServer) DriverJourneys(context.Context, *DriverJourneysRequest) (*DriverJourneysResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DriverJourneys not implemented") return nil, status.Errorf(codes.Unimplemented, "method DriverJourneys not implemented")
} }
@ -256,6 +270,24 @@ func _CarpoolService_GetUserPlanning_Handler(srv interface{}, ctx context.Contex
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _CarpoolService_GetPlannedTrip_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPlannedTripRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CarpoolServiceServer).GetPlannedTrip(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CarpoolService/GetPlannedTrip",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CarpoolServiceServer).GetPlannedTrip(ctx, req.(*GetPlannedTripRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CarpoolService_DriverJourneys_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _CarpoolService_DriverJourneys_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DriverJourneysRequest) in := new(DriverJourneysRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -401,6 +433,10 @@ var CarpoolService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetUserPlanning", MethodName: "GetUserPlanning",
Handler: _CarpoolService_GetUserPlanning_Handler, Handler: _CarpoolService_GetUserPlanning_Handler,
}, },
{
MethodName: "GetPlannedTrip",
Handler: _CarpoolService_GetPlannedTrip_Handler,
},
{ {
MethodName: "DriverJourneys", MethodName: "DriverJourneys",
Handler: _CarpoolService_DriverJourneys_Handler, Handler: _CarpoolService_DriverJourneys_Handler,

View File

@ -98,7 +98,7 @@ func (j *CarpoolServiceDriverJourney) ToOCSS() ocss.DriverJourney {
Duration: time.Duration(j.Duration), Duration: time.Duration(j.Duration),
Distance: j.Distance, Distance: j.Distance,
DriverDepartureLat: j.DriverDepartureLat, DriverDepartureLat: j.DriverDepartureLat,
DriverDepartureLng: j.DriverArrivalLng, DriverDepartureLng: j.DriverDepartureLng,
DriverArrivalLat: j.DriverArrivalLat, DriverArrivalLat: j.DriverArrivalLat,
DriverArrivalLng: j.DriverArrivalLng, DriverArrivalLng: j.DriverArrivalLng,
DriverDepartureAddress: j.DriverDepartureAddress, DriverDepartureAddress: j.DriverDepartureAddress,
@ -161,7 +161,7 @@ func (j *CarpoolServicePassengerJourney) ToOCSS() ocss.PassengerJourney {
Duration: time.Duration(j.Duration), Duration: time.Duration(j.Duration),
Distance: j.Distance, Distance: j.Distance,
DriverDepartureLat: j.DriverDepartureLat, DriverDepartureLat: j.DriverDepartureLat,
DriverDepartureLng: j.DriverArrivalLng, DriverDepartureLng: j.DriverDepartureLng,
DriverArrivalLat: j.DriverArrivalLat, DriverArrivalLat: j.DriverArrivalLat,
DriverArrivalLng: j.DriverArrivalLng, DriverArrivalLng: j.DriverArrivalLng,
DriverDepartureAddress: j.DriverDepartureAddress, DriverDepartureAddress: j.DriverDepartureAddress,

View File

@ -66,3 +66,24 @@ func (s *CarpoolServiceServerImpl) GetUserPlanning(ctx context.Context, req *pro
RoutesByDates: results, RoutesByDates: results,
}, nil }, 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
}

View File

@ -53,6 +53,14 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
driverDepartureLng := j.Route.Features[0].Point().Lon() driverDepartureLng := j.Route.Features[0].Point().Lon()
driverArrivalLat := j.Route.Features[1].Point().Lat() driverArrivalLat := j.Route.Features[1].Point().Lat()
driverArrivalLng := j.Route.Features[1].Point().Lon() 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) duration := time.Duration(0)
var distance *int64 var distance *int64
if len(j.Itinerary.Legs) > 2 { if len(j.Itinerary.Legs) > 2 {
@ -76,12 +84,15 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
DriverDepartureLng: &driverDepartureLng, DriverDepartureLng: &driverDepartureLng,
DriverArrivalLat: &driverArrivalLat, DriverArrivalLat: &driverArrivalLat,
DriverArrivalLng: &driverArrivalLng, DriverArrivalLng: &driverArrivalLng,
DriverDepartureAddress: driverDepartureAddress,
DriverArrivalAddress: driverArrivalAddress,
Duration: int64(duration), Duration: int64(duration),
Distance: distance, Distance: distance,
Id: journeyId, Id: journeyId,
PassengerPickupDate: timestamppb.New(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)), PassengerPickupDate: timestamppb.New(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)),
DriverDepartureDate: timestamppb.New(j.DepartureDate), DriverDepartureDate: timestamppb.New(j.DepartureDate),
Type: proto.CarpoolServiceJourneyType_PLANNED, 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() passengerArrivalLat := j.Route.Features[1].Point().Lat()
passengerArrivalLng := j.Route.Features[1].Point().Lon() passengerArrivalLng := j.Route.Features[1].Point().Lon()
passengerDepartureDate := timestamppb.New(j.DepartureDate) 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)) driverDepartureDate := timestamppb.New(j.DepartureDate.Add(-j.Itinerary.Legs[0].Duration))
duration := time.Duration(0) duration := time.Duration(0)
var distance *int64 var distance *int64
log.Debug().Any("itinerary", j.Itinerary).Msg("debug itinerary")
if len(j.Itinerary.Legs) > 2 { if len(j.Itinerary.Legs) > 2 {
duration = j.Itinerary.Legs[1].Duration / time.Second duration = j.Itinerary.Legs[1].Duration / time.Second
dist := int64(j.Itinerary.Legs[1].Distance) dist := int64(j.Itinerary.Legs[1].Distance)
@ -142,6 +160,8 @@ func (s *CarpoolServiceServerImpl) PassengerJourneys(ctx context.Context, req *p
PassengerPickupLng: passengerDepartureLng, PassengerPickupLng: passengerDepartureLng,
PassengerDropLat: passengerArrivalLat, PassengerDropLat: passengerArrivalLat,
PassengerDropLng: passengerArrivalLng, PassengerDropLng: passengerArrivalLng,
PassengerPickupAddress: passengerPickupAddress,
PassengerDropAddress: passengerDropAddress,
DriverDepartureLat: &req.DepartureLat, DriverDepartureLat: &req.DepartureLat,
DriverDepartureLng: &req.DepartureLng, DriverDepartureLng: &req.DepartureLng,
DriverArrivalLat: &req.ArrivalLat, DriverArrivalLat: &req.ArrivalLat,
@ -152,6 +172,7 @@ func (s *CarpoolServiceServerImpl) PassengerJourneys(ctx context.Context, req *p
PassengerPickupDate: passengerDepartureDate, PassengerPickupDate: passengerDepartureDate,
DriverDepartureDate: driverDepartureDate, DriverDepartureDate: driverDepartureDate,
Type: proto.CarpoolServiceJourneyType_PLANNED, Type: proto.CarpoolServiceJourneyType_PLANNED,
JourneyPolyline: &j.Itinerary.Summary.Polyline,
}) })
} }

View File

@ -274,7 +274,7 @@ func (s MongoDBStorage) StoreRouteSchedules(js []internal.PlannedRouteSchedule)
return s.PersistedKVPut(documents) return s.PersistedKVPut(documents)
} }
func (s MongoDBStorage) GetRouteSchedules(id string) (*internal.PlannedRouteSchedule, error) { func (s MongoDBStorage) GetRouteSchedule(id string) (*internal.PlannedRouteSchedule, error) {
var result internal.PlannedRouteSchedule var result internal.PlannedRouteSchedule
err := s.PersistedKVGet(id, &result) err := s.PersistedKVGet(id, &result)

View File

@ -23,7 +23,7 @@ type Storage interface {
StoreSearchResults([]internal.SearchResult) error StoreSearchResults([]internal.SearchResult) error
GetSearchResult(id string) (*internal.SearchResult, error) GetSearchResult(id string) (*internal.SearchResult, error)
StoreRouteSchedules([]internal.PlannedRouteSchedule) error StoreRouteSchedules([]internal.PlannedRouteSchedule) error
GetRouteSchedules(id string) (*internal.PlannedRouteSchedule, error) GetRouteSchedule(id string) (*internal.PlannedRouteSchedule, error)
} }
func NewStorage(cfg *viper.Viper) (Storage, error) { func NewStorage(cfg *viper.Viper) (Storage, error) {