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

Refactor GTFS #179

Merged
merged 10 commits into from
Sep 24, 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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'whenever', require: false # to manage crontab
# data model
gem 'squeel'
gem 'enumerize'
gem 'gtfs'
gem 'gtfs', github: 'transitland/gtfs', tag: 'v1.0.0rc1'
gem 'rgeo-geojson'
gem 'c_geohash', require: 'geohash'
gem 'json-schema'
Expand Down
18 changes: 12 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
GIT
remote: git://github.com/transitland/gtfs.git
revision: 21453060861b955ca63a06aec12fba34f677dfa3
tag: v1.0.0rc1
specs:
gtfs (0.2.5)
multi_json
rake
rubyzip (~> 1.1)

GIT
remote: git://github.com/transitland/transitland-ruby-client.git
revision: 3adc5991adcee9f41f862ebc30524ce204e42157
Expand All @@ -10,7 +20,7 @@ GIT
PATH
remote: components
specs:
datastore_admin (0.0.1)
datastore_admin (1.0.0rc2)
sinatra

GEM
Expand Down Expand Up @@ -128,10 +138,6 @@ GEM
git (1.2.9.1)
globalid (0.3.6)
activesupport (>= 4.1.0)
gtfs (0.2.4)
multi_json
rake
rubyzip (~> 1.1)
hashie (3.4.2)
hitimes (1.2.2)
http-cookie (1.0.2)
Expand Down Expand Up @@ -359,7 +365,7 @@ DEPENDENCIES
ffaker
figaro
foreman
gtfs
gtfs!
json-schema
mock_redis
oj
Expand Down
18 changes: 9 additions & 9 deletions app/models/operator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ def self.from_gtfs(entity, stops)
raise ArgumentError.new('Need at least one Stop') if stops.empty?
geohash = GeohashHelpers.fit(stops.map { |i| i[:geometry] })
geometry = Operator.convex_hull(stops, as: :wkt, projected: false)
name = [entity.name, entity.id, "unknown"]
name = [entity.agency_name, entity.id, "unknown"]
.select(&:present?)
.first
.first
onestop_id = OnestopId.new(
entity_prefix: 'o',
geohash: geohash,
entity_prefix: 'o',
geohash: geohash,
name: name
)
operator = Operator.new(
Expand All @@ -132,12 +132,12 @@ def self.from_gtfs(entity, stops)
operator[:geometry] = geometry
# Copy over GTFS attributes to tags
operator.tags ||= {}
operator.tags[:agency_phone] = entity.phone
operator.tags[:agency_lang] = entity.lang
operator.tags[:agency_fare_url] = entity.fare_url
operator.tags[:agency_phone] = entity.agency_phone
operator.tags[:agency_lang] = entity.agency_lang
operator.tags[:agency_fare_url] = entity.agency_fare_url
operator.tags[:agency_id] = entity.id
operator.timezone = entity.timezone
operator.website = entity.url
operator.timezone = entity.agency_timezone
operator.website = entity.agency_url
operator
end

Expand Down
16 changes: 8 additions & 8 deletions app/models/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def self.from_gtfs(entity, stops)
# GTFS Constructor
raise ArgumentError.new('Need at least one Stop') if stops.empty?
geohash = GeohashHelpers.fit(stops.map { |i| i[:geometry] })
name = [entity.short_name, entity.long_name, entity.id, "unknown"]
name = [entity.route_short_name, entity.route_long_name, entity.id, "unknown"]
.select(&:present?)
.first
.first
onestop_id = OnestopId.new(
entity_prefix: 'r',
geohash: geohash,
Expand All @@ -144,12 +144,12 @@ def self.from_gtfs(entity, stops)
# Copy over GTFS attributes to tags
vehicles = ['tram', 'metro', 'rail', 'bus', 'ferry', 'cablecar', 'gondola', 'funicalar']
route.tags ||= {}
route.tags[:vehicle_type] = vehicles[entity.type.to_i]
route.tags[:route_long_name] = entity.long_name
route.tags[:route_desc] = entity.desc
route.tags[:route_url] = entity.url
route.tags[:route_color] = entity.color
route.tags[:route_text_color] = entity.text_color
route.tags[:vehicle_type] = vehicles[entity.route_type.to_i]
route.tags[:route_long_name] = entity.route_long_name
route.tags[:route_desc] = entity.route_desc
route.tags[:route_url] = entity.route_url
route.tags[:route_color] = entity.route_color
route.tags[:route_text_color] = entity.route_text_color
route
end

Expand Down
16 changes: 8 additions & 8 deletions app/models/stop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ def conflate_with_osm
include FromGTFS
def self.from_gtfs(entity)
# GTFS Constructor
point = Stop::GEOFACTORY.point(entity.lon, entity.lat)
point = Stop::GEOFACTORY.point(entity.stop_lon, entity.stop_lat)
geohash = GeohashHelpers.encode(point, precision=GEOHASH_PRECISION)
name = [entity.name, entity.id, "unknown"]
name = [entity.stop_name, entity.id, "unknown"]
.select(&:present?)
.first
.first
onestop_id = OnestopId.new(
entity_prefix: 's',
geohash: geohash,
entity_prefix: 's',
geohash: geohash,
name: name
)
stop = Stop.new(
Expand All @@ -242,10 +242,10 @@ def self.from_gtfs(entity)
# Copy over GTFS attributes to tags
stop.tags ||= {}
stop.tags[:wheelchair_boarding] = entity.wheelchair_boarding
stop.tags[:stop_desc] = entity.desc
stop.tags[:stop_url] = entity.url
stop.tags[:stop_desc] = entity.stop_desc
stop.tags[:stop_url] = entity.stop_url
stop.tags[:zone_id] = entity.zone_id
stop.timezone = entity.timezone
stop.timezone = entity.stop_timezone
stop
end

Expand Down
1 change: 0 additions & 1 deletion app/workers/feed_eater_feed_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def perform(feed_onestop_id, import_level=0)
graph = nil
begin
graph = GTFSGraph.new(feed.file_path, feed)
graph.load_gtfs
operators = graph.load_tl
graph.create_changeset operators, import_level
rescue Exception => e
Expand Down
22 changes: 0 additions & 22 deletions config/initializers/gtfs.rb

This file was deleted.

Loading