Skip to content

Update Passenger Services Mode for new commuter shuttle fields#927

Merged
schnuerle merged 14 commits intoopenmobilityfoundation:devfrom
matthewmarwedel:dev
Mar 25, 2025
Merged

Update Passenger Services Mode for new commuter shuttle fields#927
schnuerle merged 14 commits intoopenmobilityfoundation:devfrom
matthewmarwedel:dev

Conversation

@matthewmarwedel
Copy link
Copy Markdown
Contributor

@matthewmarwedel matthewmarwedel commented Feb 3, 2025


name: Matthew Marwedel, SFMTA @matthewmarwedel supported by @Mu-yi-Zhou, @monachiu, and @alexdemisch (SFMTA)
about: Suggest changes to MDS to support commuter shuttles within passenger services mode
title: Adding new fields to Passenger Services mode to support Commuter Shuttles


Explain pull request

SFMTA would like to update the passenger services mode in MDS to include support for commuter shuttles. Most fields in passenger services match the needs of commuter shuttle (such as stop_id, lat, long, etc.) We would like to add three additional fields for commuter shuttle use. These fields would be optional (required for commuter shuttle use case, but optional as an MDS field). When those fields are implemented, we would like to add support to integrate GTFS endpoints to passenger services mode to track shuttle routes.

Initial pull request includes:
adding service_id field to [Events, Trips, Telemetry]
adding route_id field to [Events, Trips, Telemetry]
adding stop_sequence field to [Events, Trips, Telemetry]

Once this is implemented we will build on the pull request for the following:
adding GTFS integration in MDS for route_id and service_id

Is this a breaking change

A breaking change would require consumers or implementors of the API to modify their code for it to continue to function (ex: renaming of a required field or the change in data type of an existing field). A non-breaking change would allow existing code to continue to function (ex: addition of an optional field or the creation of a new optional endpoint).

  • No, not breaking

We would like to add some optional fields fields to passenger services mode along with an optional Schedule endpoint in the future to support commuter shuttles. Existing code will continue to function.

Impacted Spec

Which spec(s) will this pull request impact?

  • agency
  • provider
  • policy

Additional context

N/A

adding route_id field to [Events, Trips, Telemetry]
adding stop_sequence field to [Events, Trips]

Signed-off-by: Matthew Marwedel <[email protected]>
@matthewmarwedel matthewmarwedel requested a review from a team as a code owner February 3, 2025 19:33
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 3, 2025

CLA assistant check
All committers have signed the CLA.

@schnuerle schnuerle added enhancement New feature or request Provider Specific to the Provider API Agency Specific to the Agency API Policy Specific to the Policy API labels Feb 4, 2025
@schnuerle
Copy link
Copy Markdown
Member

schnuerle commented Feb 7, 2025

Some items to consider, based on OMF staff discussion with SFMTA staff.

  1. Should these fields be in the data types for all modes, or in just Passenger Service
  2. Potentially add a service_id to better describe the route id
  3. Could add another field route_name, or reference it only in external endpoint in Schedule
  4. Maybe add stop_sequence to telemetry too
  5. Policy and Geography may not need route and stop info, geographic policies should be sufficient
  6. A draft of what's in Schedule would be useful to see, like route info, stop sequence, calendar (days of week), calendar dates (month/day of operation), including exceptions
    • GTFS could be the solution here. Would need to make sure route_id, service_id is in GTFS Schedule format, and new GTFS URL (info) field in MDS Trips. GTFS_Stop_id may be needed in events too.
  7. stop sequence might not need to go in Trips
  8. Might need a gtfs_url in the providers.csv file to track new operator IDs
  9. Operators would generate a unique device_id UUID, but can also use VIN, license plate, USDOT id, etc fields.

@schnuerle
Copy link
Copy Markdown
Member

We will be discussing this at this week's MDS Working Group meeting. Please review and leave your comments and use cases and questions ahead of time.

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

