Skip to content

Commit

Permalink
Merge pull request #4 from munterfi/fix/add-transit-stop-link
Browse files Browse the repository at this point in the history
fix: add stop links to transit routes
  • Loading branch information
munterfi authored Nov 14, 2024
2 parents 875a484 + 4b545d4 commit b62eaa8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ TransitRoute buildTransitRoute(TransitLineInfo transitLineInfo, List<RouteElemen

// add first stop
RouteStop firstRouteStop = (RouteStop) directedRouteElements.getFirst();
TransitStopFacility stopFacility = stopFacilities.get(firstRouteStop.getStopFacilityInfo().getId());
TransitRouteStop transitRouteStop = factory.createTransitRouteStop(stopFacility, OptionalTime.undefined(),
final TransitStopFacility[] stopFacility = {stopFacilities.get(firstRouteStop.getStopFacilityInfo().getId())};
TransitRouteStop transitRouteStop = factory.createTransitRouteStop(stopFacility[0], OptionalTime.undefined(),
OptionalTime.zeroSeconds());
routeStops.add(transitRouteStop);
routeLinks.add(stopFacility[0].getLinkId());

// loop over route elements, set first stop as last element and start with second element
for (int i = 1; i < directedRouteElements.size(); i++) {
Expand All @@ -83,7 +84,6 @@ TransitRoute buildTransitRoute(TransitLineInfo transitLineInfo, List<RouteElemen
// visit element
currentElement.accept(new RouteElementVisitor() {


@Override
public void visit(RouteStop routeStop) {
travelTime[0] = travelTime[0] + routeStop.getTravelTime().toSeconds();
Expand All @@ -95,8 +95,8 @@ public void visit(RouteStop routeStop) {
travelTime[0] + dwellTime);

// add route stop
TransitStopFacility stopFacility = stopFacilities.get(routeStop.getStopFacilityInfo().getId());
TransitRouteStop transitRouteStop = factory.createTransitRouteStop(stopFacility, arrivalOffset,
stopFacility[0] = stopFacilities.get(routeStop.getStopFacilityInfo().getId());
TransitRouteStop transitRouteStop = factory.createTransitRouteStop(stopFacility[0], arrivalOffset,
departureOffset);
routeStops.add(transitRouteStop);

Expand All @@ -110,8 +110,9 @@ public void visit(RoutePass passInfo) {

});

// connect stop facilities on network
// connect stop facilities on network and add stop link
routeLinks.addAll(connect(stopFacilities, addedSegments, transitLineInfo, lastElement, currentElement));
routeLinks.add(stopFacility[0].getLinkId());
}

return factory.createTransitRoute(transitLine,
Expand Down

0 comments on commit b62eaa8

Please sign in to comment.