Skip to content

Commit

Permalink
fix: add hbg specific vp message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hbruch committed Dec 12, 2024
1 parent c8b1cc1 commit 34b7478
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
35 changes: 33 additions & 2 deletions app/configurations/realtimeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,43 @@ export default {
active: true,
},
hbg: {
mqttTopicResolver: function mqttTopicResolver() {
return '/gtfsrt/vp/#';
mqttTopicResolver: function hbgTopicResolver(
route,
direction,
tripStartTime,
headsign,
feedId,
tripId,
geoHash,
) {
return (
'/gtfsrt/vp/' +
feedId +
'/+/+/+/' +
route +
'/' +
'+' + // direction is not available in VVS GTFS-RT-VP feed
'/' +
'+' + // headsign is not available in VVS GTFS-RT-VP feed
'/' +
tripId +
'/+/' +
'+' + // tripstartTime is not available in VVS GTFS-RT-VP feed
'/+/' +
geoHash[0] +
'/' +
geoHash[1] +
'/' +
geoHash[2] +
'/' +
geoHash[3] +
'/#'
);
},

// this value is overridden in config.herrenberg.js
mqtt: 'wss://vehiclepositions.stadtnavi.eu/mqtt/',
topicFeedId: 'hbg',

gtfsrt: true,

Expand Down
6 changes: 3 additions & 3 deletions app/util/gtfsRtParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const parseFeedMQTT = (feedParser, data, topic, agency) => {
,
,
,
,
feedId,
,
,
mode,
Expand All @@ -55,8 +55,8 @@ export const parseFeedMQTT = (feedParser, data, topic, agency) => {
const { trip, position, vehicle } = vehiclePos;
if (trip && position && vehicle) {
const message = {
id: `${agency}:${vehicleId}`,
route: `${agency}:${routeId}`,
id: `${feedId}:${vehicleId}`,
route: `${feedId}:${routeId}`,
direction:
directionId === '' ? undefined : parseInt(directionId, 10) || 0,
tripStartTime:
Expand Down

0 comments on commit 34b7478

Please sign in to comment.