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

SSP accessibility labels #209

Merged
merged 8 commits into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/models/json_schemas/schedule_stop_pair.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
"frequencyStartTime": { "type": ["string","null"] },
"frequencyEndTime": { "type": ["string","null"] },
"frequencyHeadwaySeconds": { "type": ["string","null"] },
"wheelchairAccessible": { "type": ["integer","null"] },
"bikesAllowed": { "type": ["integer","null"] },
"pickupType": { "type": ["integer","null"] },
"dropOffType": { "type": ["integer","null"] },
"wheelchairAccessible": { "type": ["boolean","null"] },
"bikesAllowed": { "type": ["boolean","null"] },
"pickupType": { "type": ["string","null"] },
"dropOffType": { "type": ["string","null"] },
"shapeDistTraveled": { "type": ["number","null"] },
"tags": { "type": "object" },
"importedFromFeed": {
Expand Down
8 changes: 4 additions & 4 deletions app/models/schedule_stop_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
# updated_at :datetime not null
# block_id :string
# trip_short_name :string
# wheelchair_accessible :integer
# bikes_allowed :integer
# pickup_type :integer
# drop_off_type :integer
# shape_dist_traveled :float
# origin_timezone :string
# destination_timezone :string
Expand All @@ -39,6 +35,10 @@
# origin_timepoint_source :string
# destination_timepoint_source :string
# operator_id :integer
# wheelchair_accessible :boolean
# bikes_allowed :boolean
# pickup_type :string
# drop_off_type :string
#
# Indexes
#
Expand Down
8 changes: 4 additions & 4 deletions app/serializers/schedule_stop_pair_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
# updated_at :datetime not null
# block_id :string
# trip_short_name :string
# wheelchair_accessible :integer
# bikes_allowed :integer
# pickup_type :integer
# drop_off_type :integer
# shape_dist_traveled :float
# origin_timezone :string
# destination_timezone :string
Expand All @@ -39,6 +35,10 @@
# origin_timepoint_source :string
# destination_timepoint_source :string
# operator_id :integer
# wheelchair_accessible :boolean
# bikes_allowed :boolean
# pickup_type :string
# drop_off_type :string
#
# Indexes
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class ChangeSspAccessibilityFromIntegers < ActiveRecord::Migration
def change
["current","old"].each do |version|
remove_column "#{version}_schedule_stop_pairs", :wheelchair_accessible, :integer
remove_column "#{version}_schedule_stop_pairs", :bikes_allowed, :integer
remove_column "#{version}_schedule_stop_pairs", :pickup_type, :integer
remove_column "#{version}_schedule_stop_pairs", :drop_off_type, :integer
add_column "#{version}_schedule_stop_pairs", :wheelchair_accessible, :boolean
add_column "#{version}_schedule_stop_pairs", :bikes_allowed, :boolean
add_column "#{version}_schedule_stop_pairs", :pickup_type, :string
add_column "#{version}_schedule_stop_pairs", :drop_off_type, :string
end
end
end
18 changes: 9 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20151027003112) do
ActiveRecord::Schema.define(version: 20151029001514) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -168,10 +168,6 @@
t.datetime "updated_at", null: false
t.string "block_id"
t.string "trip_short_name"
t.integer "wheelchair_accessible"
t.integer "bikes_allowed"
t.integer "pickup_type"
t.integer "drop_off_type"
t.float "shape_dist_traveled"
t.string "origin_timezone"
t.string "destination_timezone"
Expand All @@ -180,6 +176,10 @@
t.string "origin_timepoint_source"
t.string "destination_timepoint_source"
t.integer "operator_id"
t.boolean "wheelchair_accessible"
t.boolean "bikes_allowed"
t.string "pickup_type"
t.string "drop_off_type"
end

add_index "current_schedule_stop_pairs", ["created_or_updated_in_changeset_id"], name: "c_ssp_cu_in_changeset", using: :btree
Expand Down Expand Up @@ -428,10 +428,6 @@
t.datetime "updated_at", null: false
t.string "block_id"
t.string "trip_short_name"
t.integer "wheelchair_accessible"
t.integer "bikes_allowed"
t.integer "pickup_type"
t.integer "drop_off_type"
t.float "shape_dist_traveled"
t.string "origin_timezone"
t.string "destination_timezone"
Expand All @@ -440,6 +436,10 @@
t.string "origin_timepoint_source"
t.string "destination_timepoint_source"
t.integer "operator_id"
t.boolean "wheelchair_accessible"
t.boolean "bikes_allowed"
t.string "pickup_type"
t.string "drop_off_type"
end

