org.opentripplanner.gtfs.mapping.AgencyMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.gtfs.mapping;
import org.opentripplanner.model.Agency;
import org.opentripplanner.model.FeedScopedId;
import org.opentripplanner.util.MapUtils;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/** Responsible for mapping GTFS Agency into the OTP model. */
class AgencyMapper {
private final Map mappedAgencies = new HashMap<>();
private String feedId;
public AgencyMapper(String feedId) {
this.feedId = feedId;
}
Collection map(Collection agencies) {
return MapUtils.mapToList(agencies, this::map);
}
/** Map from GTFS to OTP model, {@code null} safe. */
Agency map(org.onebusaway.gtfs.model.Agency orginal) {
return orginal == null ? null : mappedAgencies.computeIfAbsent(orginal, this::doMap);
}
private Agency doMap(org.onebusaway.gtfs.model.Agency rhs) {
Agency lhs = new Agency(
new FeedScopedId(feedId, rhs.getId()),
rhs.getName(),
rhs.getTimezone()
);
lhs.setUrl(rhs.getUrl());
lhs.setLang(rhs.getLang());
lhs.setPhone(rhs.getPhone());
lhs.setFareUrl(rhs.getFareUrl());
lhs.setBrandingUrl(rhs.getBrandingUrl());
return lhs;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy