Giter VIP home page Giter VIP logo

ratp-gtfs-to-json's Introduction

ratp-gtfs-to-json

Create a JSON graph from RATP open data (http://data.ratp.fr/fr/les-donnees/fiche-de-jeu-de-donnees/dataset/offre-transport-de-la-ratp-format-gtfs.html)

This is part of fxos-metrobusparis

Data Overview

The goal of these scripts is to parse the GTFS files to create a Graph usable to find shortest paths

The GTFS structure is :

Line X directory

routes.txt trips.txt stop_times.txt stops.txt
route_id route_id stop_id stop_id
trip_id trip_id trip_id stop_name
type arrival_time
line (directory)

And the output is :

{
    <stop_id>: {
        name: <name>,
        loc: {
            lat: <latitude>,
            lon: <longitude>
        }
        zip: <zipcode>,
        edges: [
            {
                "dest": <dest_stop_id>,
                "dur": <edge_duration>,
                "type": <edge_type>,
                "open": <hour_of_opening>,
                "close": <hour_of_closing>,
                "line": <line_number>,
                "dir": <line_direction>,
                "freq": <average_frequency>
            }
        ]
    }
}

You can see the full RATP GTFS description in the PDF file in the page linked above (direct link: http://data.ratp.fr/?eID=ics_od_datastoredownload&file=88)

Scripts overview

create_raw_edges.c

Crunch all the stops informations from stop_times.txt (> 600MB, millions of lines) and output edges with average duration, frequency and open hours

create_graph.rb

Create graph nodes by browsing GTFS lines directories to get line informations (line name, directions...) and parse the output of create_raw_edges.c above to create final graph

The stops (stations) with identical names are merged to reduce graph size because in the original GTFS files there is one stop_id per line per direction.

See comments in the scripts for further explanations.

Usage

gcc create_raw_edges.c lib/r_hashtable.c lib/r_linkedlist.c -I lib/ -o create_raw_edges create_raw_edges <RATP_GTFS_FULL directory> > edges.txt create_graph.rb <RATP_GTFS_LINES directory> <RATP_GTFS_FULL directory> <edges.txt> <output.json>

Licence

(c) 2013 Romain BEAUDON This code may be freely distributed under the terms of the GPL3 Licence

ratp-gtfs-to-json's People

Contributors

rombdn avatar

Stargazers

eph avatar Lucas Declercq avatar Yujian Zhang avatar Signo avatar Tim Spann avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

poulpifr sebfab

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.