Skip to content

derhuerst/generate-vbb-transit-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

generate-vbb-transit-map

Generate an SVG transit map for Berlin public transport. Consumes data in the JSON Graph Format, e.g. generated by TransitmapSolver, which in turn consumed data from generate-vbb-graph.

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install -g generate-vbb-transit-map

Or just run it using npx:

cat graph.json | npx generate-vbb-transit-map > map.svg

Usage

From the command line:

Usage:
    generate-vbb-transit-map
Examples:
    cat graph.json | generate-vbb-transit-map > map.svg

As a library:

const generateTransitMap = require('generate-vbb-transit-map')

const graph = require('./graph.json') // some data
const map = generateTransitMap(graph)

map will be a virtual-dom <svg> element. Generate an SVG string like this:

const toString = require('virtual-dom-stringify')

console.log(toString(svg))

Input data format

The input data must be in the JSON Graph Format. An example graph.json might look like this:

{
	"nodes": [ // list of all nodes
		{
			"id": "900000042101", // required
			"metadata": {
				"x": 537.029, // x-coordinate in any metric, required
				"y": 673.576 // y-coordinate in any metric, required
			}
		}
		// …
	],
	"edges": [ // list of all edges
		{
			"source": "900000120025", // node id, required
			"target": "900000120008", // node id, required
			"metadata": {
				"line": "U5"
			}
		}
		// …
	]
}

Contributing

If you have a question or have difficulties using generate-vbb-transit-map, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.