Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicola/tubemaps
:mountain_cableway: Browser, NodeJs library and command-line tool for handling tube data
https://github.com/nicola/tubemaps
Last synced: 9 days ago
JSON representation
:mountain_cableway: Browser, NodeJs library and command-line tool for handling tube data
- Host: GitHub
- URL: https://github.com/nicola/tubemaps
- Owner: nicola
- Created: 2014-11-24T01:05:53.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-18T17:53:38.000Z (11 months ago)
- Last Synced: 2024-10-22T03:05:28.115Z (18 days ago)
- Language: JavaScript
- Homepage:
- Size: 900 KB
- Stars: 209
- Watchers: 10
- Forks: 29
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - nicola/tubemaps - :mountain_cableway: Browser, NodeJs library and command-line tool for handling tube data (others)
README
# Tubemaps
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nicola/tubemaps?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)Given a dataset, get all the tube/stations relations done!
![London tubemap](https://raw.githubusercontent.com/nicola/tubemaps/master/thumbnail.png)
[Visualizing the tube](http://bl.ocks.org/nicola/20beed2981b6607be961) in D3 and TubeMaps.
## Install
```bash
$ npm install --save tubemaps
```For command-line use:
```bash
$ npm install --g tubemaps
```Soon on **bower**.
## Command line tool
For now Command line only supports London
```sh
$ tubemaps path --from "Euston" --to "Hammersmith"
# Victoria Line: Euston to Warren Street
# Victoria Line: Warren Street to Oxford Circus
# Victoria Line: Oxford Circus to Green Park
# Victoria Line: Green Park to Victoria
# Victoria Line: Victoria to Sloane Square
# District Line: Sloane Square to South Kensington
# Piccadilly Line: South Kensington to Gloucester Road
# Piccadilly Line: Gloucester Road to Earl's Court
# District Line: Earl's Court to Barons Court
# Piccadilly Line: Barons Court to Hammersmith$ tubemaps station "Euston" --london
# Northern Line: Camden Town
# Victoria Line: King's Cross St. Pancras
# Northern Line: Mornington Crescent
# Victoria Line: Warren Street
# Victoria Line: King's Cross St. Pancras
# Victoria Line: Warren Street
```## NodeJS Library
```javascript
var TubeMap = require('tubemaps').TubeMap;
var london = new TubeMap({
stations: csv.stations,
lines: csv.lines,
connections: csv.connections
});// Find information about a station
var victoriaStation = london.getStationByName('Victoria');
// {conns:[{display_name: "Euston"}, ...], ..}// Find information a line
var victoriaLine = london.getLineByName('Victoria Line');
// [station1, station2,..]// Find all connections in a line
var conns = london.line(victoriaLine)
// [{station1: #euston, station2: #warrentStreet}]// Find path between two stations
var conns = london.path(euston, victoria)
// [{station1: #euston, station2: #warrentStreet, line: #victoriaLine}]// Find path between two stations in a line
var conns = london.path(euston, victoria, line)
// [{station1: #euston, station2: #warrentStreet, line: #victoriaLine}]
```## Existing datasets
#### London
```javascript
var Maps = require('tubemaps/maps');Maps("london", function(err, tube) {
var euston = tube.getStationByName("Euston");
var victoria = tube.getStationByName("Victoria");
console.log(tube.path(euston, victoria))
})
```#### Use yours
Look at our datasets and make it identical but with your data
```javascript
var TubeMap = require('tubemaps').TubeMap;
var readCSVs = require('tubemaps/csv').readCSVs;var files = {
connections: __dirname + '/../datasets/london.connections.csv',
lines: __dirname + '/../datasets/london.lines.csv',
stations: __dirname + '/../datasets/london.stations.csv'
};readCSVs(files, function(err, csvs) {
var tubemap = new TubeMap({
connections: csvs[0],
lines: csvs[1],
stations: csvs[2]
});var victoriaLine = tubemap.getLineByName("Victoria Line");
console.log(tubemap.line(victoriaLine.line));});
```## Examples
- [London Tubemap showing closures](http://bl.ocks.org/nicola/dd355954e9b4ae524963)
- [London Tubemap visualization](http://bl.ocks.org/nicola/20beed2981b6607be961)
- [London Tubemap with Voronoi visualization](http://bl.ocks.org/nicola/10e25b18aca0bc05b192)## Want to contribute or add dataset?
- Ping me on twitter @nicolagreco, or a PR here.