Search in sources :

Example 6 with FareAttribute

use of org.opentripplanner.model.FareAttribute in project OpenTripPlanner by opentripplanner.

the class DefaultFareServiceFactory method fillFareRules.

protected void fillFareRules(Collection<FareAttribute> fareAttributes, Collection<FareRule> fareRules, Map<FeedScopedId, FareRuleSet> fareRuleSet) {
    /*
         * Create an empty FareRuleSet for each FareAttribute, as some FareAttribute may have no
         * rules attached to them.
         */
    for (FareAttribute fare : fareAttributes) {
        FeedScopedId id = fare.getId();
        FareRuleSet fareRule = fareRuleSet.get(id);
        if (fareRule == null) {
            fareRule = new FareRuleSet(fare);
            fareRuleSet.put(id, fareRule);
        }
    }
    /*
         * For each fare rule, add it to the FareRuleSet of the fare.
         */
    for (FareRule rule : fareRules) {
        FareAttribute fare = rule.getFare();
        FeedScopedId id = fare.getId();
        FareRuleSet fareRule = fareRuleSet.get(id);
        if (fareRule == null) {
            // Should never happen by design
            LOG.error("Inexistant fare ID in fare rule: " + id);
            continue;
        }
        String contains = rule.getContainsId();
        if (contains != null) {
            fareRule.addContains(contains);
        }
        String origin = rule.getOriginId();
        String destination = rule.getDestinationId();
        if (origin != null || destination != null) {
            fareRule.addOriginDestination(origin, destination);
        }
        Route route = rule.getRoute();
        if (route != null) {
            FeedScopedId routeId = route.getId();
            fareRule.addRoute(routeId);
        }
    }
}
Also used : FareAttribute(org.opentripplanner.model.FareAttribute) FareRule(org.opentripplanner.model.FareRule) FeedScopedId(org.opentripplanner.model.FeedScopedId) FareRuleSet(org.opentripplanner.routing.core.FareRuleSet) Route(org.opentripplanner.model.Route)

Example 7 with FareAttribute

use of org.opentripplanner.model.FareAttribute in project OpenTripPlanner by opentripplanner.

the class DefaultFareServiceFactory method fillFareRules.

protected void fillFareRules(Collection<FareAttribute> fareAttributes, Collection<FareRule> fareRules, Map<FeedScopedId, FareRuleSet> fareRuleSet) {
    /*
         * Create an empty FareRuleSet for each FareAttribute, as some FareAttribute may have no
         * rules attached to them.
         */
    for (FareAttribute fare : fareAttributes) {
        FeedScopedId id = fare.getId();
        FareRuleSet fareRule = fareRuleSet.get(id);
        if (fareRule == null) {
            fareRule = new FareRuleSet(fare);
            fareRuleSet.put(id, fareRule);
        }
    }
    /*
         * For each fare rule, add it to the FareRuleSet of the fare.
         */
    for (FareRule rule : fareRules) {
        FareAttribute fare = rule.getFare();
        FeedScopedId id = fare.getId();
        FareRuleSet fareRule = fareRuleSet.get(id);
        if (fareRule == null) {
            // Should never happen by design
            LOG.error("Inexistant fare ID in fare rule: " + id);
            continue;
        }
        String contains = rule.getContainsId();
        if (contains != null) {
            fareRule.addContains(contains);
        }
        String origin = rule.getOriginId();
        String destination = rule.getDestinationId();
        if (origin != null || destination != null) {
            fareRule.addOriginDestination(origin, destination);
        }
        Route route = rule.getRoute();
        if (route != null) {
            FeedScopedId routeId = route.getId();
            fareRule.addRoute(routeId);
        }
    }
}
Also used : FareAttribute(org.opentripplanner.model.FareAttribute) FareRule(org.opentripplanner.model.FareRule) FeedScopedId(org.opentripplanner.model.FeedScopedId) FareRuleSet(org.opentripplanner.routing.core.FareRuleSet) Route(org.opentripplanner.model.Route)

Example 8 with FareAttribute

use of org.opentripplanner.model.FareAttribute in project OpenTripPlanner by opentripplanner.

the class FareAttributeMapper method doMap.

private FareAttribute doMap(org.onebusaway.gtfs.model.FareAttribute rhs) {
    FareAttribute lhs = new FareAttribute(mapAgencyAndId(rhs.getId()));
    lhs.setPrice(rhs.getPrice());
    lhs.setCurrencyType(rhs.getCurrencyType());
    lhs.setPaymentMethod(rhs.getPaymentMethod());
    lhs.setTransfers(rhs.getTransfers());
    lhs.setTransferDuration(rhs.getTransferDuration());
    lhs.setYouthPrice(rhs.getYouthPrice());
    lhs.setSeniorPrice(rhs.getSeniorPrice());
    lhs.setJourneyDuration(rhs.getJourneyDuration());
    return lhs;
}
Also used : FareAttribute(org.opentripplanner.model.FareAttribute)

Aggregations

FareAttribute (org.opentripplanner.model.FareAttribute)8 FeedScopedId (org.opentripplanner.model.FeedScopedId)7 FareRuleSet (org.opentripplanner.routing.core.FareRuleSet)4 FareRule (org.opentripplanner.model.FareRule)3 HashSet (java.util.HashSet)2 Route (org.opentripplanner.model.Route)2 Duration (java.time.Duration)1 ZonedDateTime (java.time.ZonedDateTime)1