Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow remapping of agency_ids in GTFS-rt service alerts #114

Closed
barbeau opened this issue Jan 27, 2015 · 2 comments
Closed

Allow remapping of agency_ids in GTFS-rt service alerts #114

barbeau opened this issue Jan 27, 2015 · 2 comments
Assignees

Comments

@barbeau
Copy link
Member

barbeau commented Jan 27, 2015

We need to be able to re-map agency_ids that appear in GTFS-rt Service Alerts to match re-mapping done with GTFS data. Currently, the GTFS-rt spec only allows the agency_id field to be supplied in Service Alerts, so this only applies to Service Alerts.

Currently, the GtfsRealtimeSource config in data-sources.xml looks like this:

<bean class="org.onebusaway.transit_data_federation.impl.realtime.gtfs_realtime.GtfsRealtimeSource">
  <property name="tripUpdatesUrl" value="http://url/to/gtfs-realtime/trip-updates" />
  <property name="vehiclePositionsUrl" value="http://url/to/gtfs-realtime/vehicle-positions" />
  <property name="alertsUrl" value="http://url/to/gtfs-realtime/alerts" />

  <!-- Optionally configure the agency id we use to match incoming data -->
  <property name="agencyId" value="SomeAgencyId" />
</bean>

The agencyId property above is used to associate the GTFS-rt feeds with a particular agencyId from the GTFS data. However, currently the agencyId field in the GTFS-rt Service Alerts feed takes precedence, and as a result OBA can't match the alerts to the correct agency. Additionally, the GTFS-rt specs allow more than one agency to be represented in the same Service Alerts feed (hence the agency_id field), so we actually need a way to remap multiple agencyIds in the same Service Alerts feed.

We propose to implement this remapping in the data-sources.xml config file as a new alertAgencyIdMap property for GtfsRealtimeSource:

<bean class="org.onebusaway.transit_data_federation.impl.realtime.gtfs_realtime.GtfsRealtimeSource">
  <property name="tripUpdatesUrl" value="http://url/to/gtfs-realtime/trip-updates" />
  <property name="vehiclePositionsUrl" value="http://url/to/gtfs-realtime/vehicle-positions" />
  <property name="alertsUrl" value="http://url/to/gtfs-realtime/alerts" />

  <!-- Optionally configure the agency id we use to match incoming data -->
  <property name="agencyId" value="SomeAgencyId" />

  <!-- **Remap the following agencyIds in the GTFS-rt Service Alerts feed** -->
    <property name="alertAgencyIdMap">
        <map>
            <entry key="agencyIdInFeed" value="remappedAgencyId" />
        </map>
    </property>
</bean>

For example, here's a GTFS-rt Service Alerts feed:

entity {
  id: "1"
  alert {
    informed_entity {
      agency_id: "1"
    }
    header_text {
      translation {
        text: "new 29: 29"
        language: "
        ...

We need to remap the agency_id of 1 to PSTA. We would configure this as follows:

<bean class="org.onebusaway.transit_data_federation.impl.realtime.gtfs_realtime.GtfsRealtimeSource">
  <property name="tripUpdatesUrl" value="http://url/to/gtfs-realtime/trip-updates" />
  <property name="vehiclePositionsUrl" value="http://url/to/gtfs-realtime/vehicle-positions" />
  <property name="alertsUrl" value="http://url/to/gtfs-realtime/alerts" />

  <!-- Optionally configure the agency id we use to match incoming data -->
  <property name="agencyId" value="PSTA" />

  <!-- **Remap the following agencyIds in the GTFS-rt Service Alerts feed** -->
    <property name="alertAgencyIdMap">
        <map>
            <entry key="1" value="PSTA" />
        </map>
    </property>
</bean>

@cagryInside has tested this implementation and it works. He'll submit a PR shortly. Any feedback is welcome.

@sheldonabrown This is a solution to the issue we discussed via email.

@sheldonabrown sheldonabrown self-assigned this Jan 28, 2015
sheldonabrown added a commit that referenced this issue Jan 28, 2015
fix #114 - Implementing agency id remapping in realtime service alerts
@barbeau
Copy link
Member Author

barbeau commented Jan 28, 2015

I'm re-opening, as it looks like we missed re-mapping the agency_ids in the situationIds list.

For example, see the following REST API request:
http://app.staging.obahart.org/api/where/arrivals-and-departures-for-stop/PSTA_4077.json?key=TEST

The response:

data: {
    entry: {
        arrivalsAndDepartures: [
        ...
        ]
    }
        situationIds: [
        "1_1",
        "1_2"
        ]
        stopId: "PSTA_4077"
    },
    references: {
        ...
        situations: [
            {
                allAffects: [
                    {
                        agencyId: "PSTA"
...

You can see that the agencyId in the references element has been remapped, but the situationIds list in the entry element has not.

@cagryInside Could you please take a look and submit another PR fixing this? Thanks!

@barbeau barbeau reopened this Jan 28, 2015
@barbeau
Copy link
Member Author

barbeau commented Feb 9, 2015

Looks like the above was a data-sources.xml config issue (there was still a reference to <property name="agencyId" value="1" />). After this was changed to PSTA, everything looks good. So, this issue is fixed.

@barbeau barbeau closed this as completed Feb 9, 2015
sheldonabrown added a commit that referenced this issue Jan 1, 2024
…ill-show-trips-that-are-in-the-past

added ArrivalAndDepartureFilterByPredictedArrivalTime to filter the b…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants