fix: add workaround for duplicate vehicle IDs

This commit is contained in:
dancingCycle 2022-10-10 15:40:02 +02:00
parent ecf1c59e4c
commit 0fd0e1938c
2 changed files with 5 additions and 4 deletions

View File

@ -27,11 +27,11 @@ export default function Map({messages}) {
/>
{
messages.map(function(value,key) {
//console.log(`key: ${key}, value: ${value.vehicleId}`);
//console.log(`key: ${key}, value: ${JSON.stringify(value)}`);
if(hasGtfs){
return <MsgMarkerWithGtfs key={value.vehicleId} index={value.vehicleId} message={value}/>;
return <MsgMarkerWithGtfs key={value.tripId} index={value.vehicleId} message={value}/>;
}else{
return <MsgMarkerWithoutGtfs key={value.vehicleId} index={value.vehicleId} message={value}/>;
return <MsgMarkerWithoutGtfs key={value.tripId} index={value.vehicleId} message={value}/>;
}
})
}

View File

@ -52,7 +52,8 @@ export default function parseMessages(buffer){
/*Internal system identification of the vehicle.*/
vehicleId: vehicle.id === undefined ? '' : vehicle.id,
/*The trip_id from the GTFS feed that this selector refers to.*/
tripId: trip.trip_id === undefined ? -1 : parseInt(trip.trip_id,10) || -2,
//TODO How shall duplicate or unavailable trip id's be handles?
tripId: trip.trip_id === undefined ? ''+position.latitude+position.longiture : parseInt(trip.trip_id,10) || ''+position.latitude+position.longitude,
/*The route_id from the GTFS that this selector refers to.*/
routeId: trip.route_id === undefined ? -1 : parseInt(trip.route_id,10) || -2,
lat: position.latitude,