Add tiles management
This commit is contained in:
@@ -37,10 +37,15 @@ func Run(done chan error, cfg *viper.Viper, handler *handler.CarpoolServiceHandl
|
||||
return
|
||||
}
|
||||
|
||||
err = http.ListenAndServe(address, ocss.NewServer(service))
|
||||
server := ocss.NewServer(service)
|
||||
server.AddOperator("mobilaude_preprod", "wxvSwUpTTZ5wiAxrHpPfDsijz88w6tMW")
|
||||
server.AuthorizedOperators = append(server.AuthorizedOperators, ocss.AuthorizedOperator{
|
||||
Operator: "mobilaude",
|
||||
ApiKey: "$2y$10$TJuDZDu.mqy5dDKGMSfxSO5f6pz/36XVrAyQ1CXJd63ccjRlX7gpC",
|
||||
})
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: ocss.NewServer(service),
|
||||
Handler: server,
|
||||
Addr: address,
|
||||
WriteTimeout: 15 * time.Second,
|
||||
ReadTimeout: 15 * time.Second,
|
||||
|
||||
@@ -21,12 +21,64 @@ func (s *OCSSApiService) GetDriverJourneys(ctx context.Context, departureLat flo
|
||||
minDate := departureDate.Add(-td * time.Second)
|
||||
maxDate := departureDate.Add(td * time.Second)
|
||||
|
||||
result, err := s.Handler.GetDriverJourneys(departure, arrival, minDate, maxDate)
|
||||
journeys, err := s.Handler.GetDriverJourneys(departure, arrival, departureRadius, arrivalRadius, minDate, maxDate, count)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
results := []ocss.DriverJourney{}
|
||||
|
||||
for _, j := range journeys {
|
||||
usermap := j.Route.ExtraMembers["user"].(map[string]any)
|
||||
journeyId := j.Route.ExtraMembers.MustString("journey_id")
|
||||
driverDepartureLat := j.Route.Features[0].Point().Lat()
|
||||
driverDepartureLng := j.Route.Features[0].Point().Lon()
|
||||
driverArrivalLat := j.Route.Features[1].Point().Lat()
|
||||
driverArrivalLng := j.Route.Features[1].Point().Lon()
|
||||
driverDepartureDate := ocss.JSONTime(j.DepartureDate)
|
||||
duration := time.Duration(0)
|
||||
var distance *int64
|
||||
if len(j.Itinerary.Legs) > 2 {
|
||||
duration = j.Itinerary.Legs[1].Duration
|
||||
dist := int64(j.Itinerary.Legs[1].Distance)
|
||||
distance = &dist
|
||||
}
|
||||
|
||||
results = append(results, ocss.DriverJourney{
|
||||
DriverTrip: ocss.DriverTrip{
|
||||
Driver: ocss.User{
|
||||
ID: usermap["id"].(string),
|
||||
Operator: usermap["opeator"].(string),
|
||||
Alias: usermap["alias"].(string),
|
||||
},
|
||||
Trip: ocss.Trip{
|
||||
Operator: "ridygo.fr",
|
||||
PassengerPickupLat: departureLat,
|
||||
PassengerPickupLng: departureLng,
|
||||
PassengerDropLat: arrivalLat,
|
||||
PassengerDropLng: arrivalLng,
|
||||
DriverDepartureLat: &driverDepartureLat,
|
||||
DriverDepartureLng: &driverDepartureLng,
|
||||
DriverArrivalLat: &driverArrivalLat,
|
||||
DriverArrivalLng: &driverArrivalLng,
|
||||
Duration: duration,
|
||||
Distance: distance,
|
||||
},
|
||||
},
|
||||
JourneySchedule: ocss.JourneySchedule{
|
||||
ID: &journeyId,
|
||||
PassengerPickupDate: ocss.JSONTime(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)),
|
||||
DriverDepartureDate: &driverDepartureDate,
|
||||
Type: ocss.Planned,
|
||||
},
|
||||
// Price: &ocss.Price{
|
||||
// Amount: ,
|
||||
// Currency: "EUR",
|
||||
// },
|
||||
})
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func (s *OCSSApiService) GetPassengerJourneys(ctx context.Context, departureLat float64, departureLng float64, arrivalLat float64, arrivalLng float64, departureDate time.Time, timeDelta *time.Duration, departureRadius *float64, arrivalRadius *float64, count *int64) ([]ocss.PassengerJourney, error) {
|
||||
|
||||
Reference in New Issue
Block a user