@@ -321,6 +321,7 @@ com.transitboard.hotel.prototype.showDestination = function (iteration) {
321
321
// set up the narrative
322
322
var time = 0 ;
323
323
var narr = '' ;
324
+ var isFirstTransitLeg = true ; // only the first transit leg should show real-time arrivals
324
325
$ . each ( dest . itinerary . legs , function ( ind , leg ) {
325
326
if ( leg . type == 'walk' ) {
326
327
// capitalize first
@@ -334,19 +335,26 @@ com.transitboard.hotel.prototype.showDestination = function (iteration) {
334
335
else if ( leg . type == 'transit' ) {
335
336
if ( ind == 0 ) var lett = 'B' ;
336
337
else var lett = 'b' ;
338
+
339
+ if ( isFirstTransitLeg ) {
340
+ var arrivals = ' <span class="rtarrivals">(next: ' +
341
+ // agency is hard-wired for now
342
+ instance . formatArrivals (
343
+ instance . getRealTimeArrivals (
344
+ 'TriMet:' + leg . startId ,
345
+ leg . routeId ,
346
+ leg . headsign
347
+ )
348
+ ) +
349
+ ')</span>,' ;
350
+ isFirstTransitLeg = false ;
351
+ }
352
+ // leave them out, just put a comma for grammatical correctness
353
+ else var arrivals = ',' ;
354
+
337
355
narr += '<span id="narrative-leg-' + ind +
338
356
'" class="narrative-leg">' +
339
- lett + 'oard ' + leg . headsign +
340
- ' <span class="rtarrivals">(next: ' +
341
- // agency is hard-wired for now
342
- instance . formatArrivals (
343
- instance . getRealTimeArrivals (
344
- 'TriMet:' + leg . startId ,
345
- leg . routeId ,
346
- leg . headsign
347
- )
348
- ) +
349
- ')</span>,' +
357
+ lett + 'oard ' + leg . headsign + arrivals +
350
358
' offboard at ' + leg . toPlace +
351
359
' (' + leg . noStops + ' stops)' +
352
360
'</span>, ' ;
@@ -786,20 +794,23 @@ com.transitboard.hotel.prototype.getTripPlanOnly = function (dest) {
786
794
// loop through the itineraries, find the lowest-cost one
787
795
data . find ( 'itinerary' ) . each ( function ( ind , itin ) {
788
796
itin = $ ( itin ) ;
789
- // make sure it fits hard requirements (0 transfers,
790
- // allowed stop), frequent service
791
- // TODO: allowed stop
797
+ // make sure it fits hard requirements: allowed stop, frequent service, &c.
798
+
799
+ /*
792
800
if (itin.find('numberOfTransfers').text() != '0') {
793
801
console.log('Trip has transfers!');
794
802
return true;
795
803
}
796
-
804
+ */
797
805
798
806
// We don't handle throughroutes yet (issue 43)
807
+ /*
799
808
if (Number(itin.find('numberOfTripLegs').text()) > 3) {
800
809
console.log('Too many trip legs, probably issue 43!');
801
810
return true;
802
811
}
812
+ */
813
+ // TODO: handle throughroutes when formulating narrative
803
814
804
815
// route 90 is an alternate number for MAX
805
816
// 90: MAX Red Line
@@ -811,15 +822,22 @@ com.transitboard.hotel.prototype.getTripPlanOnly = function (dest) {
811
822
'15' , '33' , '54' , '56' , '57' ,
812
823
'72' , '75' , '90' , '100' , '190' , '193' ,
813
824
'200' ] ;
814
- if ( $ . inArray ( itin . find ( 'leg route internalNumber' )
815
- . first ( ) . text ( ) ,
816
- freqService ) == - 1 ) {
817
- console . log ( 'route ' +
818
- itin . find ( 'leg route internalNumber' )
819
- . first ( ) . text ( ) +
820
- ' is not Frequent Service' ) ;
821
- return true ;
822
- }
825
+ var isFreqService = true ;
826
+ itin . find ( 'leg route internalNumber' ) . each ( function ( ) {
827
+ if ( $ . inArray ( $ ( this ) . text ( ) , freqService ) == - 1 ) {
828
+ console . log ( 'route ' +
829
+ itin . find ( 'leg route internalNumber' )
830
+ . first ( ) . text ( ) +
831
+ ' is not Frequent Service' ) ;
832
+ isFreqService = false ;
833
+
834
+ // no need to check any more
835
+ return false ;
836
+ }
837
+ } ) ;
838
+
839
+ // proceed to the next itinerary
840
+ if ( ! isFreqService ) return true ;
823
841
824
842
// these two tests are both transfer safe, b/c we only care about restrictions on the first legs
825
843
// stop id of this itin
@@ -831,8 +849,7 @@ com.transitboard.hotel.prototype.getTripPlanOnly = function (dest) {
831
849
}
832
850
833
851
// check for allowed route
834
- // it should either be explicitly stated or included with *. We assume that all routes
835
- // TP suggests are also in the real time feed.
852
+ // it should either be explicitly stated or included with * in the appliance def
836
853
var rid = itin . find ( 'leg route internalNumber' ) . first ( ) . text ( ) ;
837
854
if ( instance . realTimeArrivals . stopsConfig . TriMet [ sid ] [ rid ] == undefined &
838
855
instance . realTimeArrivals . stopsConfig . TriMet [ sid ] [ '*' ] == undefined ) {
@@ -1188,7 +1205,7 @@ com.transitboard.hotel.prototype.getRealTimeArrivals = function (stopId,
1188
1205
}
1189
1206
catch ( err ) {
1190
1207
// return an empty arrivalsQueue
1191
- console . log ( 'no arrivals found' ) ;
1208
+ console . log ( 'no arrivals found for stopId: ' + stopId + ', route ' + route + ', headsign ' + headsign ) ;
1192
1209
return new arrivalsQueue ( ) ;
1193
1210
}
1194
1211
// in case the headsign does not match
0 commit comments