forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRouteMapper.java
More file actions
49 lines (39 loc) · 1.65 KB
/
RouteMapper.java
File metadata and controls
49 lines (39 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.opentripplanner.gtfs.mapping;
import org.opentripplanner.model.Route;
import org.opentripplanner.util.MapUtils;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/** Responsible for mapping GTFS Route into the OTP model. */
class RouteMapper {
private final AgencyMapper agencyMapper;
private final Map<org.onebusaway.gtfs.model.Route, Route> mappedRoutes = new HashMap<>();
RouteMapper(AgencyMapper agencyMapper) {
this.agencyMapper = agencyMapper;
}
Collection<Route> map(Collection<org.onebusaway.gtfs.model.Route> agencies) {
return MapUtils.mapToList(agencies, this::map);
}
/** Map from GTFS to OTP model, {@code null} safe. */
Route map(org.onebusaway.gtfs.model.Route orginal) {
return orginal == null ? null : mappedRoutes.computeIfAbsent(orginal, this::doMap);
}
private Route doMap(org.onebusaway.gtfs.model.Route rhs) {
Route lhs = new Route();
lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId()));
lhs.setAgency(agencyMapper.map(rhs.getAgency()));
lhs.setShortName(rhs.getShortName());
lhs.setLongName(rhs.getLongName());
lhs.setType(rhs.getType());
lhs.setDesc(rhs.getDesc());
lhs.setUrl(rhs.getUrl());
lhs.setColor(rhs.getColor());
lhs.setTextColor(rhs.getTextColor());
lhs.setRouteBikesAllowed(rhs.getRouteBikesAllowed());
lhs.setBikesAllowed(rhs.getBikesAllowed());
lhs.setSortOrder(rhs.getSortOrder());
lhs.setBrandingUrl(rhs.getBrandingUrl());
lhs.setEligibilityRestricted(rhs.getEligibilityRestricted());
return lhs;
}
}