Skip to content

Commit fef19de

Browse files
author
Billy Charlton
committed
transit colors
1 parent e6fc222 commit fef19de

2 files changed

Lines changed: 141 additions & 11 deletions

File tree

docs/assets/transit.jpg

101 KB
Loading

docs/matsim-transit-supply.md

Lines changed: 141 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,160 @@ id: transit-supply
33
title: MATSim Transit supply/demand
44
---
55

6-
![transit banner](assets/transit.jpg)
7-
_Transit routes_
6+
<img style="border: 1px solid #aac" src="assets/transit.jpg" title="transit banner">
7+
_Transit routes and station boardings/alightings_
88

9-
This viz shows transit route details.
9+
The transit viewer displays MATSim public transport networks, along with passenger demand if available.
1010

1111
## Usage
1212

13-
No YAML is required. If the run folder contains a `*output_transitSchedule.xml.gz` file, then this view will be available and the transit route supply can be explored.
13+
If the run folder contains a `*output_transitSchedule.xml.gz` file, then this view will be automatically available.
1414

1515
**Stop-to-stop ridership:** If the run folder also contains `*pt_stop2stop_departures.csv.gz` then the transit ridership (demand) will also be loaded. This may take a few seconds.
1616

17-
## Dashboard
17+
A standalone `viz-pt-*.yaml` file can also be used to set all configuration parameters; see dashboard config below.
18+
19+
### Exploring the transit system
20+
21+
Click on any transit link to see the list of transit routes which traverse that link. You can select any individual route from the details panel to see the extent of the route.
22+
23+
Selecting a transit line or a line's transit routes (routes are always children under one line) by clicking a link or using the search panel.
24+
25+
**Line widths** represent the number of vehicle departures on a specific link. Passenger volumes and load factors are also available if the `stop2stop` file is available.
26+
27+
**Boardings/alightings** will be shown at each stop if the `stop2stop` file is available. They are show as pie charts at each stop location.
28+
29+
## Dashboard and YAML config
30+
31+
The following configuration options are available when embedding the transit viewer in a dashboard or YAML config file. Use `type: transit` for this plugin.
32+
33+
### Field descriptions
34+
35+
**title:** (optional) title of the visualization, appears right on top of the map. If a title is specified both under `general` and under `props`, the one under `general` will be used.
36+
37+
**description:** (optional) one line additional detail about this view.
38+
39+
**transitSchedule:** (required) the `*transitSchedule.xml.gz` file from the simulation.
40+
41+
**network:** The MATSim network file that matches the transit schedule. The following network formats are supported. If no network is specified in a YAML config, these files are searched for in the folder containing the transit schedule:
42+
- Avro: `*network.avro` file using the new MATSim Avro network format. Avro network files are smaller and load faster than XML. If your simulation doesn't create this automatically, you can generate it using this Python script: [create-avro-network.py](https://github.com/simwrapper/simwrapper/raw/refs/heads/master/scripts/create-avro-network.py)
43+
- XML: standard `*network.xml.gz` MATSim output network
44+
- GeoJSON: Network files converted to GeoJSON also work.
45+
46+
**projection:** (optional) the EPSG code e.g. "EPSG:25832" which specifies the coordinate reference system in use. Most recent MATSim networks, including Avro files, already have this embedded, but sometimes it is incorrect or set to "Atlantis". You must have the correct EPSG code to place the network on a background map.
47+
48+
**colors:** (optional) a list of rules to assign color codes to transit lines. If unset, the default set is used which is based on GTFS codes and/or the `transportMode` attribute from each transit route. See below for a detailed description.
49+
50+
**customRouteTypes:** (deprecated) same as `colors:` above.
51+
52+
### Route color configuration
53+
54+
The default colors use GTFS codes if available, followed by the `transportMode` attribute. But you might want to modify the the default colors.
55+
56+
`colors` is interpreted as a **list of rules**. Here's how it works; see the example below which makes it easier to understand.
57+
58+
- Each transit route starts at the top of the list and works its way down the list until it finds a matching rule.
59+
- Each rule consists of **match criteria**, a **color code**, and a **label** for the legend. An option **hide** boolean can be set as well.
60+
- The `match` criteria are one more route property keys such as _gtfsRouteType_ or _transportMode_ or _id_, followed by the value or set of possible values for that key.
61+
- The first rule that matches ALL criteria for this route is used as the label and color for this transit route.
62+
- If any of the match criteria in a rule do not match the details of the current route, this rule is skipped and the next rule on the list is tried. This continues down the list until a rule matches for the route.
63+
- A default color is used for "Other" if no rules match at all.
64+
65+
The `color:` field in a rule can either a [standard CSS color](https://i.pinimg.com/originals/ad/07/fa/ad07fab27cc455481593fe3704cdd800.png) such as red, yellow, green; or a [CSS hex code](https://www.kindpng.com/picc/m/197-1970796_hex-color-code-samples-png-download-hexagonal-color.png) such as `#ff0` for more options.
66+
67+
The `match:` property can be either a single value (string or numeric), or a list of possible values -- only one of which needs to match. So you can set `transportMode: 'rail'` or `transportMode: ['rail', 'subway']` and the transport mode must be "rail" in the first case and must be "rail" OR "subway" in the second.
68+
69+
An optional `hide: true` can be included on any rule to hide any routes which match that rule.
70+
71+
If a rule contains multiple match criteria, ALL of them must match for the rule to be used. So, you can say you want `transportMode: 'rail'` AND `id: 'M*'` to be red for "Metro" routes.
72+
73+
Some examples of rules:
1874

19-
The following configuration options are available when embedding the transit viewer in a dashboard. Use `type: transit` for this plugin.
75+
```yaml
76+
# Three rules to set colors for S-Bahn, U-Bahn, and Bus/Other
77+
colors:
78+
- label: "S-Bahn" # for the legend
79+
color: "red" # CSS color or "#00ff00" hexcode in quotes
80+
match:
81+
transportMode: ["rail","subway"] # match either rail OR subway
82+
id: "S*" # AND match all lines beginning with "U"
83+
84+
- label: "U-Bahn" # for the legend
85+
color: "blue"
86+
match:
87+
transportMode: ["rail","subway"] # match either rail OR subway
88+
id: "U*" # AND match all lines beginning with "U"
89+
90+
- label: "Bus/Other" # for the legend
91+
color: "#660" # hex color codes must be in quotes
92+
match:
93+
id: "*" # Match everything else: catch-all.
94+
```
95+
96+
GTFS codes are often on MATSim networks generated from Open Street Map data. At VSP we find that using GTFS codes from `gtfsRouteType` first (at the top of the list), followed by `transportMode` rules lower down as a backup works pretty well.
97+
98+
Note that the match value can be a single string or number; or it can be a list of possible values (only one of which needs to match).
99+
100+
101+
### Example dashboard.yaml
102+
```yaml
103+
layout:
104+
row1:
105+
- type: transit
106+
title: Transit Explorer
107+
description: My simulation
108+
transitSchedule: "*transitSchedule.xml.gz"
109+
network: "*output_network.xml.gz" # or "network.avro"
110+
# Provide the EPSG coordinate system if the crs is not embedded in network file
111+
projection: EPSG:25832
112+
```
113+
114+
### Example dashboard.yaml with Avro network and color specifications based on GTFS and/or transportMode
20115
```yaml
21116
layout:
22117
row1:
23118
- type: transit
24119
title: Transit Explorer
25-
network: "*output_network.xml.gz"
26-
transitSchedule: "*output_transitSchedule.xml.gz"
27-
projection: EPSG:25832 # Use your EPSG coordinate system here
120+
description: My simulation
121+
transitSchedule: "*transitSchedule.xml.gz"
122+
network: "*network.avro"
123+
colors:
124+
- label: 'Bus (GTFS)'
125+
color: '#95276E'
126+
match:
127+
gtfsRouteType: [3, 700, 701, 702, 703, 704]
128+
129+
- label: 'S-Bahn (GTFS)'
130+
color: '#408335'
131+
match:
132+
gtfsRouteType: [109]
133+
134+
- label: 'U-Bahn (GTFS)'
135+
color: '#115D91'
136+
match:
137+
gtfsRouteType: [401,402]
138+
139+
- label: 'Tram (GTFS)'
140+
color: '#BE1414'
141+
match:
142+
gtfsRouteType: [0, 3, 900, 901, 902, 903, 904, 905, 906]
143+
144+
- label: 'Rail'
145+
color: 'red'
146+
match:
147+
transportMode: ["train","rail"]
148+
149+
- label: 'Bus'
150+
color: '#070'
151+
match:
152+
transportMode: "bus"
153+
154+
- label: 'Other'
155+
color: 'darkMagenta'
156+
match:
157+
id: "*"
158+
159+
28160
```
29161

30-
### Exploring transit
31162

32-
Click on any transit link to see the list of transit routes which traverse that link. You can select any individual route from the details panel to see the extent of the route.

0 commit comments

Comments
 (0)