
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
The newest version!
package org.opentripplanner.gtfs.mapping;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.opentripplanner.framework.collection.MapUtils;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.organization.Agency;
/** Responsible for mapping GTFS Agency into the OTP model. */
class AgencyMapper {
private final Map mappedAgencies = new HashMap<>();
private final 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) {
return Agency
.of(new FeedScopedId(feedId, rhs.getId()))
.withName(rhs.getName())
.withTimezone(rhs.getTimezone())
.withUrl(rhs.getUrl())
.withLang(rhs.getLang())
.withPhone(rhs.getPhone())
.withFareUrl(rhs.getFareUrl())
.withBrandingUrl(rhs.getBrandingUrl())
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy