Skip to content

Commit

Permalink
Rename individual leg types
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-albers committed Feb 25, 2022
1 parent 7cd7e63 commit c9d3218
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Sources/TripKit/Model/Leg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public class IndividualLeg: NSObject, Leg, NSSecureCoding {
}

public enum `Type`: Int {
case WALK, BIKE, CAR, TRANSFER
case walk, bike, car, transfer
}

struct PropertyKey {
Expand Down
4 changes: 2 additions & 2 deletions Sources/TripKit/Provider/AbstractEfaMobileProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ public class AbstractEfaMobileProvider: AbstractEfaProvider {
}
let addTime: TimeInterval = !legs.isEmpty ? max(0, -departure.minTime.timeIntervalSince(legs.last!.maxTime)) : 0
if lineDestination.line === Line.FOOTWAY {
legs.append(IndividualLeg(type: .WALK, departureTime: departure.minTime.addingTimeInterval(addTime), departure: departure.location, arrival: arrival.location, arrivalTime: arrival.maxTime.addingTimeInterval(addTime), distance: 0, path: path))
legs.append(IndividualLeg(type: .walk, departureTime: departure.minTime.addingTimeInterval(addTime), departure: departure.location, arrival: arrival.location, arrivalTime: arrival.maxTime.addingTimeInterval(addTime), distance: 0, path: path))
} else if lineDestination.line === Line.TRANSFER {
legs.append(IndividualLeg(type: .TRANSFER, departureTime: departure.minTime.addingTimeInterval(addTime), departure: departure.location, arrival: arrival.location, arrivalTime: arrival.maxTime.addingTimeInterval(addTime), distance: 0, path: path))
legs.append(IndividualLeg(type: .transfer, departureTime: departure.minTime.addingTimeInterval(addTime), departure: departure.location, arrival: arrival.location, arrivalTime: arrival.maxTime.addingTimeInterval(addTime), distance: 0, path: path))
} else if lineDestination.line === Line.DO_NOT_CHANGE {
if let last = legs.last as? PublicLeg {
var lastMessage = "Nicht umsteigen, Weiterfahrt im selben Fahrzeug möglich."
Expand Down
6 changes: 3 additions & 3 deletions Sources/TripKit/Provider/AbstractEfaWebProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,11 @@ public class AbstractEfaWebProvider: AbstractEfaProvider {
} else if meansOfTransportType == 98 && meansOfTransportProductName == "gesicherter Anschluss" {
// ignore
} else if meansOfTransportType == 99 && meansOfTransportProductName == "Fussweg" {
processIndividualLeg(partialRoute, &legs, .WALK, departureTime, departureLocation, arrivalTime, arrivalLocation)
processIndividualLeg(partialRoute, &legs, .walk, departureTime, departureLocation, arrivalTime, arrivalLocation)
} else if meansOfTransportType == 100 && (meansOfTransportProductName == nil || meansOfTransportProductName == "Fussweg") {
processIndividualLeg(partialRoute, &legs, .WALK, departureTime, departureLocation, arrivalTime, arrivalLocation)
processIndividualLeg(partialRoute, &legs, .walk, departureTime, departureLocation, arrivalTime, arrivalLocation)
} else if meansOfTransportType == 105 && meansOfTransportProductName == "Taxi" {
processIndividualLeg(partialRoute, &legs, .CAR, departureTime, departureLocation, arrivalTime, arrivalLocation)
processIndividualLeg(partialRoute, &legs, .car, departureTime, departureLocation, arrivalTime, arrivalLocation)
} else {
throw ParseError(reason: "unknown means of transport: \(meansOfTransportType) \(meansOfTransportProductName ?? "")")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public class AbstractHafasClientInterfaceProvider: AbstractHafasProvider {
let gis = sec["gis"]
let distance = gis["distance"].intValue
let path = parsePath(encodedPolyList: encodedPolyList, jny: gis)
processIndividualLeg(legs: &legs, type: .WALK, departureStop: departureStop, arrivalStop: arrivalStop, distance: distance, path: path)
processIndividualLeg(legs: &legs, type: .walk, departureStop: departureStop, arrivalStop: arrivalStop, distance: distance, path: path)
case "KISS":
let gis = sec["gis"]
let distance = gis["distance"].intValue
Expand All @@ -514,7 +514,7 @@ public class AbstractHafasClientInterfaceProvider: AbstractHafasProvider {
let line = Line(id: nil, network: nil, product: .onDemand, label: providerName, name: providerName, number: nil, vehicleNumber: nil, style: lineStyle(network: nil, product: .onDemand, label: providerName), attr: nil, message: nil, direction: nil)
legs.append(PublicLeg(line: line, destination: arrivalStop.location, departure: departureStop, arrival: arrivalStop, intermediateStops: [], message: nil, path: path, journeyContext: nil, loadFactor: nil))
} else {
processIndividualLeg(legs: &legs, type: .WALK, departureStop: departureStop, arrivalStop: arrivalStop, distance: distance, path: path)
processIndividualLeg(legs: &legs, type: .walk, departureStop: departureStop, arrivalStop: arrivalStop, distance: distance, path: path)
}
default:
throw ParseError(reason: "could not parse outcon sec type \(sec["type"].stringValue)")
Expand Down
8 changes: 4 additions & 4 deletions Sources/TripKit/Provider/AbstractHafasLegacyProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1043,16 +1043,16 @@ public class AbstractHafasLegacyProvider: AbstractHafasProvider {
let individualType: IndividualLeg.`Type`
if let routingType = routingType {
if routingType == "FOOT" {
individualType = .WALK
individualType = .walk
} else if routingType == "BIKE" {
individualType = .BIKE
individualType = .bike
} else if routingType == "CAR" || routingType == "P+R" {
individualType = .CAR
individualType = .car
} else {
throw ParseError(reason: "unknown routing type \(routingType)")
}
} else {
individualType = type == 1 ? .WALK : .TRANSFER
individualType = type == 1 ? .walk : .transfer
}

let departureTime = Date(timeIntervalSince1970: predictedDepartureTime != 0 ? predictedDepartureTime : plannedDepartureTime)
Expand Down
6 changes: 3 additions & 3 deletions Sources/TripKit/Provider/Implementations/HvvProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ public class HvvProvider: AbstractNetworkProvider {
switch serviceType {
case "FOOTPATH":
// Individual leg
return IndividualLeg(type: .WALK, departureTime: departure.time, departure: departure.location, arrival: arrival.location, arrivalTime: arrival.time, distance: 0, path: path)
return IndividualLeg(type: .walk, departureTime: departure.time, departure: departure.location, arrival: arrival.location, arrivalTime: arrival.time, distance: 0, path: path)
case "BICYCLE":
return IndividualLeg(type: .BIKE, departureTime: departure.time, departure: departure.location, arrival: arrival.location, arrivalTime: arrival.time, distance: 0, path: path)
return IndividualLeg(type: .bike, departureTime: departure.time, departure: departure.location, arrival: arrival.location, arrivalTime: arrival.time, distance: 0, path: path)
case "CHANGE", "CHANGE_SAME_PLATFORM":
if departure.time == arrival.time {
return nil
}
return IndividualLeg(type: .TRANSFER, departureTime: departure.time, departure: departure.location, arrival: arrival.location, arrivalTime: arrival.time, distance: 0, path: path)
return IndividualLeg(type: .transfer, departureTime: departure.time, departure: departure.location, arrival: arrival.location, arrivalTime: arrival.time, distance: 0, path: path)
case "BUS", "TRAIN", "SHIP":
// Public leg
let servingLine = parseLineAndDestination(json: json["line"], directionType: nil)
Expand Down
2 changes: 1 addition & 1 deletion Sources/TripKit/Provider/Implementations/VrsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ public class VrsProvider: AbstractNetworkProvider {
if type == "walk" {
let distance = segment["distance"] as? Int ?? 0
let addTime: TimeInterval = !legs.isEmpty ? max(0, -departurePlanned.timeIntervalSince(legs.last!.maxTime)) : 0
legs.append(IndividualLeg(type: .WALK, departureTime: departurePlanned.addingTimeInterval(addTime), departure: segmentOrigin, arrival: segmentDestination, arrivalTime: arrivalPlanned.addingTimeInterval(addTime), distance: distance, path: points))
legs.append(IndividualLeg(type: .walk, departureTime: departurePlanned.addingTimeInterval(addTime), departure: segmentOrigin, arrival: segmentDestination, arrivalTime: arrivalPlanned.addingTimeInterval(addTime), distance: distance, path: points))
} else if type == "publicTransport" {
let directionLoc: Location?
guard let lineObject = segment["line"] as? [String: Any] else {
Expand Down

0 comments on commit c9d3218

Please sign in to comment.