matthewmarwedel commented Feb 12, 2025

Hi all,

Replying to earlier discussion points with my thoughts

  1. Should these fields be in the data types for all modes, or in just Passenger Service
    I think there is a lot of potential for other modes and the new fields should be for all modes. I would love to hear thoughts from other OMF members
  2. Potentially add a service_id to better describe the route id
    service_id and route id will both be needed to show what the route is and what times it runs. These can reference routes.txt, calendar.txt, and calendar_dates.txt in GTFS.
  3. Could add another field route_name, or reference it only in external endpoint in Schedule
    Referencing routes.txt in GTFS may be the best option here, no route_name field needed
  4. Maybe add stop_sequence to telemetry too
    Yes, add stop_sequence to Telemetry
  5. Policy and Geography may not need route and stop info, geographic policies should be sufficient
    Policy and Geography endpoints don't need the new fields (stop_sequence, service_id and route id)
  6. A draft of what's in Schedule would be useful to see, like route info, stop sequence, calendar (days of week), calendar dates (month/day of operation), including exceptions
  • GTFS could be the solution here. Would need to make sure route_id, service_id is in GTFS Schedule format, and new GTFS URL (info) field in MDS Trips. GTFS_Stop_id may be needed in events too.
    Use routes.txt, calendar.txt, and calendar_dates.txt in GTFS as the schedule with route_id and service_id matching GTFS format. I'm not sure if that alone is enough to connect MDS to the GTFS spec, if not a gtfs_url field may be needed in [Trips, Events, Telemetry]. I'm also not sure if the gtfs_url field would be needed in all of them. Would love insight from OMF community on this.
  1. stop sequence might not need to go in Trips
    Not sure, depends if stops are in MDS or GTFS. For now, it seems like stop sequence will stay in MDS and GTFS stops won't be needed.
  2. Might need a gtfs_url in the providers.csv file to track new operator IDs
    Yes, add a gtfs_api_url field to the MDS provider list
  3. Operators would generate a unique device_id UUID, but can also use VIN, license plate, USDOT id, etc fields.
    This sounds good.

Added service id and GTFS integration for to events, trips, and telemetry.

Added stop_sequence to Telemetry.

Signed-off-by: Matthew Marwedel <[email protected]>
Added gtfs_api_url column with blank values for now.

Signed-off-by: Matthew Marwedel <[email protected]>
Corrected some comma errors

Signed-off-by: Matthew Marwedel <[email protected]>
@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

I added a new commit to the pull request finalizing a few changes discussed above.

  • stop_sequence was added to Telemetry
  • service_id was added to Events, Trips, Telemetry
  • GTFS integration support was added to documentation in Events, Trips, Telemetry
  • gtfs_api_url was added to providers.csv

@schnuerle
Copy link
Copy Markdown
Member

schnuerle commented Feb 13, 2025

Open questions:

  • Should stop_sequence, route_id, service_id be in the base MDS objects so they can be used for more than one mode (eg, maybe for Delivery Robots too), or should they only be in the Passenger Services mode?
  • Do stop_sequence, route_id, service_id need to all be in Events, Telemetry, and Trips?
  • What role does MDS Stops play in this, if any?

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

matthewmarwedel commented Feb 14, 2025

Hi all,

After the OMF discussion, I will be reviewing the following updates to the pull request with the SFMTA team:

  • removing stop_sequence from Trips, Telemetry
  • adding stop_id_gtfs to Events
  • adding supporting documentation for the gtfs_api_url field in providers.csv (the Adding an MDS Provider ID page)
  • adding a gtfs_api_url field to Trips, Events for linking route_id, service_id, and stop_id_gtfs to the correct gtfs url

@schnuerle
Copy link
Copy Markdown
Member

  • adding stop_id_gtfs to Events

I think call this gtfs_stop_id, per some other MDS/CDS naming conventions.

  • adding supporting documentation for the gtfs_api_url field in providers.csv (the Adding an MDS Provider ID page)

