Skip to content

sebastianknopf/vdv736gtfsrt

Repository files navigation

VDV736GTFSRT

This package provides a VDV736 compatible GTFS-RT ServiceAlerts converter. It uses a publish/subscribe or request/response connection to a VDV736 compliant datahub and publishes GTFS-RT ServiceAlerts via a configurable GET endpoint or alternatively as differential GTFS-RT feed to a MQTT broker.

The project is successfully tested with Google Maps integration and running in production. See examples and more information in the showroom.

Basic Idea

Incident information or service alerts are part of realtime passenger information. However, in most OpenData sets, there're no GTFS-RT or even SIRI-SX alerts available. The purpose of this package is to provide a full VDV736 compliant converter to generate GTFS-RT service alerts.

Therefore, the application uses a pyvdv736 subscriber to connect to VDV736 compliant data hub. Both request patterns, publish/subscribe and request/response are supported. After receiving some PtSituationElements, they're converted to GTFS-RT service alerts using different adapters and exposed using a minimal uvicorn webserver or alternatively pushed to a MQTT broker as differential GTFS-RT feed.

The purpose of different adapters is to react to different implementations of the delivered VDV736 / SIRI-SX data. There's a VdvStandardAdaper strongly following the VDV736 sepcs, which used by default. You can use different adapters by configuration.

Installation

There're different options to use vdv736gtfsrt. You can use it by cloning this repository and install it into your virtual environment directly:

git clone https://github.com/sebastianknopf/vdv736gtfsrt.git
cd vdv736gtfsrt

pip install .

and run it by using

python -m vdv736gtfsrt server ./config/your-config.yaml -h 127.0.0.1 -p 8080

This is especially good for development.

If you simply want to run vdv736gtfsrt on your server (e.g. behind a reverse-proxy), you also can use docker:

docker run 
   --rm
   -v /host/etc/vdv736gtfsrt/config.yaml:/app/config/config.yaml
   -v /host/etc/vdv736gtfsrt/participants.yaml:/app/config/participants.yaml
   -v /host/var/log/vdv736gtfsrt/xml:/app/datalog
   -p 8080:8080
   -p 9091:9091
   sebastianknopf/vdv736gtfsrt:latest
   server -p 8080 -h 0.0.0.0

Note: In this example there're two ports configured: One port for the GTFS-RT server (8080) and one port for the VDV736 subscriber (9091). The latter port depends on the participant configuration in participants.yaml as well as the used pattern (publish/subscribe or request/response).

Configuration

The configuration YAML file enables you to customize the vdv736gtfsrt instance for your needs. See config/default.yaml for further assistance.

Participant Configuration

As a typical VDV realtime system, there're many different participants (sometimes also known as 'Leitstelle' with a 'Leitstellenkennung'). Additionally to the config file, a participants config file is required. By default, the file ./config/participants.yaml is used. If you want to specify another participants config file, set the key app.participants to the corresponding value.

The keys app.subscriber and app.publisher are used to set the participant IDs for the subscriber and the publisher which should be subscribed (or requested).

For more information about the participants configuration, see pyvdv736.

Running in Request/Reponse Pattern

By default, vdv736gtfsrt uses the more complexe publish/subscribe pattern to act as realtime capable system. However, the request/response pattern is much easier to setup. Simply set the key app.pattern to request/response to put vdv736gtfsrt into request/response mode.

Publishing differential GTFS-RT to MQTT Broker

Instead of running a GTFS-RT server, you can also run a MQTT publisher. This makes the system fully realtime capable. To run a MQTT publisher, use the command

python -m vdv736gtfsrt mqtt ./config/your-config.yaml -m mqtt://{username}:{password}@{domain}/here/is/your/topic/for/alert/[alertId] -c yourClientId

or alternatively docker

docker run 
   --rm
   -v /host/etc/vdv736gtfsrt/config.yaml:/app/config/config.yaml
   -v /host/etc/vdv736gtfsrt/participants.yaml:/app/config/participants.yaml
   -v /host/var/log/vdv736gtfsrt/xml:/app/datalog
   -p 9091:9091
   sebastianknopf/vdv736gtfsrt:latest
   mqtt -m mqtt://{username}:{password}@{domain}/here/is/your/topic/for/alert/[alertId] -c yourClientID

Replace {username}, {password}, {domain} by your values. The key [alertId] is replaced with the entity ID. The parameter -c / --client is optional to specify a certain client ID at the MQTT broker. Default is vdv736gtfsrt.

Using Data Logs

By setting the configuratiion key app.datalog_enabled all requests and responses are logged to the directory ./datalog as raw XML for debugging purposes. When running in Docker, you need to mount a directory on your host to /app/datalog to access the XML logs.

License

This project is licensed under the Apache License. See LICENSE.md for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors