');
31 |
32 | $tr.append($('').html(index));
33 | $tr.append($(' ').html(formatHour(section.departure_date_time)));
34 | $tr.append($(' ').html(formatHour(section.arrival_date_time)));
35 | $tr.append($(' ').html(section.from && section.from.name));
36 | $tr.append($(' ').html(section.to && section.to.name));
37 | $tr.append($(' ').html(section.mode));
38 | $tr.append($(' ').html(section.type));
39 | $tr.append($(' ').html(section.display_informations && section.display_informations.physical_mode));
40 | $tr.append($(' ').html(section.display_informations && section.display_informations.code));
41 |
42 | $tbody.append($tr);
43 | });
44 | }
45 |
46 | function formatHour(navitiaDate) {
47 | return navitiaDate.substr(9).match(/.{2}/g).join(':');
48 | }
49 |
50 | if (!pretty)
51 | var pretty = {};
52 |
53 | pretty.json = {
54 | replacer: function(match, pIndent, pKey, pVal, pEnd) {
55 | var key = '';
56 | var val = '';
57 | var str = '';
58 | var r = pIndent || '';
59 | if (pKey)
60 | r = r + key + pKey.replace(/[": ]/g, '') + ' : ';
61 | if (pVal)
62 | r = r + (pVal[0] == '"' ? str : val) + pVal + ' ';
63 | return r + (pEnd || '');
64 | },
65 | prettyPrint: function(obj) {
66 | var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg;
67 | return JSON.stringify(obj, null, 3)
68 | .replace(/&/g, '&').replace(/\\"/g, '"')
69 | .replace(//g, '>')
70 | .replace(jsonLine, pretty.json.replacer);
71 | }
72 | };
73 |
--------------------------------------------------------------------------------
/source/_static/raptor/jquery.raptorize.1.0.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Raptorize Plugin 1.0
3 | * www.ZURB.com/playground
4 | * Copyright 2010, ZURB
5 | * Free to use under the MIT license.
6 | * http://www.opensource.org/licenses/mit-license.php
7 | */
8 |
9 |
10 | (function($) {
11 |
12 | $.fn.raptorize = function(options) {
13 |
14 | //Yo' defaults
15 | var defaults = {
16 | enterOn: 'click', //timer, konami-code, click
17 | delayTime: 5000 //time before raptor attacks on timer mode
18 | };
19 |
20 | //Extend those options
21 | var options = $.extend(defaults, options);
22 |
23 | return this.each(function() {
24 |
25 | var _this = $(this);
26 | var audioSupported = false;
27 | //Stupid Browser Checking which should be in jQuery Support
28 | if ($.browser.mozilla && $.browser.version.substr(0, 5) >= "1.9.2" || $.browser.webkit) {
29 | audioSupported = true;
30 | }
31 |
32 | //Raptor Vars
33 | var raptorImageMarkup = ' '
34 | var raptorAudioMarkup = ' ';
35 | var locked = false;
36 |
37 | //Append Raptor and Style
38 | $('body').append(raptorImageMarkup);
39 | if(audioSupported) { $('body').append(raptorAudioMarkup); }
40 | var raptor = $('#elRaptor').css({
41 | "position":"fixed",
42 | "bottom": "-700px",
43 | "right" : "0",
44 | "display" : "block"
45 | })
46 |
47 | // Animating Code
48 | function init() {
49 | locked = true;
50 |
51 | //Sound Hilarity
52 | if(audioSupported) {
53 | function playSound() {
54 | document.getElementById('elRaptorShriek').play();
55 | }
56 | playSound();
57 | }
58 |
59 | // Movement Hilarity
60 | raptor.animate({
61 | "bottom" : "0"
62 | }, function() {
63 | $(this).animate({
64 | "bottom" : "-130px"
65 | }, 100, function() {
66 | var offset = (($(this).position().left)+400);
67 | $(this).delay(300).animate({
68 | "right" : offset
69 | }, 2200, function() {
70 | raptor = $('#elRaptor').css({
71 | "bottom": "-700px",
72 | "right" : "0"
73 | })
74 | locked = false;
75 | })
76 | });
77 | });
78 | }
79 |
80 |
81 | //Determine Entrance
82 | if(options.enterOn == 'timer') {
83 | setTimeout(init, options.delayTime);
84 | } else if(options.enterOn == 'click') {
85 | _this.bind('click', function(e) {
86 | e.preventDefault();
87 | if(!locked) {
88 | init();
89 | }
90 | })
91 | } else if(options.enterOn == 'konami-code'){
92 | var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
93 | $(window).bind("keydown.raptorz", function(e){
94 | kkeys.push( e.keyCode );
95 | if ( kkeys.toString().indexOf( konami ) >= 0 ) {
96 | init();
97 | $(window).unbind('keydown.raptorz');
98 | }
99 | }, true);
100 |
101 | }
102 |
103 | });//each call
104 | }//orbit plugin call
105 | })(jQuery);
106 |
107 |
--------------------------------------------------------------------------------
/source/integration.rst:
--------------------------------------------------------------------------------
1 | SNCF API documentation
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 |
4 | .. contents:: Index
5 |
6 | OVERVIEW
7 | ========
8 |
9 | This documentation describes how to use the SNCF API based on Navitia software. Navitia is an Open Source software developed by `Kisio Digital `_. To see the last update, please go to navitia.io documentation (`http://doc.navitia.io/ `_).
10 |
11 | The SNCF API contains **theoretical train data** for the following commercial modes: TGV, TER, Transilien, Intercités. The SNCF API also contains **realtime train data** for the following commercial modes: TGV, TER, Intercités.
12 |
13 | The SNCF API handles:
14 | * Journeys computation
15 | * Line schedules
16 | * Next departures
17 | * Exploration of public transport data / search places
18 | * Autocomplete
19 | * Isochrones
20 |
21 | Read the **Open Transport vocabulary** (`https://github.com/OpenTransport/vocabulary/blob/master/vocabulary.md `_).
22 |
23 | .. _authentification:
24 |
25 | AUTHENTICATION
26 | ==============
27 | You must authenticate to use SNCF API. When you register we give you an authentication key to the API. You must use the Basic HTTP authentication, where the username is the key, and without password.
28 | * Username: copy / paste your key
29 | * Password: leave the field blank
30 |
31 | .. _easy_examples:
32 |
33 | EASY EXAMPLES
34 | =============
35 | Easy **executable examples** are available on JSFiddle
36 |
37 | * `Try JOURNEYS feature on JSFiddle `_
38 |
39 | * `Try ISOCHRONES feature on JSFiddle `_
40 |
41 | * `Try LINES feature on JSFiddle `_
42 |
43 | .. _more_detail_and_examples:
44 |
45 | MORE DETAILS AND EXAMPLES
46 | =========================
47 | If you need more information describing how to use SNCF API, please refer to the Navitia API documentation (`http://doc.navitia.io/ `_). It contains many example, libraries and tools that will help you build your project using the API.
48 |
49 | `VIEW THE FULL NAVITIA DOCUMENTATION `_
50 |
51 | **Important note**
52 | The Navitia documentation describes the Navitia API. All the examples that it contains refer to this API. Since it is based on the same technology, do not forget to change the first part of the URL in order to call the right API.
53 |
54 | Here is an example :
55 |
56 | ============================================================================= ======================================================================================
57 | If the documentation shows this request try this one !
58 | ============================================================================= ======================================================================================
59 | `https://api.navitia.io/v1/coverage `_ `https://api.sncf.com/v1/coverage `_
60 | ============================================================================= ======================================================================================
61 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | PAPER =
8 | BUILDDIR = build
9 |
10 | # Internal variables.
11 | PAPEROPT_a4 = -D latex_paper_size=a4
12 | PAPEROPT_letter = -D latex_paper_size=letter
13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
14 |
15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
16 |
17 | help:
18 | @echo "Please use \`make ' where is one of"
19 | @echo " html to make standalone HTML files"
20 | @echo " dirhtml to make HTML files named index.html in directories"
21 | @echo " singlehtml to make a single large HTML file"
22 | @echo " pickle to make pickle files"
23 | @echo " json to make JSON files"
24 | @echo " htmlhelp to make HTML files and a HTML help project"
25 | @echo " qthelp to make HTML files and a qthelp project"
26 | @echo " devhelp to make HTML files and a Devhelp project"
27 | @echo " epub to make an epub"
28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
29 | @echo " latexpdf to make LaTeX files and run them through pdflatex"
30 | @echo " text to make text files"
31 | @echo " man to make manual pages"
32 | @echo " changes to make an overview of all changed/added/deprecated items"
33 | @echo " linkcheck to check all external links for integrity"
34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)"
35 |
36 | clean:
37 | -rm -rf $(BUILDDIR)/*
38 |
39 | html:
40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
41 | @echo
42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
43 |
44 | dirhtml:
45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
46 | @echo
47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
48 |
49 | singlehtml:
50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
51 | @echo
52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
53 |
54 | pickle:
55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
56 | @echo
57 | @echo "Build finished; now you can process the pickle files."
58 |
59 | json:
60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
61 | @echo
62 | @echo "Build finished; now you can process the JSON files."
63 |
64 | htmlhelp:
65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
66 | @echo
67 | @echo "Build finished; now you can run HTML Help Workshop with the" \
68 | ".hhp project file in $(BUILDDIR)/htmlhelp."
69 |
70 | qthelp:
71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
72 | @echo
73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \
74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/NAViTiA2.qhcp"
76 | @echo "To view the help file:"
77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/NAViTiA2.qhc"
78 |
79 | devhelp:
80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
81 | @echo
82 | @echo "Build finished."
83 | @echo "To view the help file:"
84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/NAViTiA2"
85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/NAViTiA2"
86 | @echo "# devhelp"
87 |
88 | epub:
89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
90 | @echo
91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
92 |
93 | latex:
94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
95 | @echo
96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \
98 | "(use \`make latexpdf' here to do that automatically)."
99 |
100 | latexpdf:
101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
102 | @echo "Running LaTeX files through pdflatex..."
103 | make -C $(BUILDDIR)/latex all-pdf
104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
105 |
106 | text:
107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
108 | @echo
109 | @echo "Build finished. The text files are in $(BUILDDIR)/text."
110 |
111 | man:
112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
113 | @echo
114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
115 |
116 | changes:
117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
118 | @echo
119 | @echo "The overview file is in $(BUILDDIR)/changes."
120 |
121 | linkcheck:
122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
123 | @echo
124 | @echo "Link check complete; look for any errors in the above output " \
125 | "or in $(BUILDDIR)/linkcheck/output.txt."
126 |
127 | doctest:
128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
129 | @echo "Testing of doctests in the sources finished, look at the " \
130 | "results in $(BUILDDIR)/doctest/output.txt."
131 |
--------------------------------------------------------------------------------
/source/examples/jsFiddle/isochron/demo.js:
--------------------------------------------------------------------------------
1 | var sandboxToken = '49545ca6-b27c-4a29-a179-6f2fb5d33819';
2 |
3 | // Isochron starting point
4 | var from = 'stop_area:SNF:SA:MANS';
5 |
6 | // Limit isochron duration (required, or may trigger timeout when there is more data)
7 | var maxDuration = 3600 * 6;
8 |
9 | // Query for this isochron
10 | var isochronUrl = 'http://navitia2sim-ws.mutu.production.canaltp.fr/v1/coverage/sandbox/journeys?from='+from+'&max_duration='+maxDuration;
11 |
12 | // Call SNCF api
13 | $.ajax({
14 | type: 'GET',
15 | url: isochronUrl,
16 | dataType: 'json',
17 | headers: {
18 | Authorization: 'Basic ' + btoa(sandboxToken)
19 | },
20 | success: drawIsochron,
21 | error: function(xhr, textStatus, errorThrown) {
22 | alert('Error when trying to process isochron: "'+textStatus+'", "'+errorThrown+'"');
23 | }
24 | });
25 |
26 | /*
27 | * Drawing isochron result on a map.
28 | *
29 | * Isochron result contains many points with their duration from starting point.
30 | * So here using Leaflet, each point will be represented with a color
31 | * showing its duration from starting point.
32 | */
33 |
34 | var tiles = {
35 | url: 'http://www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png',
36 | attrib: 'Isochron example with SNCF open data © OpenStreetMap contributors'
37 | };
38 |
39 | // Create a drawable map using Leaflet
40 | var map = L.map('map')
41 | .setView([48.007778, 0.199533], 7)
42 | .addLayer(new L.TileLayer(tiles.url, {minZoom: 0, maxZoom: 16, attribution: tiles.attrib}))
43 | ;
44 |
45 | // Add marker to show isochron starting point
46 | L.marker([48.007778, 0.199533]).addTo(map);
47 |
48 | var geojsonLayer = null;
49 |
50 | /**
51 | * Display points returned by navitia isochron, and colored red/green depending on journey duration.
52 | *
53 | * @param {Object} result
54 | */
55 | function drawIsochron(result) {
56 | var isochron = [];
57 |
58 | $.each(result.journeys, function (i, journey) {
59 | isochron.push({
60 | to: [
61 | parseFloat(journey.to.stop_point.coord.lat),
62 | parseFloat(journey.to.stop_point.coord.lon)
63 | ],
64 | duration: journey.duration,
65 | data: journey
66 | });
67 | });
68 |
69 | var geojson = createGeoJsonFromIsochron(isochron);
70 |
71 | drawGeoJson(map, geojson);
72 | }
73 |
74 | /**
75 | * Create a geoJson object contening all points and their colors.
76 | *
77 | * @param {Array} isochron
78 | *
79 | * @returns {Object} GeoJson object
80 | */
81 | function createGeoJsonFromIsochron(isochron) {
82 | var geojson = {
83 | name: 'Points',
84 | type: 'FeatureCollection',
85 | features: []
86 | };
87 |
88 | $.each(isochron, function (i, point) {
89 | geojson.features.push({
90 | type: 'Feature',
91 | geometry: {
92 | type: 'Point',
93 | coordinates: point.to.reverse()
94 | },
95 | properties: {
96 | color: colorFromDuration(point.duration),
97 | journey: point.data
98 | }
99 | });
100 | });
101 |
102 | return geojson;
103 | }
104 |
105 | /**
106 | * Create a Leaflet GeoJson layer and append it to the map.
107 | * (Remove the last layer if there is any.)
108 | *
109 | * @param {L.Map} map
110 | * @param {Object} geojson
111 | */
112 | function drawGeoJson(map, geojson) {
113 | if (null !== geojsonLayer) {
114 | map.removeLayer(geojsonLayer);
115 | }
116 |
117 | geojsonLayer = L.geoJson(geojson, {
118 | style: function(feature) {
119 | return {
120 | color: feature.properties.color
121 | };
122 | },
123 | pointToLayer: function(feature, latlng) {
124 | var raduis = 4;
125 |
126 | return new L.CircleMarker(latlng, {radius: raduis, fillOpacity: 0.6});
127 | },
128 | onEachFeature: function (feature, layer) {
129 | var journey = feature.properties.journey;
130 | var hours = Math.floor(journey.duration / 3600);
131 | var min = Math.round((journey.duration - hours * 3600) / 60);
132 | var duration = hours+'h'+min+'min';
133 | var journeyLink = journey.links[0].href.replace('://', '://'+sandboxToken+'@');
134 |
135 | layer.bindPopup([
136 | ''+journey.to.name+' ',
137 | duration,
138 | 'Journeys to this point '
139 | ].join(' '));
140 | }
141 | });
142 |
143 | map.addLayer(geojsonLayer);
144 | }
145 |
146 | /**
147 | * Calculate a color from a duration, from green to red when duration is small/long.
148 | *
149 | * @param {Integer} duration
150 | *
151 | * @returns {String}
152 | */
153 | function colorFromDuration(duration) {
154 | var color1 = '822566';
155 | var color2 = '1C9DD5';
156 | var ratio = duration / maxDuration;
157 | ratio *= ratio; // Apply ratio^2 to have more green.
158 | var hex = function(x) {
159 | x = x.toString(16);
160 | return (x.length === 1) ? '0' + x : x;
161 | };
162 |
163 | var r = Math.ceil(parseInt(color1.substring(0,2), 16) * ratio + parseInt(color2.substring(0,2), 16) * (1-ratio));
164 | var g = Math.ceil(parseInt(color1.substring(2,4), 16) * ratio + parseInt(color2.substring(2,4), 16) * (1-ratio));
165 | var b = Math.ceil(parseInt(color1.substring(4,6), 16) * ratio + parseInt(color2.substring(4,6), 16) * (1-ratio));
166 |
167 | var middle = hex(r) + hex(g) + hex(b);
168 |
169 | return '#' + middle;
170 | }
171 |
--------------------------------------------------------------------------------
/source/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # NAViTiA2 documentation build configuration file, created by
4 | # sphinx-quickstart on Fri Mar 30 16:58:49 2012.
5 | #
6 | # This file is execfile()d with the current directory set to its containing dir.
7 | #
8 | # Note that not all possible configuration values are present in this
9 | # autogenerated file.
10 | #
11 | # All configuration values have a default; values that are commented out
12 | # serve to show the default.
13 |
14 | import sys, os
15 | import sphinx_bootstrap_theme
16 | # If extensions (or modules to document with autodoc) are in another directory,
17 | # add these directories to sys.path here. If the directory is relative to the
18 | # documentation root, use os.path.abspath to make it absolute, like shown here.
19 | #sys.path.insert(0, os.path.abspath('.'))
20 | # -- General configuration -----------------------------------------------------
21 |
22 | # If your documentation needs a minimal Sphinx version, state it here.
23 | #needs_sphinx = '1.0'
24 |
25 | # Add any Sphinx extension module names here, as strings. They can be extensions
26 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
27 | extensions = ['sphinx.ext.todo', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinxcontrib.aafig', 'sphinxcontrib.mscgen']
28 |
29 | # Add any paths that contain templates here, relative to this directory.
30 | templates_path = ['_templates']
31 | import sphinx_bootstrap_theme
32 | # The suffix of source filenames.
33 | source_suffix = '.rst'
34 |
35 | # The encoding of source files.
36 | #source_encoding = 'utf-8-sig'
37 |
38 | # The master toctree document.
39 | master_doc = 'index'
40 |
41 | # General information about the project.
42 | project = u'navitia.io'
43 | copyright = u'2013, Canal TP'
44 |
45 | # The version info for the project you're documenting, acts as replacement for
46 | # |version| and |release|, also used in various other places throughout the
47 | # built documents.
48 | #
49 | # The short X.Y version.
50 | #version = '0.56'
51 | # The full version, including alpha/beta/rc tags.
52 | #release = 'v0'
53 |
54 | # The language for content autogenerated by Sphinx. Refer to documentation
55 | # for a list of supported languages.
56 | language = 'fr'
57 |
58 | # There are two options for replacing |today|: either, you set today to some
59 | # non-false value, then it is used:
60 | #today = ''
61 | # Else, today_fmt is used as the format for a strftime call.
62 | #today_fmt = '%B %d, %Y'
63 |
64 | # List of patterns, relative to source directory, that match files and
65 | # directories to ignore when looking for source files.
66 | exclude_patterns = []
67 |
68 | # The reST default role (used for this markup: `text`) to use for all documents.
69 | #default_role = None
70 |
71 | # If true, '()' will be appended to :func: etc. cross-reference text.
72 | #add_function_parentheses = True
73 |
74 | # If true, the current module name will be prepended to all description
75 | # unit titles (such as .. function::).
76 | #add_module_names = True
77 |
78 | # If true, sectionauthor and moduleauthor directives will be shown in the
79 | # output. They are ignored by default.
80 | #show_authors = False
81 |
82 | # The name of the Pygments (syntax highlighting) style to use.
83 | pygments_style = 'sphinx'
84 | highlight_language = 'c++'
85 |
86 | # A list of ignored prefixes for module index sorting.
87 | #modindex_common_prefix = []
88 |
89 |
90 | # -- Options for HTML output ---------------------------------------------------
91 |
92 | # The theme to use for HTML and HTML Help pages. See the documentation for
93 | # a list of builtin themes.
94 | html_theme = 'bootstrap'
95 | html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
96 |
97 | # Theme options are theme-specific and customize the look and feel of a theme
98 | # further. For a list of options available for each theme, see the
99 | # documentation.
100 | html_theme_options = {
101 | 'bootswatch_theme': "united",
102 | # 'sidebarbgcolor' : '#ff6600',
103 | # 'sidebartextcolor' : '#ffffff',
104 | # 'relbarbgcolor' : '#ff6600',
105 | # 'sidebarlinkcolor' : '#FFBB99',
106 | # 'headtextcolor': '#ff6600'
107 |
108 | # Si la charte Canal TP reste orange, on peut mettre ça:
109 | # 'sidebarbgcolor' : '#ffEEDD',
110 | # 'sidebartextcolor' : '#BB4400',
111 | # 'sidebarlinkcolor' : '#DD5500',
112 | # 'relbarbgcolor' : '#ff6600',
113 | # 'headbgcolor': '#ffEEDD',
114 | # 'headtextcolor' : '#994400',
115 | # 'linkcolor' : '#994400',
116 | # 'visitedlinkcolor' : '#994400'
117 | }
118 |
119 | # Add any paths that contain custom themes here, relative to this directory.
120 | #html_theme_path = []
121 |
122 | # The name for this set of Sphinx documents. If None, it defaults to
123 | # " v documentation".
124 | #html_title = None
125 |
126 | # A shorter title for the navigation bar. Default is the same as html_title.
127 | #html_short_title = None
128 |
129 | # The name of an image file (relative to this directory) to place at the top
130 | # of the sidebar.
131 | #html_logo = None
132 | #html_logo = '_static/logo_ro.png'
133 |
134 | # The name of an image file (within the static path) to use as favicon of the
135 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
136 | # pixels large.
137 | #html_favicon = None
138 |
139 | # Add any paths that contain custom static files (such as style sheets) here,
140 | # relative to this directory. They are copied after the builtin static files,
141 | # so a file named "default.css" will overwrite the builtin "default.css".
142 | html_static_path = ['_static']
143 |
144 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
145 | # using the given strftime format.
146 | #html_last_updated_fmt = '%b %d, %Y'
147 |
148 | # If true, SmartyPants will be used to convert quotes and dashes to
149 | # typographically correct entities.
150 | html_use_smartypants = True
151 |
152 | # Custom sidebar templates, maps document names to template names.
153 | #html_sidebars = {}
154 |
155 | # Additional templates that should be rendered to pages, maps page names to
156 | # template names.
157 | #html_additional_pages = {}
158 |
159 | # If false, no module index is generated.
160 | #html_domain_indices = True
161 |
162 | # If false, no index is generated.
163 | #html_use_index = True
164 |
165 | # If true, the index is split into individual pages for each letter.
166 | #html_split_index = False
167 |
168 | # If true, links to the reST sources are added to the pages.
169 | #html_show_sourcelink = True
170 |
171 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
172 | #html_show_sphinx = True
173 |
174 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
175 | #html_show_copyright = True
176 |
177 | # If true, an OpenSearch description file will be output, and all pages will
178 | # contain a tag referring to it. The value of this option must be the
179 | # base URL from which the finished HTML is served.
180 | #html_use_opensearch = ''
181 |
182 | # This is the file name suffix for HTML files (e.g. ".xhtml").
183 | #html_file_suffix = None
184 |
185 | # Output file base name for HTML help builder.
186 | htmlhelp_basename = 'NAViTiA2doc'
187 |
188 |
189 | # -- Options for LaTeX output --------------------------------------------------
190 |
191 | latex_elements = {
192 | # The paper size ('letterpaper' or 'a4paper').
193 | #'papersize': 'letterpaper',
194 |
195 | # The font size ('10pt', '11pt' or '12pt').
196 | #'pointsize': '10pt',
197 |
198 | # Additional stuff for the LaTeX preamble.
199 | #'preamble': '',
200 | }
201 |
202 | # Grouping the document tree into LaTeX files. List of tuples
203 | # (source start file, target name, title, author, documentclass [howto/manual]).
204 | latex_documents = [
205 | ('index', 'NAViTiA2.tex', u'NAViTiA2 Documentation',
206 | u'Canal TP', 'manual'),
207 | ]
208 |
209 | # The name of an image file (relative to this directory) to place at the top of
210 | # the title page.
211 | #latex_logo = None
212 |
213 | # For "manual" documents, if this is true, then toplevel headings are parts,
214 | # not chapters.
215 | #latex_use_parts = False
216 |
217 | # If true, show page references after internal links.
218 | #latex_show_pagerefs = False
219 |
220 | # If true, show URL addresses after external links.
221 | #latex_show_urls = False
222 |
223 | # Additional stuff for the LaTeX preamble.
224 | #latex_preamble = ''
225 |
226 | # Documents to append as an appendix to all manuals.
227 | #latex_appendices = []
228 |
229 | # If false, no module index is generated.
230 | #latex_domain_indices = True
231 |
232 |
233 | # -- Options for manual page output --------------------------------------------
234 |
235 | # One entry per manual page. List of tuples
236 | # (source start file, name, description, authors, manual section).
237 | man_pages = [
238 | ('index', 'navitia2', u'NAViTiA2 Documentation',
239 | [u'Canal TP'], 1)
240 | ]
241 |
--------------------------------------------------------------------------------
/source/index.rst:
--------------------------------------------------------------------------------
1 | .. NAViTiA2 documentation master file, created by
2 | sphinx-quickstart on Fri Mar 30 16:58:49 2012.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to navitia.io
7 | =====================
8 |
9 | An API to build cool stuff with public transport
10 | -------------------------------------------------
11 |
12 | We provide:
13 |
14 | * journeys computation
15 | * line schedules
16 | * next departures
17 | * exploration of public transport data
18 | * sexy things such as isochrones
19 |
20 | .. note::
21 |
22 | We are gradually supporting more and more cities. If your city has open public transport data and is missing, drop us a note.
23 | We will add it to navitia.io
24 |
25 |
26 | Getting started
27 | ---------------
28 |
29 | The easiest is probably to jump to `Examples`_ below.
30 |
31 | At some point you will want to read:
32 |
33 | .. toctree::
34 | :maxdepth: 1
35 |
36 | public_transport
37 | integration
38 |
39 | There are no restrictions in using our API. However, please don't make more than one request per second.
40 |
41 | Let us know if you build something with our API, we will be happy to highlight it on this page. The more feedback we get, the more cities you will get
42 | and the more effort we will put to make the API durable.
43 |
44 | Overview
45 | ********
46 |
47 | *navitia* is a RESTful API that returns `JSON `_ formated results.
48 |
49 | Our APIs are available at the following url: http://api.navitia.io/v1 (the latest API version is ``v1``).
50 |
51 | The API has been built on the `HATEOAS model `_ so the API should be quite self explanatory since the interactions are defined in hypermedia.
52 |
53 | The different possible actions on a given API level are given in the ``links`` section of the response.
54 |
55 | To provide additional arguments to the API, add them at the end of the query with the following syntax: ``?arg1=val1&arg2=val2``.
56 |
57 | Have a look at the examples below to learn what API we provide and how to use them.
58 |
59 | .. note::
60 | The results are paginated to avoid crashing your parser. The parameters to get the next or previous page are within the ``links`` section of the result.
61 |
62 |
63 | Examples
64 | --------
65 |
66 | This chapter shows some usages with the minimal required arguments. However, this is not a reference and not all APIs nor arguments are shown.
67 |
68 | A simple route computation
69 | **************************
70 |
71 | Let's find out how to get from the view point of the Golden Gate bridge to the Transamerica Pyramid in San Francisco the 18th of January at 08:00 AM.
72 | We need to use the ``journeys`` API.
73 |
74 |
75 | The coordinates of the view point are ``longitude = -122.4752``, ``latitude = 37.80826`` and the coordinates of the Transamercia Pyramid are ``longitude = -122.402770``, ``latitude = 37.794682``.
76 | The coordinates are always in decimal degrees as WGS84 (also known as GPS coordinates). The coordinates are given to the API with the following format: ``longitute;latitude``.
77 |
78 | The dates are given in the basic form of the ISO 8601 datetime format: ``YYYYMMDDTHHMM``.
79 |
80 | The arguments are the following:
81 |
82 |
83 | * ``from=-122.4752;37.80826``
84 | * ``to=-122.402770;37.794682``
85 | * ``datetime=20140118T0800``
86 |
87 | Hence, the complete URL: http://api.navitia.io/v1/journeys?from=-122.4752;37.80826&to=-122.402770;37.794682&datetime=20140618T0800.
88 |
89 |
90 | A ``journeys`` request might return multiple journeys. Those journeys are said to be *equivalent*. For instance
91 | a journey can be faster than an other but requires more changes or more walking.
92 |
93 | This API has more options explained in the reference as:
94 |
95 | * Forbid certain lines, routes or modes
96 | For example you can forbid the line 1030 and the cable car mode with the url:
97 | http://api.navitia.io/v1/journeys?from=-122.4752;37.80826&to=-122.402770;37.794682&datetime=20140618T0800&forbidden_uris[]=line:OSF:1030&forbidden_uris[]=commercial_mode:cablecar
98 |
99 | * Latest departure
100 | To get the latest departure, you can query for some journeys arriving before the end of the service
101 | http://api.navitia.io/v1/journeys?from=-122.47787733594924;37.71696489300146&to=-122.41539259473815;37.78564348914185&datetime=20140613T0300&datetime_represents=arrival
102 |
103 | * You can also limit the maximum duration to reach the public transport system (to limit the walking/biking/driving parts):
104 | https://api.navitia.io/v1/coverage/iledefrance/journeys?from=2.3865494;48.8499182&to=2.3643739;48.854&datetime=201406121000&max_duration_to_pt=1800
105 |
106 | * Enable biking, driving or use of bike sharing system
107 | For example you can allow bss (and walking since it's implicitly allowed with bss) at the departure:
108 | https://api.navitia.io/v1/coverage/iledefrance/journeys?from=2.3865494;48.8499182&to=2.3643739;48.854&datetime=201406121000&max_duration_to_pt=1800&first_section_mode[]=bss
109 |
110 | you can also allow walking and bike with:
111 | https://api.navitia.io/v1/coverage/iledefrance/journeys?from=2.3865494;48.8499182&to=2.3643739;48.854&datetime=201406121000&max_duration_to_pt=1800&first_section_mode[]=bike&first_section_mode[]=walking
112 |
113 | to allow a different fallback mode at the arrival mode, use ``last_section_mode[]``
114 |
115 |
116 | A quick journey in the API
117 | **************************
118 |
119 | *navitia* allows to dive into the public transport data.
120 |
121 | To better understand how the API works let's ask the API the different main possibilities by simply querying the API endpoint: http://api.navitia.io/v1/
122 |
123 | The ``links`` section of the answer contains the different possible interactions with the API.
124 |
125 | As you can see there are several possibilities like for example ``coverage`` to navigate through the covered regions data or ``journeys`` to compute a journey.
126 |
127 |
128 | Now let's see what interactions are possible with ``coverage``: http://api.navitia.io/v1/coverage
129 |
130 | This request will give you:
131 |
132 | * in the ``regions`` section the list of covered regions
133 | * in the ``links`` section the list of possible interactions with them
134 |
135 |
136 | In the ``links`` section there is for example this link: ``"href": "http://api.navitia.io/v1/coverage/{regions.id}/lines"``
137 |
138 |
139 | This link is about lines (according to its ``rel`` attribute) and is templated which means that it needs additional parameters. The parameters are identified with the ``{`` ``}`` syntax.
140 | In this case it needs a region id. This id can the found in the ``regions`` section. For example let's consider this region: ::
141 |
142 | "start_production_date": "20140105",
143 | "status": "running",
144 | "shape": "POLYGON((-74.500997 40.344999,-74.500997 41.096999,-73.226 41.096999,-73.226 40.344999,-74.500997 40.344999))",
145 | "id": "ny",
146 | "end_production_date": "20140406"
147 |
148 |
149 | To query for the public transport lines of New York we thus have to call: http://api.navitia.io/v1/coverage/ny/lines
150 |
151 |
152 | Easy isn't it?
153 |
154 | We could push the exploration further and:
155 |
156 | * get all the stop areas of the line with the uri ``line:BCO:Q10`` (the first line of the last request): http://api.navitia.io/v1/coverage/ny/lines/line:BCO:Q10/stop_areas/
157 | * get the upcoming departures in the first stop area found with the last request (uri of the stop area ``stop_area:BCO:SA:CTP-BCO550123``):
158 | http://api.navitia.io/v1/coverage/ny/stop_areas/stop_area:BCO:SA:CTP-BCO550123/departures/
159 | * get all the upcoming departures in the first stop area found in the last request, for the network mta:
160 | http://api.navitia.io/v1/coverage/ny/stop_areas/stop_area:BCO:SA:CTP-BCO550123/networks/network:mta/departures/
161 |
162 |
163 | What places have a name that start with 'tran'
164 | **********************************************
165 |
166 | The ``places`` API finds any object whose name matches the first letters of the query.
167 |
168 | To find the objects that start with "tran" the request should be: http://api.navitia.io/v1/coverage/ny/places?q=tran
169 |
170 | This API is fast enough to use it for autocompleting a user request.
171 |
172 | What places are within 1000 meters
173 | **********************************
174 |
175 | The ``places_nearby`` API finds any object within a certain radius as a crow flies.
176 | This API is not accessible from the main endpoint but has to be applied on a stop point, an address, some coordinates,...
177 |
178 | All objects around the coordinates of the Transamerica Pyramid can be fetched with the following request: http://api.navitia.io/v1/coverage/sf/coords/-122.402770;37.794682/places_nearby
179 |
180 | We could, in the same fashion, ask for the objects around a particuliar stop area (``stop_area:BCO:SA:CTP-BCO550123`` for example): http://api.navitia.io/v1/coverage/ny/stop_areas/stop_area:BCO:SA:CTP-BCO550123/places_nearby
181 |
182 | Optionally you can select what object types to return and change the radius.
183 |
184 |
185 | What stations can be reached in the next 60 minutes
186 | ***************************************************
187 |
188 | The API can computes *all* the reachable stop points from an origin within a given maximum travel duration.
189 |
190 | All the stop points that can be reached from the Transamerica Pyramid can be fetched with the following request:
191 | http://api.navitia.io/v1/coverage/sf/coords/-122.402770;37.794682/journeys
192 |
193 | It returns for each destination stop point the earliest arrival and a link to the journey detail.
194 |
195 |
196 | Getting help
197 | ------------
198 |
199 | All available functions are documented on
200 | .. toctree::
201 | :maxdepth: 1
202 |
203 | integration
204 |
205 | A mailing list is available to ask question: navitia@googlegroups.com
206 |
207 | In order to report bug and make requests we created a `github navitia project `_ .
208 |
209 | At last, we are present on IRC on the network Freenode, channel #navitia.
210 |
211 | About…
212 | ------
213 |
214 | About the service
215 | *****************
216 | If you plan to build something successful, contact us to get an access with more vitamins and even more support.
217 |
218 | For the moment, the service is not hosted on a powerful server, so please don't make more than one request per second.
219 |
220 | .. warning::
221 | Authentication is not required now, but will soon become (within april 2014).
222 | Please contact us for details.
223 |
224 |
225 |
226 | About the data
227 | **************
228 |
229 | The street network is extracted from `OpenStreetMap `_ .
230 |
231 | The public transport data are provided by networks that provide their timetables as open data.
232 |
233 | Some data improvement are achieved by Canal TP.
234 |
235 | About Canal TP
236 | **************
237 |
238 | `Canal TP `_ is the editor of *navitia*. We are a company based in Paris, leader in
239 | France for public transport information systems.
240 |
241 | If you speak French, visit our `technical blog `_ .
242 |
243 |
--------------------------------------------------------------------------------