diff --git a/src/main/java/ch/naviqore/service/gtfs/raptor/convert/GtfsToRaptorConverter.java b/src/main/java/ch/naviqore/service/gtfs/raptor/convert/GtfsToRaptorConverter.java index 67ac63b..080401f 100644 --- a/src/main/java/ch/naviqore/service/gtfs/raptor/convert/GtfsToRaptorConverter.java +++ b/src/main/java/ch/naviqore/service/gtfs/raptor/convert/GtfsToRaptorConverter.java @@ -44,12 +44,6 @@ public GtfsToRaptorConverter(GtfsSchedule schedule, List stopIds = subRoute.getStopsSequence().stream().map(Stop::getId).toList(); + for (String stopId : stopIds) { + if (!addedStops.contains(stopId)) { + builder.addStop(stopId); + addedStops.add(stopId); + } + } + + // add sub route as raptor route builder.addRoute(subRoute.getId(), stopIds); // add trips of sub route - for (var trip : subRoute.getTrips()) { + for (Trip trip : subRoute.getTrips()) { builder.addTrip(trip.getId(), subRoute.getId()); List stopTimes = trip.getStopTimes(); for (int i = 0; i < stopTimes.size(); i++) { @@ -81,21 +84,12 @@ private void addRoute(GtfsRoutePartitioner.SubRoute subRoute) { /** * Processes all types of transfers, ensuring the correct order of precedence: - *
    - *
  1. - * Additional transfers: These transfers have the lowest priority and are processed first. - *
  2. - *
  3. - * Parent-child derived transfers: If a transfer is defined between two parent stops - * (e.g., A to B), this method derives corresponding transfers for their child stops - * (e.g., A1, A2, ... to B1, B2, ...). - *
  4. - *
  5. - * GTFS schedule-defined transfers: Transfers explicitly defined in the GTFS schedule - * (e.g., A1 to B2) take the highest priority. These transfers are applied last, - * overwriting any transfers previously derived from parent stops. - *
  6. - *
+ *

+ * 1. Additional transfers: These transfers have the lowest priority and are processed first. 2. Parent-child + * derived transfers: If a transfer is defined between two parent stops (e.g., A to B), this method derives + * corresponding transfers for their child stops (e.g., A1, A2, ... to B1, B2, ...). 3. GTFS schedule-defined + * transfers: Transfers explicitly defined in the GTFS schedule (e.g., A1 to B2) take the highest priority and are + * applied last, thereby overwriting transfers previously derived from parent stops. *

* The method ensures that all transfers, whether additional, derived, or explicitly defined, are handled in the * correct priority order. @@ -251,4 +245,4 @@ private Collection expandTransfersFromStop(Stop stop return parentTransfers.values(); } -} +} \ No newline at end of file