add_index "old_schedule_stop_pairs", ["created_or_updated_in_changeset_id"], name: "o_ssp_cu_in_changeset", using: :btree
Expand Down
39 changes: 32 additions & 7 deletions lib/gtfsgraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def make_change_ssp(entity)
tripHeadsign: entity.trip_headsign,
tripShortName: entity.trip_short_name,
wheelchairAccessible: entity.wheelchair_accessible,
bikesAllowed: entity.bikes_allowed,
dropOffType: entity.drop_off_type,
pickupType: entity.pickup_type,
shapeDistTraveled: entity.shape_dist_traveled,
Expand Down Expand Up @@ -410,12 +411,12 @@ def make_ssp(route, trip, origin, destination)
trip: trip.id.presence,
trip_headsign: (origin.stop_headsign || trip.trip_headsign).presence,
trip_short_name: trip.trip_short_name.presence,
wheelchair_accessible: trip.wheelchair_accessible.to_i,
bikes_allowed: trip.bikes_allowed.to_i,
# Stop Time
drop_off_type: origin.drop_off_type.to_i,
pickup_type: origin.pickup_type.to_i,
shape_dist_traveled: origin.shape_dist_traveled.to_f,
shape_dist_traveled: destination.shape_dist_traveled.to_f,
# Accessibility
pickup_type: to_pickup_type(origin.pickup_type),
drop_off_type: to_pickup_type(destination.drop_off_type),
wheelchair_accessible: to_tfn(trip.wheelchair_accessible),
bikes_allowed: to_tfn(trip.bikes_allowed),
# service period
service_start_date: service_period.start_date,
service_end_date: service_period.end_date,
Expand All @@ -424,10 +425,34 @@ def make_ssp(route, trip, origin, destination)
service_except_dates: service_period.except_dates
)
end

def to_tfn(value)
case value.to_i
when 0
nil
when 1
true
when 2
false
end
end

def to_pickup_type(value)
case value.to_i
when 0
nil
when 1
:unavailable
when 2
:ask_agency
when 3
:ask_driver
end
end
end

if __FILE__ == $0
# ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.logger = Logger.new(STDOUT)
feed_onestop_id = ARGV[0] || 'f-9q9-caltrain'
import_level = (ARGV[1] || 1).to_i
feed = Feed.find_by!(onestop_id: feed_onestop_id)
Expand Down
8 changes: 4 additions & 4 deletions spec/factories/schedule_stop_pair_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
# updated_at :datetime not null
# block_id :string
# trip_short_name :string
# wheelchair_accessible :integer
# bikes_allowed :integer
# pickup_type :integer
# drop_off_type :integer
# shape_dist_traveled :float
# origin_timezone :string
# destination_timezone :string
Expand All @@ -39,6 +35,10 @@
# origin_timepoint_source :string
# destination_timepoint_source :string
# operator_id :integer
# wheelchair_accessible :boolean
# bikes_allowed :boolean
# pickup_type :string
# drop_off_type :string
#
# Indexes
#
Expand Down
8 changes: 4 additions & 4 deletions spec/models/schedule_stop_pair_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
# updated_at :datetime not null
# block_id :string
# trip_short_name :string
# wheelchair_accessible :integer
# bikes_allowed :integer
# pickup_type :integer
# drop_off_type :integer
# shape_dist_traveled :float
# origin_timezone :string
# destination_timezone :string
Expand All @@ -39,6 +35,10 @@
# origin_timepoint_source :string
# destination_timepoint_source :string
# operator_id :integer
# wheelchair_accessible :boolean
# bikes_allowed :boolean
# pickup_type :string
# drop_off_type :string
#
# Indexes
#
Expand Down
7 changes: 4 additions & 3 deletions spec/services/gtfsgraph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ def load_feed(import_level=1)
expect(s.destination_timezone).to eq('America/Los_Angeles')
expect(s.shape_dist_traveled).to eq(0.0)
expect(s.block_id).to be_nil
expect(s.wheelchair_accessible).to eq(0)
expect(s.pickup_type).to eq(0)
expect(s.drop_off_type).to eq(0)
expect(s.wheelchair_accessible).to eq(nil)
expect(s.bikes_allowed).to eq(nil)
expect(s.pickup_type).to eq(nil)
expect(s.drop_off_type).to eq(nil)
expect(s.origin_arrival_time).to eq('08:15:00')
expect(s.origin_departure_time).to eq('08:15:00')
expect(s.destination_arrival_time).to eq('08:20:00')
Expand Down