The gtfs_api_url field can be removed from providers.csv, thus reverting it back to the way it was. Instead adding it to Trips, Events would be enough. Operators can still add their name, website, UUID, and applicable mode to the file, but it doesn't make sense to add a single URL for GTFS.

Removed stop_sequence from telemetry, trips
Added gtfs_api_url to events, trips
Added gtfs_stop_id to events
Added shape_id to trips

Signed-off-by: Matthew Marwedel <[email protected]>
Removed gtfs_api_url column (it is now included in data_types.md)

Signed-off-by: Matthew Marwedel <[email protected]>
@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

Summary of changes I made from suggestions:

  • removed stop_sequence from Trips, Telemetry
  • added gtfs_stop_id to Events
  • added shape_id to Trips
  • removed gtfs_api_url column in providers.csv
  • added a gtfs_api_url field to Trips, Events for linking route_id, shape_id, service_id, and gtfs_stop_id to the correct gtfs url

@stevenmwhite
Copy link
Copy Markdown

I have not been involved in the development of MDS over the past few years, but back in 2020 I was collaborating with Ellis & Associates / Lacuna Tech. on a proposal to add fixed-route service to MDS for LADOT (my company manages the fixed route dispatch software and GTFS/GTFS-RT for LADOT). It never really got off the ground, but I'm going to share the notes of where we had progressed to.

I'm not proposing or advocating for anything here, simply sharing for your information. Do keep in mind that this was based on the state of the spec in 2020 and may include assumptions that are well out of date today.
mds_fixed_route.md

Clarified service_id and route_id definitions; removed gtfs_stop_id from events; added gtfs_trip_id to events, telemetry, trips

Signed-off-by: Matthew Marwedel <[email protected]>
@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

matthewmarwedel commented Mar 5, 2025

Summary of changes I made after discussion with SFMTA team on matching MDS to GTFS format:

  • Clarified definitions of route_id, service_id in Trips, Telemetry, Events to match GTFS route-trip schedule format
  • Added gtfs_trip_id to Trips, Telemetry, Events
  • Removed gtfs_stop_id from Events; MDS existing stop_id field will be used instead

@schnuerle
Copy link
Copy Markdown
Member

schnuerle commented Mar 10, 2025

  1. Shouldn’t the gtfs_shape_id in MDS Trips for the shapes.txt file be discoverable via the associated route_id, service_id, and trip_id in the GTFS trips.txt file? If so the `gtfs_shape_id' field in MDS Trips is not needed.

  2. For the MDS Events stop_sequence field, are these be the same as the GTFS stop_sequence field in stop_times.txt, and should we reference that in the description with a link?

    • Is stop sequence even needed here, and instead use the stop_id field from GTFS (which includes the expected sequence). Even if there is an unexpected stop, the stop sequence can be determined by timestamps in MDS events or telemetry.
  3. MDS Events has a trip_ids field to connect to MDS Trips. Can gtfs_route_id, gtfs_service_id, and gtfs_trip_id just be cross referenced via the trip id in MDS Trips? Even if a bus is not on a trip, then referencing GTFS trip info won’t be needed or possible anyway.

  4. MDS Telemetry has a trip_ids field to connect to MDS Trips, so can gtfs_route_id, gtfs_service_id, and gtfs_trip_id just be cross referenced via the trip id? Similar to item 3 above.

  5. Do MDS Events and MDS Telemetry need a gtfs_api_url field, if they happen when they are not on a GTFS trip? If on a GTFS trip, can it just reference this gtfs_api_url field in MDS Trips via trip_id?

  6. MDS Telemetry and MDS Events each have their own timestamp and location fields built in. MDS Telemetry has an MDS stop_id field to reference MDS Stops, and Events has a new GTFS stop_sequence field. But shouldn’t Telemetry and Events have a stops.txt GTFS gtfs_stop_id field to know when the bus stopped at a scheduled GTFS stop along the route?

  7. What is the need ofgtfs_service_id in MDS Trips? service_id in GTFS connects to the calendar.txt file, which only are used to "define exceptions to the default service patterns." I may be missing a use case here.

  8. In MDS Trips, gtfs_route_id references a route_id in GTFS, but this ID is already part of the trips.txt field that is referenceable via the gtfs_trip_id field. So it may not be needed to be duplicated here.

Let me see if I can summarize all of this.

MDS Events

Current:

  • stop_sequence
  • gtfs_route_id
  • gtfs_service_id
  • gtfs_trip_id
  • gtfs_api_url

Proposed:

  • gtfs_stop_id
  • use trip_ids to make GTFS field connections

MDS Telemetry

Current:

  • gtfs_route_id
  • gtfs_service_id
  • gtfs_trip_id

Proposed:

  • gtfs_stop_id
  • use trip_ids to make GTFS field connections

MDS Trips

Current:

  • gtfs_route_id
  • gtfs_service_id
  • gtfs_shape_id
  • gtfs_trip_id
  • gtfs_api_url

Proposed:

  • gtfs_trip_id
  • gtfs_api_url

I may have to turn the proposed fields into a diagram to show the connections between MDS objects and GTFS too, because this is tricky to follow otherwise!

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

Hi @schnuerle,

We reviewed within SFMTA and agreed with most of your proposal. I will update the pull request with the below.

MDS Events

  • remove gtfs_route_id, gtfs_trip_id, gtfs_service_id, gtfs_api_url; These can all be found by linking to MDS trips with MDS trip_id.
  • remove stop_sequence; We can get this information ourselves using the stop_id and timestamp fields for each MDS trip_id so this field doesn't need to be part of the spec

MDS Telemetry

  • remove gtfs_route_id, gtfs_trip_id, gtfs_service_id; These can all be found by linking to MDS trips with MDS trip_id.

MDS Trips

  • remove gtfs_route_id, gtfs_service_id, gtfs_shape_id; These can all be found by linking to GTFS trips with GTFS trip_id and the GTFS API URL.

The remaining issue is gtfs_stop_id in MDS Events and MDS Telemetry. Since SFMTA is planning to use MDS stop_id here, we don't need a gtfs_stop_id field. I won't add it back to the pull request for now, but if you want to add it back as an optional field that other jurisdictions can use that works. Let me know and I will update the pull request to have it as optional.

MDS Events
- removed gtfs_route_id, gtfs_trip_id, gtfs_service_id, gtfs_api_url; These can all be found by linking to MDS trips with MDS trip_id.
- removed stop_sequence; We can get this information ourselves using the stop_id and timestamp fields for each MDS trip_id so this field doesn't need to be part of the spec

MDS Telemetry
- removed gtfs_route_id, gtfs_trip_id, gtfs_service_id; These can all be found by linking to MDS trips with MDS trip_id.

MDS Trips
- remove gtfs_route_id, gtfs_service_id, gtfs_shape_id; These can all be found by linking to GTFS trips with GTFS trip_id and the GTFS API URL.

Signed-off-by: Matthew Marwedel <[email protected]>
@schnuerle
Copy link
Copy Markdown
Member

Thank you looks great and is much simpler!

For gtfs_stop_id in MDS Events and MDS Telemetry, I feel like that is what SFMTA (and others) should use, instead of MDS' stop_id.

MDS stop_id is a UUID, and explicitly references the Stops object, so it would not work as the stop identifier in GTFS that you would be interested in knowing about for Events and Telemetry.

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

@schnuerle The plan is for SFMTA to actually put all our stops into MDS Stops endpoint and use those, but I will add back in gtfs_stop_id to Events, Telemetry as an optional field in case another jurisdiction wants to use it or SFMTA decides to use it in the future.

Added gtfs_stop_id back to Events, Telemetry

Signed-off-by: Matthew Marwedel <[email protected]>
@schnuerle
Copy link
Copy Markdown
Member

Thank you Matt, that makes sense to both have it there to connect to GTFS data, or use MDS Stops.

How are you planning on creating each stop for each route for each operator using MDS Stops? Are all the data fields you need for that in MDS Stops already? Anything else you'd need to support this?

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

@schnuerle All the operators use the same stops since they are determined by our commuter shuttle stop map so we just made an MDS Stops endpoint that references these stops. We are using the short_name field to write in the stop numbers and have UUIDs for each stop. Right now, the only missing field is there is no regular MDS stop_id field in MDS Events like there is in MDS Telemetry. Do you know the reasoning behind this?

@schnuerle
Copy link
Copy Markdown
Member

Ok that makes sense for your use of MDS Stops. And I think it's good to add back gtfs_stop_id.

I am not 100% on the reasoning why MDS stop_id is in Telemetry, but not Events. I think it should be added as optional to Events too. You or I can add that as part of this pull request, and look for feedback from the working group on this.

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

Hi @schnuerle Sorry for the late reply, I have updated the PR one last time by putting MDS stop_id into MDS Events with the same language found in MDS Telemetry.

@matthewmarwedel
Copy link
Copy Markdown
Contributor Author

Hi @schnuerle I wanted to update you that I am planning to leave SFMTA at the end of this week and go to a new position elsewhere. If it's possible to get this pull request merged by the end of the week that would be great. I do feel that it's been thoroughly reviewed and it's ready for merge with the dev branch. If not, the Github handles for the rest of the SFMTA team are: @Mu-yi-Zhou, @monachiu, and @alexdemisch. Please contact them for additional questions on the pull request.

@schnuerle
Copy link
Copy Markdown
Member

Hi @matthewmarwedel yes, agree it can be pushed to dev. We had a recap at the last working group meeting (see link for slide and recording) about the status of it and gave people another full week to comment. So I will review and push to dev. Thanks for your work and good luck in your new endeavor!

@schnuerle schnuerle merged commit 182ebb1 into openmobilityfoundation:dev Mar 25, 2025
1 check passed
@ericyco
Copy link
Copy Markdown

ericyco commented May 9, 2025

Hi @schnuerle, one issue that's come up with our data providers who manage GTFS files is that MDS gtfs_trip_id requires a UUID while GTFS doesn't.

https://github.com/openmobilityfoundation/mobility-data-specification/blob/dev/data-types.md#trips
gtfs_trip_id | UUID | Required if Applicable | A unique trip ID for the associated scheduled GTFS route-trip. Matches GTFS trip_id in the trips.txt and other files.

https://github.com/google/transit/blob/master/gtfs/spec/en/reference.md#tripstxt
trip_id | Unique ID | Required | Identifies a trip.

There doesn't seem to be overwhelming support within the GTFS community to update their standard to start restricting their trip_id Unique IDs to UUID:
google/transit#518

Since this needs to match GTFS trip_id, shouldn't we update MDS gtfs_trip_id type to be a string instead of UUID?

@schnuerle
Copy link
Copy Markdown
Member

@ericyco You are absolutely right, I can't believe I didn't see that sooner. It should be a string to keep it generic enough. I'll update.

@schnuerle
Copy link
Copy Markdown
Member

@ericyco take a look and check my work if you can, for the updates here at PR #937.

@ericyco
Copy link
Copy Markdown

ericyco commented May 9, 2025

@schnuerle looks great, thanks for the quick update on both gtfs_trip_id and gtfs_stop_id!

@schnuerle
Copy link
Copy Markdown
Member

Alright, merged to dev now, thanks for the catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Agency Specific to the Agency API enhancement New feature or request Policy Specific to the Policy API Provider Specific to the Provider API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for fixed-route services Add fixed Route Identifier to trips endpoint, geography API and policy API

5 participants