Skip to content

Commit

Permalink
Merge pull request #18 from Metalab/rewrite
Browse files Browse the repository at this point in the history
Rewrite
  • Loading branch information
Bernhard Hayden authored Feb 22, 2017
2 parents 8243715 + 87084e1 commit acb9e75
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 449 deletions.
57 changes: 51 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
# Öffimonitor

Display the Wiener Linien timetable for nearby bus/tram/subway lines on a
screen in the Metalab Hauptraum.
Displays an info screen with the next Wiener Linien public transport connections nearby. It was developed and is currently in use at [Metalab](https://metalab.at).

Written in Javascript for use on a Raspberry Pi in a CSS3 capable browser in Kiosk mode.
It includes a small server written in Node.js that pulls the needed data from the [Wiener Linien API](https://www.data.gv.at/katalog/dataset/add66f20-d033-4eee-b9a0-47019828e698), caches it and serves it together with an HTML5 frontend. At Metalab, [all of this runs](https://metalab.at/wiki/%C3%96ffimonitor) on a Raspberry Pi, which also displays the frontend on a spare monitor (check out ```util``` for reproduction).

## Usage

1. Move ```server/settings.example.js``` to ```server/settings.js``` and add your API key and change the listen port and other settings.
2. Change the walktimes in ```site/settings.js``` according to your needs (you can also choose to use a local JSON file as input here for client side testing)
3. Run ```node server/httpd.js```
1. Run ```npm install``` to fetch dependencies.
2. Move ```server/settings.example.js``` to ```server/settings.js``` and
1. Add your API key (mandatory, [get one here](http://www.wienerlinien.at/eportal3/ep/channelView.do?pageTypeId=66528&channelId=-48664)).
2. Most likely you will also want to change the ```api_ids``` to the RBL numbers that correspond to the stations you want to include ([find them here](https://till.mabe.at/rbl/)) and change the ```location_coordinate``` to the location of your Öffimonitor.
3. Change additional settings (optional).
3. Run ```npm start```
4. Open Öffimonitor in a browser of your choice.

## API

Besides the HTML frontend you can find a JSON API at ```/api```. It returns a status message, an array of departures and an array of warnings, which include all traffic infos of the type ```stoerungkurz``` from the Wiener Linien API.

### Example response

{
"status": "ok", // 'ok' or 'error'
"departures":[{
"stop": "Landesgerichtsstraße",
"coordinates": [16.3568570699034,48.2145510683941],
"line": "43",
"type": "ptTram",
"towards": "Neuwaldegg",
"barrierFree": true,
"time": "2017-02-14T18:54:14.000Z", // calculated most accurate departure time
"timePlanned": "2017-02-14T19:52:00.000+0100",
"timeReal": "2017-02-14T19:54:14.000+0100",
"countdown": 6,
"walkDuration": 197.9, // walking duration to stop in seconds
"walkStatus":"soon" // 'too late', 'hurry' or 'soon'
}],
"warnings": [{
"title": "43 : Fremder Verkehrsunfall",
"description": "Nach einer Fahrtbehinderung kommt es auf der Linie 43 zu unterschiedlichen Intervallen."
}]
}

All values without comments are directly taken from the Wiener Linien API. **Attention!** ```timeReal``` does not exist in case there is no real time information available and even ```timePlanned``` might be undefined if the departure time is written into the ```towards``` string (e.g. 'KARLSPLATZ NÄCHSTER ZUG 9 MIN'). In case you need a returned timestamp, rely on ```time```, which always contains the most accurate departure time available.

### Example error response

{
"status": "error",
"error": "API request failed"
}

## License

This project is licensed under [AGPL-3](COPYING). It includes several external assets in the folder ```site/assets```, which are licensed under [Creative Commons Namensnennung 3.0 Österreich](https://creativecommons.org/licenses/by/3.0/at/deed.de) by Stadt Wien – Wiener Linien (all SVG files) as well as the Roboto font by Google licensed under [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) (all TTF files).

For calculating the walking duration to the stop, Öffimonitor by default queries the [OSRM Demo Server](https://github.com/Project-OSRM/osrm-backend/wiki/Demo-server) and caches these results for the current runtime execution. By using the OSRM Demo Server you agree to this [API usage policy](https://github.com/Project-OSRM/osrm-backend/wiki/Api-usage-policy). The corresponding database is licensed under [ODbL](http://opendatacommons.org/licenses/odbl/) by [OSRM](http://project-osrm.org/). You can change the server address to any other OSRM instance in ```server/settings.js```.

Happy hacking!
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"name": "oeffimonitor",
"version": "0.0.1",
"description": "Oeffimonitor for the metalab.",
"main": "index.js",
"version": "0.1.0",
"description": "Displays an info screen with the next Wiener Linien public transport connections nearby.",
"main": "server/httpd.js",
"directories": {
"test": "test"
},
"scripts": {
"start": "npm run build && NODE_ENV='production' node server.js",
"build": "babel site/server/index.js -o ./server.js",
"dev": "babel-node site/server/index.js"
"start": "NODE_ENV='production' node server/httpd.js"
},
"repository": {
"type": "git",
Expand All @@ -22,6 +20,7 @@
},
"homepage": "https://github.com/metalab/oeffimonitor",
"dependencies": {
"babel": "^5.8.23"
"apicache": "^0.8.1",
"express": "^4.14.0"
}
}
Loading

0 comments on commit acb9e75

Please sign in to comment.