conveyal / r5

Developed to power Conveyal's web-based interface for scenario planning and land-use/transport accessibility analysis, R5 is our routing engine for multimodal (transit/bike/walk/car) networks with a particular focus on public transit
https://conveyal.com/learn
MIT License
272 stars 71 forks source link

Include names in paths in CSV #930

Closed abyrd closed 4 months ago

abyrd commented 5 months ago

This makes it possible to represent stops and routes in CSV output using their names in addition to (or instead of) their IDs. Users have commented that they greatly prefer to work with the names, and often only with the names. Though they're not guaranteed to be unique, in some data sets names are clear enough to work well.

Showing route names has the additional major benefit of showing which modification created a route (instead of a meaningless UUID) in routes that did not come from GTFS.

As recently discussed, this also introduced a freeform Set<String> flags field in requests for enabling experimental, undocumented, or arcane behavior in backend or workers. When making a JSON request this will look like "flags": ["csv_names", "csv_no_ids"]. This should progressively replace all previous special behavior flags that were embedded inside analysis names etc.

I have tested this locally and it seems to work for all three entity representations.

Now that it's implemented, a few questions emerge. One is whether it's really worth it to define an enum for EntityRepresentation { ID_ONLY, NAME_ONLY, ID_AND_NAME } or it should just be two boolean parameters. Another is whether this would be better represented by actually adding a real enum-typed parameter to the requests. It would require less conversions and make it easier to toggle stop and route representations separately for example.

I think the flags facility should still be retained for other purposes even if we stop using it for this purpose.

abyrd commented 4 months ago

Updated to add a nested CsvRequestOptions structure to control route, stop, feed ID representation independently (as decided on 2024-02-08 meeting).

Order of name and ID have been reversed to place name first. String flags system continues to exist in requests but is no longer used to enable this feature.

This has been tested locally with no CsvRequestOptions, and with options affecting each of routes and stops separately, as well as together. It seems to work as intended.

  "csvResultOptions": {
    "stopRepresentation": "NAME_ONLY",
    "routeRepresentation": "NAME_AND_ID"
  },