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

Frequency based trips #828

Merged
merged 32 commits into from
Nov 2, 2016
Merged

Frequency based trips #828

merged 32 commits into from
Nov 2, 2016

Conversation

irees
Copy link
Member

@irees irees commented Oct 17, 2016

Resolves #408

@irees
Copy link
Member Author

irees commented Oct 20, 2016

Example SSPs for 1 trip:

The differences are:

  1. frequency_start_time, frequency_end_time, and frequency_headway_seconds. These operate the same as start_time, end_time, and headway_secs in the GTFS spec.
  2. Trip ID modified to be pseudo-unique by including frequency start/end/headway... This is just a concept and may change; it's to handle situations where a trip has multiple entries in frequencies.txt
{
    "schedule_stop_pairs": [{
        "origin_onestop_id": "s-9qsfp2212t-stagecoachhotel~casinodemo",
        "destination_onestop_id": "s-9qsfp00vhs-northave~naavedemo",
        "route_onestop_id": "r-9qsczp-40",
        "route_stop_pattern_onestop_id": "r-9qsczp-40-1f22a1-3d01d2",
        "operator_onestop_id": "o-123-dta",
        "feed_onestop_id": "f-123-debug",
        "feed_version_sha1": "2a7503435dcedeec8e61c2e705f6098e560e6bc6",
        "origin_timezone": "America/Los_Angeles",
        "destination_timezone": "America/Los_Angeles",
        "trip": "CITY1-6:00:00-7:59:59-1800",
        "trip_headsign": "E Main St / S Irving St (Demo)",
        "block_id": null,
        "trip_short_name": null,
        "wheelchair_accessible": null,
        "bikes_allowed": null,
        "pickup_type": null,
        "drop_off_type": null,
        "shape_dist_traveled": 0.0,
        "origin_arrival_time": "06:00:00",
        "origin_departure_time": "06:00:00",
        "destination_arrival_time": "06:05:00",
        "destination_departure_time": "06:07:00",
        "origin_dist_traveled": 0.0,
        "destination_dist_traveled": 875.4,
        "service_start_date": "2007-01-01",
        "service_end_date": "2010-12-31",
        "service_added_dates": [],
        "service_except_dates": ["2007-06-04"],
        "service_days_of_week": [true, true, true, true, true, true, true],
        "window_start": "06:00:00",
        "window_end": "06:05:00",
        "origin_timepoint_source": "gtfs_exact",
        "destination_timepoint_source": "gtfs_exact",
        "frequency_start_time": "6:00:00",
        "frequency_end_time": "7:59:59",
        "frequency_headway_seconds": 1800,
        "created_at": "2016-10-20T23:28:22.693Z",
        "updated_at": "2016-10-20T23:28:22.693Z"
    }, {
        "origin_onestop_id": "s-9qsfp00vhs-northave~naavedemo",
        "destination_onestop_id": "s-9qsfnb5uz6-northave~davendemo",
        "route_onestop_id": "r-9qsczp-40",
        "route_stop_pattern_onestop_id": "r-9qsczp-40-1f22a1-3d01d2",
        "operator_onestop_id": "o-123-dta",
        "feed_onestop_id": "f-123-debug",
        "feed_version_sha1": "2a7503435dcedeec8e61c2e705f6098e560e6bc6",
        "origin_timezone": "America/Los_Angeles",
        "destination_timezone": "America/Los_Angeles",
        "trip": "CITY1-6:00:00-7:59:59-1800",
        "trip_headsign": "E Main St / S Irving St (Demo)",
        "block_id": null,
        "trip_short_name": null,
        "wheelchair_accessible": null,
        "bikes_allowed": null,
        "pickup_type": null,
        "drop_off_type": null,
        "shape_dist_traveled": 0.0,
        "origin_arrival_time": "06:05:00",
        "origin_departure_time": "06:07:00",
        "destination_arrival_time": "06:12:00",
        "destination_departure_time": "06:14:00",
        "origin_dist_traveled": 875.4,
        "destination_dist_traveled": 1475.1,
        "service_start_date": "2007-01-01",
        "service_end_date": "2010-12-31",
        "service_added_dates": [],
        "service_except_dates": ["2007-06-04"],
        "service_days_of_week": [true, true, true, true, true, true, true],
        "window_start": "06:07:00",
        "window_end": "06:12:00",
        "origin_timepoint_source": "gtfs_exact",
        "destination_timepoint_source": "gtfs_exact",
        "frequency_start_time": "6:00:00",
        "frequency_end_time": "7:59:59",
        "frequency_headway_seconds": 1800,
        "created_at": "2016-10-20T23:28:22.693Z",
        "updated_at": "2016-10-20T23:28:22.693Z"
    }, {
        "origin_onestop_id": "s-9qsfnb5uz6-northave~davendemo",
        "destination_onestop_id": "s-9qscyz5vqg-doingave~davendemo",
        "route_onestop_id": "r-9qsczp-40",
        "route_stop_pattern_onestop_id": "r-9qsczp-40-1f22a1-3d01d2",
        "operator_onestop_id": "o-123-dta",
        "feed_onestop_id": "f-123-debug",
        "feed_version_sha1": "2a7503435dcedeec8e61c2e705f6098e560e6bc6",
        "origin_timezone": "America/Los_Angeles",
        "destination_timezone": "America/Los_Angeles",
        "trip": "CITY1-6:00:00-7:59:59-1800",
        "trip_headsign": "E Main St / S Irving St (Demo)",
        "block_id": null,
        "trip_short_name": null,
        "wheelchair_accessible": null,
        "bikes_allowed": null,
        "pickup_type": null,
        "drop_off_type": null,
        "shape_dist_traveled": 0.0,
        "origin_arrival_time": "06:12:00",
        "origin_departure_time": "06:14:00",
        "destination_arrival_time": "06:19:00",
        "destination_departure_time": "06:21:00",
        "origin_dist_traveled": 1475.1,
        "destination_dist_traveled": 2076.3,
        "service_start_date": "2007-01-01",
        "service_end_date": "2010-12-31",
        "service_added_dates": [],
        "service_except_dates": ["2007-06-04"],
        "service_days_of_week": [true, true, true, true, true, true, true],
        "window_start": "06:14:00",
        "window_end": "06:19:00",
        "origin_timepoint_source": "gtfs_exact",
        "destination_timepoint_source": "gtfs_exact",
        "frequency_start_time": "6:00:00",
        "frequency_end_time": "7:59:59",
        "frequency_headway_seconds": 1800,
        "created_at": "2016-10-20T23:28:22.693Z",
        "updated_at": "2016-10-20T23:28:22.693Z"
    }, {
        "origin_onestop_id": "s-9qscyz5vqg-doingave~davendemo",
        "destination_onestop_id": "s-9qsczn2rk0-emainst~sirvingstdemo",
        "route_onestop_id": "r-9qsczp-40",
        "route_stop_pattern_onestop_id": "r-9qsczp-40-1f22a1-3d01d2",
        "operator_onestop_id": "o-123-dta",
        "feed_onestop_id": "f-123-debug",
        "feed_version_sha1": "2a7503435dcedeec8e61c2e705f6098e560e6bc6",
        "origin_timezone": "America/Los_Angeles",
        "destination_timezone": "America/Los_Angeles",
        "trip": "CITY1-6:00:00-7:59:59-1800",
        "trip_headsign": "E Main St / S Irving St (Demo)",
        "block_id": null,
        "trip_short_name": null,
        "wheelchair_accessible": null,
        "bikes_allowed": null,
        "pickup_type": null,
        "drop_off_type": null,
        "shape_dist_traveled": 0.0,
        "origin_arrival_time": "06:19:00",
        "origin_departure_time": "06:21:00",
        "destination_arrival_time": "06:26:00",
        "destination_departure_time": "06:28:00",
        "origin_dist_traveled": 2076.3,
        "destination_dist_traveled": 2761.1,
        "service_start_date": "2007-01-01",
        "service_end_date": "2010-12-31",
        "service_added_dates": [],
        "service_except_dates": ["2007-06-04"],
        "service_days_of_week": [true, true, true, true, true, true, true],
        "window_start": "06:21:00",
        "window_end": "06:26:00",
        "origin_timepoint_source": "gtfs_exact",
        "destination_timepoint_source": "gtfs_exact",
        "frequency_start_time": "6:00:00",
        "frequency_end_time": "7:59:59",
        "frequency_headway_seconds": 1800,
        "created_at": "2016-10-20T23:28:22.693Z",
        "updated_at": "2016-10-20T23:28:22.693Z"
    }],
    "meta": {
        "sort_key": "id",
        "sort_order": "asc",
        "offset": 0,
        "per_page": 50
    }
}

