1212import gnu .trove .map .hash .TIntIntHashMap ;
1313import gnu .trove .map .hash .TIntObjectHashMap ;
1414import gnu .trove .set .TIntSet ;
15+ import gnu .trove .set .hash .TIntHashSet ;
1516import org .slf4j .Logger ;
1617import 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