Skip to content

Commit b3caf65

Browse files
committed
log stop-to-pattern pairs found by OSM but skipped
because the connection was already provided by gtfs transfers.txt
1 parent 18f1f14 commit b3caf65

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/com/conveyal/r5/transit/TransferFinder.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import gnu.trove.map.hash.TIntIntHashMap;
1313
import gnu.trove.map.hash.TIntObjectHashMap;
1414
import gnu.trove.set.TIntSet;
15+
import gnu.trove.set.hash.TIntHashSet;
1516
import org.slf4j.Logger;
1617
import org.slf4j.LoggerFactory;
1718

@@ -150,7 +151,15 @@ public void findTransfers () {
150151
// loop routes (see CTA Brown Line to Purple Line example in discussion on #763).
151152
distancesToReachedStops.remove(sourceStopIndex);
152153
TIntCollection ignorePatterns = gtfsTransferLoader.patternsToSkipForSourceStop(sourceStopIndex);
153-
retainClosestStopsOnPatterns(distancesToReachedStops, ignorePatterns);
154+
TIntSet gtfsProvidedStops = retainClosestStopsOnPatterns(distancesToReachedStops, ignorePatterns);
155+
{
156+
String fromStopName = transitLayer.stopNames.get(sourceStopIndex);
157+
gtfsProvidedStops.forEach(targetStopIndex -> {
158+
String toStopName = transitLayer.stopNames.get(targetStopIndex);
159+
LOG.info("Deferred to GTFS rather than OSM for transfer from {} to {}.", fromStopName, toStopName);
160+
return true;
161+
});
162+
}
154163
// At this point we have the distances to all stops that are the closest one on some pattern.
155164
// Make transfers to them, packed as pairs of (target stop index, distance).
156165
TIntList packedTransfers = new TIntArrayList();
@@ -234,8 +243,9 @@ public void findTransfers () {
234243
* @param ignorePatterns used to filter out stop-pattern pairs that already have a transfer from GTFS. May be null
235244
* or empty in other situations.
236245
*/
237-
private void retainClosestStopsOnPatterns(TIntIntMap timesToReachedStops, TIntCollection ignorePatterns) {
246+
private TIntSet retainClosestStopsOnPatterns(TIntIntMap timesToReachedStops, TIntCollection ignorePatterns) {
238247
TIntIntMap bestStopOnPattern = new TIntIntHashMap(50, 0.5f, -1, -1);
248+
TIntSet gtfsProvidedStops = new TIntHashSet();
239249
// For every reached stop,
240250
timesToReachedStops.forEachEntry((stopIndex, distanceToStop) -> {
241251
// For every pattern passing through the reached stop,
@@ -259,13 +269,15 @@ private void retainClosestStopsOnPatterns(TIntIntMap timesToReachedStops, TIntCo
259269
if (ignorePatterns != null) {
260270
ignorePatterns.forEach(patternIndex -> {
261271
if (bestStopOnPattern.containsKey(patternIndex)) {
262-
bestStopOnPattern.remove(patternIndex);
272+
int removedStop = bestStopOnPattern.remove(patternIndex);
273+
gtfsProvidedStops.add(removedStop);
263274
skippedPairCounter.increment();
264275
}
265276
return true;
266277
});
267278
}
268279
timesToReachedStops.retainEntries((stop, distance) -> bestStopOnPattern.containsValue(stop));
280+
return gtfsProvidedStops;
269281
}
270282

271283
}

0 commit comments

Comments
 (0)