Git Product home page Git Product logo

db-ice-localizer-speedometer's Introduction

README

The Python script extract.py extracts the current GPS position and train speed (in km/h) from the map publicly accessible in Deutsche Bahn's ICE Portal, hence the name of the repository. It works when being connected to the train's WiFi but independent of your device's position sensor. The data is parsed periodically (every 10 seconds) and stored to a CSV file for further analysis.

ICE Portal Karte

⬇️

CSV snippet

To improve precision of GPS coordinates, zoom to the maximum zoom level by pressing the magnifying glass symbol.

Zoom level widget

You can also run the second Python script serve.py using Flask in addition. It will serve the extracted data on your own website from the latest logged CSV data. Please note that it must be started using flask --app serve run (python serve.py would immediately finish execution and return).

$ flask --app serve run
 * Serving Flask app 'serve'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
...

Use your favorite web browser and go to the URL listed in the console output: http://127.0.0.1:5000

Flask server

How does it work?

This script automatically opens the Firefox web browser at https://iceportal.de/Karte_neu and automatically scrapes the train's speed and GPS position. Deutsche Bahn uses OpenStreetMap in the background. The same URL slippy map tilenames format is used for the tile URLs:

Comparison of maps

The GPS coordinates as latitude and longitude in degrees are re-calculated from the dynamically loaded map tiles' URLs. There's no overhead in communication added by this script - so no additional queries, just using the available data from the browser.

The scraping is done using Selenium WebDriver for Firefox. The elements are specified using XPath syntax (and is subject to change as soon as Deutsche Bahn decides to change their content layout).

The script also stores some 3D transformation positions that could be used to add precision to the GPS coordinates by using the extracted values for correction.

Prerequisites

  • Working Python3 environment with the Selenium module installed.
  • Have Firefox web browser installed (script can likely be rewritten for other web browsers).
  • Be on a Deutsche Bahn ICE or Intercity (long-distance) train on your way across Germany.
  • Manually connect to WiFi with "WIFIonICE" and browse to "ICEportal.de" in your web browser.

Future ideas

You could also ...

  • extract and store internet connectivity status and forecast along your journey.
  • extract and store shown delays in scheduled arrival times along your journey.
  • add a quick check-in function for Träwelling.

db-ice-localizer-speedometer's People

Contributors

maehw avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.