Skip to content

Commit

Permalink
Merge pull request #13 from HSLdevcom/filter-other-types
Browse files Browse the repository at this point in the history
Check that the entity is a vehicle position entity
  • Loading branch information
optionsome authored Jan 9, 2020
2 parents 14c182e + cbbb5d6 commit f34de57
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gtfsrthttp2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def doGTFSRTPolling(self):
try:
feedmsg.ParseFromString(r.content)
for entity in feedmsg.entity:
if not entity.HasField('vehicle'):
continue
# Don't send message if route_id is missing from entity
# HasField() function does not work as expected, therefore we need check it like this
if "route_id" not in map(lambda x: x.name, entity.vehicle.trip.DESCRIPTOR.fields):
Expand Down

0 comments on commit f34de57

Please sign in to comment.