Graphviz connection graph script
This commit is contained in:
parent
865e3a0e6c
commit
451f9304fb
|
@ -0,0 +1,13 @@
|
|||
[ -e lines.json ] || wget "https://data.metromobilite.fr/api/lines/json?types=ligne&reseaux=SEM" -O lines.json
|
||||
[ -e routes.json ] || wget "https://data.metromobilite.fr/api/routers/default/index/routes" -O routes.json
|
||||
|
||||
cat > /tmp/connections <<EOF
|
||||
graph connections {
|
||||
node [style=filled, fontsize=20, fontname="sans-serif"]
|
||||
EOF
|
||||
|
||||
jq -rf jq/graphnodes.jq routes.json >> /tmp/connections
|
||||
jq -rf jq/graphedges.jq lines.json >> /tmp/connections
|
||||
|
||||
echo '}' >> /tmp/connections
|
||||
circo -Tpng /tmp/connections > connections.png
|
|
@ -0,0 +1,26 @@
|
|||
[
|
||||
# Build (line, stop) tuples from each line
|
||||
[
|
||||
.features[].properties
|
||||
| . as $prop
|
||||
| .ZONES_ARRET[]
|
||||
| { line: $prop.id, stop: . }
|
||||
]
|
||||
# Group everything by stop and only retrieve lines
|
||||
# This gives us all connected lines on a given stop
|
||||
| group_by(.stop)[]
|
||||
| [
|
||||
.[].line
|
||||
# Ignore buses acting as tramways
|
||||
| select(startswith("SEM_8") | not)
|
||||
]
|
||||
# Ignore stops with only one bus line
|
||||
| select(length > 1)
|
||||
# Get all combinations, ignoring edges pointing to themselves
|
||||
| combinations(2)
|
||||
| select(.[0] != .[1])
|
||||
]
|
||||
# Remove duplicate edges like A-B and B-A
|
||||
| unique_by(sort)[]
|
||||
# Output as DOT edges
|
||||
| join(" -- ")
|
|
@ -0,0 +1,11 @@
|
|||
.[]
|
||||
| select(
|
||||
# Ignore non-TAG lines
|
||||
(.id|startswith("SEM"))
|
||||
# Ignore special lines for buses acting as tramways
|
||||
and [.mode, .type] != ["BUS", "TRAM"]
|
||||
)
|
||||
# Replace IDs with the underscored IDs from edges
|
||||
| .id |= sub(":"; "_")
|
||||
# Node descriptions with colors
|
||||
| "\(.id) [label=\"\(.shortName)\", fillcolor=\"#\(.color)\", fontcolor=\"#\(.textColor)\"]"
|
Loading…
Reference in New Issue