colorize-transit-graph
Add “random” line colors to a given transit graph, e.g. generated using osm-transit-graph
.
Installation
npm install -g colorize-transit-graph
Usage
The library will add color
attributes to all lines / line groups that don't yet have color information. Existing colors will be conserved.
The output graph could then be drawn by using svg-transit-map
.
CLI
Usage:
cat graph.json | colorize-transit-graph > colorized-graph.json
Where graph.json
containts a graph object with three attributes:
{
nodes: [
{
id: "900000042101",
metadata: {
x: 537.029,
y: 673.576
}
}
],
edges: [
{
source: "900000120025",
target: "900000120008",
metadata: {
lines :["U5","U6"]
}
}
],
lines: [
{
id: 'U6',
color: '#456',
group: 'U6'
}
]
}
As a library
The module can be used as a JS library:
const colorizeTransitGraph = require('colorize-transit-graph')
const graph = require('./graph.json')
const colorized = colorizeTransitGraph(graph)
Example
Graphs drawn using svg-transit-map
.
cat example/berlin-input.json | colorize-transit-graph > example/berlin-output.json
cat example/berlin-output.json | svg-transit-map > example/berlin-output.svg
Input
Output
Contributing
If you found a bug or want to propose a feature, feel free to visit the issues page.