Giter VIP home page Giter VIP logo

national-rail-datafeeds-ruby-examples's Introduction

National Rail datafeeds

You may have read one of the recent articles about how Network Rail is opening up a number of it's datafeeds for developers to use. This repo contains my initial experiment in processing the datafeed data.

There are two types of data produced, one on a pub/sub basis using the stomp protocol, the other downloading files from S3. This is about the former, using stomp.

You can download the developer pack, register and get started yourself. I'd use my ruby example though, changing the topic to which ever ones you have subscribed to.

Getting started

This is a ruby example so you need Ruby installed (I'm using 1.9.3 via RVM), rubygems installed and the stomp ruby gem installed gem install stomp

You will of course, also need to have signed up to the Network Rail datafeed programme and have your login credentials.

Receiving messages

Before running the code, ensure you have set the environment variables for your login credentials.

All being well, you should then slowly receive updates from the topic you have selected. The example below uses Train positioning data for the East Midlands (TD_MC_EM_SIG_AREA) and assumes that you have subscribed to that feed using the network rail control panel

The updates you receive from this program are not formatted at all, it's just sending the message straight to string. Of course, this is just helping you know you're set up correctly. So you would get something like:

<Stomp::Message headers={"message-id"=>"ID:blahblah", "destination"=>"/topic/TD_MC_EM_SIG_AREA", "timestamp"=>"1341436026840", "expires"=>"1341436326840", "persistent"=>"true", "priority"=>"4"} body='[{"CA_MSG":{"to":"1234","time":"1341435963000","area_id":"WH","msg_type":"CA","from":"5678","descr":"1Z99"}}]' command='MESSAGE' >

Ultimately of course, you'd process the JSON from the body.

national-rail-datafeeds-ruby-examples's People

Contributors

jamesjefferies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.