PRO: MVG-API Stationdetails

This page shows deatails for a MVG-Station in munich and the next departing vehicles:

back to adress-search fc bayern
servingLines:
  • 16: TRAM to Effnerplatz via Lehel U
  • 19: TRAM to Berg am Laim Bf. S
  • 21: TRAM to St.-Veit-Straße
  • N17: TRAM to Effnerplatz
  • N19: TRAM to St.-Veit-Straße

current time: 11:40:31
departures:
3 Min 11:44 19 Pasing Bf. S
3 Min 11:44 16 Romanplatz
8 Min 11:49 21 Westfriedhof U
8 Min 11:49 19 Berg am Laim Bf. S
9 Min 11:50 16 Effnerplatz via Lehel U
12 Min 11:53 21 St.-Veit-Straße
13 Min 11:54 19 Pasing Bf. S
13 Min 11:54 16 Romanplatz
18 Min 11:59 21 Westfriedhof U
18 Min 11:59 19 Berg am Laim Bf. S
19 Min 12:00 16 Effnerplatz via Lehel U
22 Min 12:03 21 St.-Veit-Straße

Create a new JCI-template:

  • urlparam4twig: stationid#su
  • URL:
{% set su = "de:09162:180" %}
{% if urlparam.stationid %}{% set su = urlparam.stationid | trim | url_encode %}
{% endif %}
https://www.mvg.de/api/fahrinfo/departure/{{su}}?footway=4

twig-template:

<a href="/pro-mvg-api-munchner-verkehrsverbund-adresssuche/?su={{urlparam.su | url_encode}}">back to adress-search {{urlparam.su | e | stripslashes }}</a><hr>

servingLines:<br>
<ul>
{% for item in servingLines %}
<li>
    {{item.lineNumber}}: {{item.product}} to {{item.destination}}
    </li>
{% endfor %}
</ul>
<hr>
{% set hour = 3600 %}
{% set currenttimestamp = ("now"|date("U")) %}
current time: {{ (currenttimestamp+hour) |date("H:i:s") }}
<hr>
departures:<br>
<table border=1>
{% for i in departures | slice(0, 12) %}
       {% set deltasec = (i.departureTime/1000 - currenttimestamp) %}
    <tr><td>
        {% set mindist = (deltasec/60) |round(0, "floor") %}
        {% if mindist>60 %}
            {% set hrs = (deltasec/60/60) | round(0, "floor") %}
           {{hrs}} Hrs, {{mindist-60*hrs}} Min
        {% else %}
            {{mindist}} Min
        {% endif %}        
        
     </td><td>
       {{(i.departureTime/1000+hour) | date("H:i") }}
     </td><td>
       {{i.label}} 
    </td><td>
        {{i.destination}}
     </td><td>
        {{i.platform}}
   </td></tr>
{% endfor %}
</table>