Add tiles management
This commit is contained in:
@@ -4,9 +4,13 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/helpers"
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/tiles"
|
||||
"git.coopgo.io/coopgo-platform/routing-service/encoding/polylines"
|
||||
"github.com/google/uuid"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/paulmach/orb/simplify"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
@@ -26,10 +30,23 @@ func (h *CarpoolServiceHandler) CreateRegularRoutes(routes []*geojson.FeatureCol
|
||||
return errors.New("no polyline found in properties from feature collection")
|
||||
}
|
||||
|
||||
lineString := geojson.NewFeature(polylines.Decode(&polyline, 5))
|
||||
lineString.Properties["encoded_polyline"] = polyline
|
||||
linestring := polylines.Decode(&polyline, 5)
|
||||
simplified_linestring := simplify.DouglasPeucker(0.003).Simplify(linestring.Clone())
|
||||
|
||||
r.Append(lineString)
|
||||
// Simplification tests
|
||||
// Antibes -> Rennes
|
||||
// Without Simplify : 12230
|
||||
// 0.01 -> 129
|
||||
// 0.005 -> 230
|
||||
// 0.003 -> 338
|
||||
|
||||
lsFeature := geojson.NewFeature(simplified_linestring)
|
||||
lsFeature.Properties["encoded_polyline"] = polyline
|
||||
|
||||
r.Append(lsFeature)
|
||||
|
||||
gridids := tiles.LineStringGridIds(simplified_linestring.(orb.LineString))
|
||||
r.ExtraMembers["grid_ids"] = gridids
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +57,18 @@ func (h *CarpoolServiceHandler) CreateRegularRoutes(routes []*geojson.FeatureCol
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate time.Time, maxDepartureDate time.Time) (map[string][]PlannedRouteSchedule, error) {
|
||||
func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate time.Time, maxDepartureDate time.Time) (map[string][]helpers.PlannedRouteSchedule, error) {
|
||||
log.Debug().
|
||||
Str("user_id", userid).
|
||||
Time("min_departure_date", minDepartureDate).
|
||||
Time("max_departure_date", maxDepartureDate).
|
||||
Msg("carpool service handler - GetUserPlanning")
|
||||
|
||||
results := map[string][]PlannedRouteSchedule{}
|
||||
results := map[string][]helpers.PlannedRouteSchedule{}
|
||||
|
||||
current_date := minDepartureDate
|
||||
for current_date.Before(maxDepartureDate) {
|
||||
results[current_date.Format("2006-01-02")] = []PlannedRouteSchedule{}
|
||||
results[current_date.Format("2006-01-02")] = []helpers.PlannedRouteSchedule{}
|
||||
current_date = current_date.Add(24 * time.Hour)
|
||||
}
|
||||
|
||||
@@ -62,7 +79,7 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
|
||||
}
|
||||
|
||||
for _, r := range routes {
|
||||
rr := RegularRoute(*r)
|
||||
rr := helpers.RegularRoute(*r)
|
||||
schedules, err := rr.PlannedJourneySchedules(minDepartureDate, maxDepartureDate)
|
||||
if err != nil {
|
||||
log.Error().Err(err)
|
||||
|
||||
Reference in New Issue
Block a user