public class DefaultFareServiceImpl extends Object implements FareService, Serializable
Modifier and Type | Field and Description |
---|---|
protected Map<Fare.FareType,Collection<FareRuleSet>> |
fareRulesPerType
For each fare type (regular, student, etc...) the collection of rules that apply.
|
Constructor and Description |
---|
DefaultFareServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addFareRules(Fare.FareType fareType,
Collection<FareRuleSet> fareRules) |
protected float |
addFares(List<org.opentripplanner.routing.impl.Ride> ride0,
List<org.opentripplanner.routing.impl.Ride> ride1,
float cost0,
float cost1) |
protected float |
calculateCost(Fare.FareType fareType,
List<org.opentripplanner.routing.impl.Ride> rides,
Collection<FareRuleSet> fareRules) |
protected List<org.opentripplanner.routing.impl.Ride> |
createRides(GraphPath path) |
Fare |
getCost(GraphPath path) |
protected float |
getLowestCost(Fare.FareType fareType,
List<org.opentripplanner.routing.impl.Ride> rides,
Collection<FareRuleSet> fareRules) |
protected static Money |
getMoney(Currency currency,
float cost) |
protected boolean |
populateFare(Fare fare,
Currency currency,
Fare.FareType fareType,
List<org.opentripplanner.routing.impl.Ride> rides,
Collection<FareRuleSet> fareRules)
Builds the Fare object for the given currency, fareType and fareRules.
|
protected Map<Fare.FareType,Collection<FareRuleSet>> fareRulesPerType
public void addFareRules(Fare.FareType fareType, Collection<FareRuleSet> fareRules)
public Fare getCost(GraphPath path)
getCost
in interface FareService
protected float addFares(List<org.opentripplanner.routing.impl.Ride> ride0, List<org.opentripplanner.routing.impl.Ride> ride1, float cost0, float cost1)
protected float getLowestCost(Fare.FareType fareType, List<org.opentripplanner.routing.impl.Ride> rides, Collection<FareRuleSet> fareRules)
protected boolean populateFare(Fare fare, Currency currency, Fare.FareType fareType, List<org.opentripplanner.routing.impl.Ride> rides, Collection<FareRuleSet> fareRules)
Besides calculating the lowest fare, we also break down the fare and which routes correspond to which components. Note that even if we cannot get a lowest fare (if some rides don't have fare rules), there will still be a breakdown for those parts which have fares.
As an example, given the rides A-B and B-C. Where A-B and B-C have fares of 10 each, 2 fare detail objects are added, one with fare 10 for A-B and one with fare 10 for B-C.
If we add the rule for A-C with a fare of 15, we will get 1 fare detail object with fare 15, which lists both A-B and B-C as routes involved.
If our only rule were A-B with a fare of 10, we would have no lowest fare, but we will still have one fare detail with fare 10 for the route A-B. B-C will not just not be listed at all.
protected float calculateCost(Fare.FareType fareType, List<org.opentripplanner.routing.impl.Ride> rides, Collection<FareRuleSet> fareRules)
Copyright © 2018. All rights reserved.