TKWaypointRouter

public enum TKWaypointRouter

Provides helper methods around TripGo API’s waypoint.json endpoint

For planning A-to-B-via-C trips, including building trip that follow a specific segment pattern.

Trip patterns + next trips

  • Calculates a trip based on the provided trip. Departure time is the provided time or now, whichever is later.

    Declaration

    Swift

    public static func fetchNextTrip(after trip: Trip, usingPrivateVehicles vehicles: [TKVehicular] = [], completion: @escaping (Result<Trip, Error>) -> Void)

    Parameters

    trip

    The trip for which to get the next departure

    vehicles

    Optional vehicles that should be for private vehicles segments

    completion

    Handler called on success with a trip or on error (with optional Error)

  • Calculates a trip from the provided pattern. Departure time is the provided time or now, whichever is later.

    Declaration

    Swift

    public static func fetchTrip(pattern: [TKSegmentPattern], departure: Date, usingPrivateVehicles vehicles: [TKVehicular] = [], into tripKitContext: NSManagedObjectContext = TripKit.shared.viewContext, in region: TKRegion, completion: @escaping (Result<Trip, Error>) -> Void)

    Parameters

    pattern

    The pattern that’s used as input to calculate a trip

    departure

    Departure time for new trip (ignored if before current time)

    vehicles

    Optional vehicles that should be for private vehicles segments

    tripKit

    TripKit instance into which the new trip will be inserted

    region

    The region where the trip starts

    completion

    Handler called on success with a trip or on error (with optional Error)

Tuning public transport trips

  • Calculates a trip from the provided trip (implied by the segment), which moves where to get on or off the provided segment to the provided visit.

    Declaration

    Swift

    public static func fetchTrip(moving segment: TKSegment, to visit: StopVisits, atStart: Bool, usingPrivateVehicles vehicles: [TKVehicular] = [], completion: @escaping (Result<Trip, Error>) -> Void)

    Parameters

    segment

    The segment for which to change getting on/off

    visit

    The visit along this segment to get on/off

    atStart

    true if getting on should change, false if getting off should change

    vehicles

    The private vehicles to use for private vehicle segments

    completion

    Handler called on success with a trip or on error (with optional Error)

  • Undocumented

    Declaration

    Swift

    public static func fetchTrip(replacing segment: TKSegment, with entry: DLSEntry, usingPrivateVehicles vehicles: [TKVehicular] = [], completion: @escaping (Result<Trip, Error>) -> Void)

Picking different shared vehicles

A-to-B-to-C Routing

Helpers

  • For calculating a trip and adding it as a stand-alone trip / request to TripKit

    Declaration

    Swift

    public static func fetchTrip(input: TKWaypointRouter.Input, region: TKRegion? = nil, into context: NSManagedObjectContext, completion: @escaping (Result<Trip, Error>) -> Void)

Input

  • Undocumented

    Declaration

    Swift

    public struct Input : Codable
  • Undocumented

    See more

    Declaration

    Swift

    public struct Segment : Equatable
    extension TKWaypointRouter.Segment: Codable