@drewda
Copy link
Member

drewda commented Oct 21, 2016

@irees, frequency time attributes look good to me. @gknisely and @dnesbitt61?

Re trip ID, can we keep it as is for the time being? It won't necessarily be unique when crossed with origin, destination, and frequency attributes--but it will still allow filtering by GTFS trip ID. Separate from this PR, definitely worth thinking of how to add another ID/hash that can identify "trips" in a more unique and stable manner (#713). I can imagine how that will get even more interesting when considering "trips" as defined singly vs. defined by a frequency pattern.

@irees
Copy link
Member Author

irees commented Oct 26, 2016

@drewda Ok -- the trip_id is now handled as before.

@irees
Copy link
Member Author

irees commented Oct 26, 2016

SSP types:

  • single
  • frequency_exact_times
  • frequency_inexact_times

Enforce presence of frequency_start_time, frequency_end_time, frequency_headway_secs when ssp_type is frequency_exact_times, frequency_inexact_times

@irees
Copy link
Member Author

irees commented Oct 29, 2016

Updated response for a single SSP.

Changes: frequency_type which can be 'window', 'exact', or null. Trip ID is not manipulated; there can be multiple trips with the same value but different frequency values.

{
    "schedule_stop_pairs": [{
        "origin_onestop_id": "s-9qsfp2212t-stagecoachhotel~casinodemo",
        "destination_onestop_id": "s-9qsfp00vhs-northave~naavedemo",
        "route_onestop_id": "r-9qsczp-40",
        "route_stop_pattern_onestop_id": "r-9qsczp-40-1f22a1-3d01d2",
        "operator_onestop_id": "o-123-dta",
        "feed_onestop_id": "f-123-debug",
        "feed_version_sha1": "2a7503435dcedeec8e61c2e705f6098e560e6bc6",
        "origin_timezone": "America/Los_Angeles",
        "destination_timezone": "America/Los_Angeles",
        "trip": "CITY1",
        "trip_headsign": "E Main St / S Irving St (Demo)",
        "block_id": null,
        "trip_short_name": null,
        "wheelchair_accessible": null,
        "bikes_allowed": null,
        "pickup_type": null,
        "drop_off_type": null,
        "shape_dist_traveled": 0.0,
        "origin_arrival_time": "06:00:00",
        "origin_departure_time": "06:00:00",
        "destination_arrival_time": "06:05:00",
        "destination_departure_time": "06:07:00",
        "origin_dist_traveled": 0.0,
        "destination_dist_traveled": 875.4,
        "service_start_date": "2007-01-01",
        "service_end_date": "2010-12-31",
        "service_added_dates": [],
        "service_except_dates": ["2007-06-04"],
        "service_days_of_week": [true, true, true, true, true, true, true],
        "window_start": "06:00:00",
        "window_end": "06:05:00",
        "origin_timepoint_source": "gtfs_exact",
        "destination_timepoint_source": "gtfs_exact",
        "frequency_start_time": "6:00:00",
        "frequency_end_time": "7:59:59",
        "frequency_headway_seconds": 1800,
        "frequency_type": "window",
        "created_at": "2016-10-29T00:58:19.978Z",
        "updated_at": "2016-10-29T00:58:19.978Z"
    }],
    "meta": {
        "sort_key": "id",
        "sort_order": "asc",
        "offset": 0,
        "per_page": 1,
        "next": "http://localhost:3000/api/v1/schedule_stop_pairs?offset=1&per_page=1&sort_key=id&sort_order=asc&trip=CITY1"
    }
}

@irees irees changed the title [WIP] Frequency based trips Frequency based trips Oct 29, 2016
@drewda
Copy link
Member

drewda commented Oct 31, 2016

@irees a few quick questions:

  • The combination of "frequency_type": "window" and window_start/window_end could be confusing. The "window" of interpolated times and the "window" of a frequency-based schedule are not necessarily the same times, right? Is there another term for the enum that is less overloaded?
  • Can you add validation in both the JSON schema and in the ActiveRecord model to ensure that SSP's with a frequency_type also have the right set of other attributes set?

@irees
Copy link
Member Author

irees commented Nov 1, 2016

@drewda I'll use another term for frequency_type: window and see about adding that validation to the JSON schema & active record validator.

@irees irees mentioned this pull request Nov 2, 2016
8 tasks
@irees irees merged commit 814161f into master Nov 2, 2016
@irees irees deleted the ssp-frequency-import branch November 2, 2016 22:45
@irees irees removed the in progress label Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants