gtfs-orm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +127 -0
- data/Rakefile +6 -0
- data/data/agency.txt +7 -0
- data/data/calendar.txt +39 -0
- data/data/feed_info.txt +2 -0
- data/data/frequencies.txt +1562 -0
- data/data/org_onebusaway_transit_data.log +23 -0
- data/data/org_onebusaway_transit_data.properties +4 -0
- data/data/org_onebusaway_transit_data.script +73 -0
- data/data/routes.txt +131 -0
- data/data/shapes.txt +21244 -0
- data/data/stop_times.txt +63700 -0
- data/data/stops.txt +5244 -0
- data/data/transfers.txt +49 -0
- data/data/trips.txt +1562 -0
- data/gtfs-orm.gemspec +33 -0
- data/lib/gtfs/orm/agency.rb +21 -0
- data/lib/gtfs/orm/calendar.rb +24 -0
- data/lib/gtfs/orm/calendar_date.rb +17 -0
- data/lib/gtfs/orm/fare_attribute.rb +20 -0
- data/lib/gtfs/orm/fare_rule.rb +19 -0
- data/lib/gtfs/orm/feed_info.rb +20 -0
- data/lib/gtfs/orm/frequency.rb +19 -0
- data/lib/gtfs/orm/resource.rb +142 -0
- data/lib/gtfs/orm/route.rb +23 -0
- data/lib/gtfs/orm/shape.rb +19 -0
- data/lib/gtfs/orm/stop.rb +26 -0
- data/lib/gtfs/orm/stop_time.rb +23 -0
- data/lib/gtfs/orm/transfer.rb +18 -0
- data/lib/gtfs/orm/trip.rb +23 -0
- data/lib/gtfs/orm/version.rb +5 -0
- data/lib/gtfs/orm.rb +43 -0
- data/lib/gtfs.rb +4 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e63f6e93c78b77729d1296205fc3c02608a8cbc6
|
4
|
+
data.tar.gz: e9856239ecc42a72a3aa9ead7a3855b276641134
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dcbc26ccf2c2ff224b1e311e2505e6f39508686523f9b1da6865016b98322f62e3b6f09d3e1dc19821fa7e86b4574c08f76365649ed20cadd782f664ce7125d8
|
7
|
+
data.tar.gz: 6043e7a88820c2371a36357cb4c12ed798b6f6bed83f8be37053737bf1ca0e7858acdb46055117e5b9489698a087313309f5e40e68254ff014c503dc5c45da23
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ryan Closner
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
gtfs-osm
|
2
|
+
========
|
3
|
+
|
4
|
+
## About
|
5
|
+
|
6
|
+
gtfs-orm is a Ruby Object Mapper for the Google Transit Feed Specification
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem "gtfs-orm", require: "gtfs/orm"
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
```
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
```
|
25
|
+
$ gem install gtfs
|
26
|
+
```
|
27
|
+
|
28
|
+
## Resources
|
29
|
+
|
30
|
+
GTFS ORM provides Ruby Object Mappings for the General Transit Feed Specification. Each file within a GTFS feed is treated as a model. As of the [current revision](https://developers.google.com/transit/gtfs/reference) of the GTFS spec published on June 20, 2012 the following resources are provided:
|
31
|
+
|
32
|
+
* Agency
|
33
|
+
* Stop
|
34
|
+
* Route
|
35
|
+
* Trip
|
36
|
+
* StopTime
|
37
|
+
* Calendar
|
38
|
+
* CalendarDates
|
39
|
+
* FareAttribute
|
40
|
+
* FareRule
|
41
|
+
* Shape
|
42
|
+
* Frequency
|
43
|
+
* Transfer
|
44
|
+
* FeedInfo
|
45
|
+
|
46
|
+
## API
|
47
|
+
|
48
|
+
The Resource API was designed to mirror that of ActiveRecord. Common methods for returning and scoping a Collection (or returning a single Resource) will be familiar to users or Rails, and are implemented as follows:
|
49
|
+
|
50
|
+
* Resource#first (returns the first instance of the collection)
|
51
|
+
* Resource#last (returns the last instance of the collection)
|
52
|
+
* Resource#all (returns the collection)
|
53
|
+
* Resource#where (scopes the collection to resources where the specified conditions apply)
|
54
|
+
* Resource#limit (limits the number of resources returned)
|
55
|
+
* Resource#page (returns the next group of resources specified by limit)
|
56
|
+
|
57
|
+
## API Examples
|
58
|
+
|
59
|
+
The Resource `GTFS::ORM::Agency` will be used for the following examples:
|
60
|
+
|
61
|
+
Resource#first:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
GTFS::ORM::Agency.first
|
65
|
+
#=> #<GTFS::ORM::Agency:0x007f8d428f0418>
|
66
|
+
```
|
67
|
+
|
68
|
+
Resource#last
|
69
|
+
```ruby
|
70
|
+
GTFS::ORM::Agency.last
|
71
|
+
#=> #<GTFS::ORM::Agency:0x007f8d428f0418>
|
72
|
+
```
|
73
|
+
|
74
|
+
Resource#all
|
75
|
+
```ruby
|
76
|
+
GTFS::ORM::Agency.all
|
77
|
+
#=> [ #<GTFS::ORM::Agency:0x007f8d428f0418>, #<GTFS::ORM::Agency:0x006d8d4281fas98>... ]
|
78
|
+
```
|
79
|
+
|
80
|
+
Note: Collections are limited by default to return 20 resources at a time. The default limit can be modified by using the `limit` method.
|
81
|
+
|
82
|
+
Resource#where
|
83
|
+
```ruby
|
84
|
+
scope = GTFS::ORM::Agency.where(agency_id: 'METRO')
|
85
|
+
#=> #<GTFS::ORM::Resource::Scope:0x007f8d42932098>
|
86
|
+
scope.all
|
87
|
+
#=> [ #<GTFS::ORM::Agency:0x007f8d428f0418>, #<GTFS::ORM::Agency:0x006d8d4281fas98>... ]
|
88
|
+
```
|
89
|
+
|
90
|
+
Resource#limit
|
91
|
+
```ruby
|
92
|
+
scope = GTFS::ORM::Agency.limit(2)
|
93
|
+
#=> #<GTFS::ORM::Resource::Scope:0x007f8d42932098>
|
94
|
+
scope.all
|
95
|
+
#=> [ #<GTFS::ORM::Agency:0x007f8d428f0418>, #<GTFS::ORM::Agency:0x006d8d4281fas98> ]
|
96
|
+
```
|
97
|
+
|
98
|
+
Resource#page
|
99
|
+
```ruby
|
100
|
+
scope = GTFS::ORM::Agency.page(2)
|
101
|
+
#=> #<GTFS::ORM::Resource::Scope:0x007f8d42932098>
|
102
|
+
scope.all
|
103
|
+
#=> [ #<GTFS::ORM::Agency:0x007f8d428f0418>, #<GTFS::ORM::Agency:0x006d8d4281fas98> ]
|
104
|
+
```
|
105
|
+
|
106
|
+
## Usage
|
107
|
+
|
108
|
+
GTFS ORM relies upon the existence of an uncompressed GTFS dir. In order to specify the path, the following configuration must be run before attempting to access any Resources.
|
109
|
+
|
110
|
+
```
|
111
|
+
GTFS.path('/path/to/uncompressed/gtfs/dir')
|
112
|
+
```
|
113
|
+
|
114
|
+
Once the path has been specified, Resources can be accessed in the following manner.
|
115
|
+
|
116
|
+
```
|
117
|
+
GTFS::ORM::Route.limit(30).page(2).where(route_long_name: "Indios Verdes - Dr. Gálvez").all
|
118
|
+
#=> [ #<GTFS::ORM::Route:0x007f8d429f0f70>, #<GTFS::ORM::Route:0x006d8d429f0f70>...]
|
119
|
+
```
|
120
|
+
|
121
|
+
## Contributing
|
122
|
+
|
123
|
+
1. Fork it ( http://github.com/<my-github-username>/gtfs/fork )
|
124
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
125
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
126
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
127
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/data/agency.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone
|
2
|
+
CC,ci-sa/corevsa NOCHEbus,http://www.ci-sa.com.mx/,America/Mexico_City,,
|
3
|
+
MB,Metrobús,http://www.metrobus.df.gob.mx/,America/Mexico_City,,
|
4
|
+
METRO,Sistema de Transporte Colectivo-Metro,http://www.metro.df.gob.mx/,America/Mexico_City,,
|
5
|
+
RTP,Red de Transporte de Pasajeros,http://www.rtp.gob.mx/,America/Mexico_City,,
|
6
|
+
STE,Servicio de Transportes Eléctricos,http://www.ste.df.gob.mx/,America/Mexico_City,,
|
7
|
+
SUB,Ferrocarriles Suburbanos,http://www.fsuburbanos.com/,America/Mexico_City,,
|
data/data/calendar.txt
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
|
2
|
+
36238,1,1,1,1,1,0,0,20131221,20140323
|
3
|
+
38253,1,1,1,1,1,1,1,20131221,20140323
|
4
|
+
38742,1,1,1,1,1,0,0,20131221,20140323
|
5
|
+
38754,1,1,1,1,1,0,0,20131221,20140323
|
6
|
+
38824,0,0,0,0,0,1,0,20131221,20140323
|
7
|
+
38827,0,0,0,0,0,0,1,20131221,20140323
|
8
|
+
38832,0,0,0,0,0,1,0,20131221,20140323
|
9
|
+
38835,0,0,0,0,0,0,1,20131221,20140323
|
10
|
+
38881,1,1,1,1,1,0,0,20131221,20140323
|
11
|
+
36479,1,1,1,1,1,0,0,20131221,20140323
|
12
|
+
38501,0,0,0,0,0,1,0,20131221,20140323
|
13
|
+
38504,0,0,0,0,0,0,1,20131221,20140323
|
14
|
+
40064,1,1,1,1,1,0,0,20131221,20140323
|
15
|
+
40074,1,1,1,1,1,1,1,20131221,20140323
|
16
|
+
16233,0,0,0,0,0,0,1,20131221,20140323
|
17
|
+
16092,1,1,1,1,1,0,0,20131221,20140323
|
18
|
+
36489,0,0,0,0,0,1,0,20131221,20140323
|
19
|
+
39389,0,0,0,0,0,0,1,20131221,20140323
|
20
|
+
38274,1,1,1,1,1,1,1,20131221,20140323
|
21
|
+
40622,1,1,1,1,1,1,1,20131221,20140323
|
22
|
+
40450,1,1,1,1,0,0,0,20131221,20140323
|
23
|
+
26949,0,0,0,0,0,0,1,20131221,20140323
|
24
|
+
26656,1,1,1,1,1,0,0,20131221,20140323
|
25
|
+
14741,1,1,1,1,1,0,0,20131221,20140323
|
26
|
+
36384,0,0,0,0,0,1,0,20131221,20140323
|
27
|
+
28960,0,0,0,0,0,0,1,20131221,20140323
|
28
|
+
16203,0,0,0,0,0,1,0,20131221,20140323
|
29
|
+
41883,0,0,0,0,1,1,0,20131221,20140323
|
30
|
+
41882,1,1,1,1,0,0,0,20131221,20140323
|
31
|
+
41987,1,1,1,0,0,0,0,20131221,20140323
|
32
|
+
41886,0,0,0,0,0,0,1,20131221,20140323
|
33
|
+
41996,0,0,0,0,1,1,0,20131221,20140323
|
34
|
+
41998,0,0,0,0,0,0,1,20131221,20140323
|
35
|
+
41989,0,0,0,1,0,0,0,20131221,20140323
|
36
|
+
41994,0,0,0,1,0,0,0,20131221,20140323
|
37
|
+
42138,0,0,0,0,1,1,0,20131221,20140323
|
38
|
+
42083,0,0,0,0,1,0,0,20131221,20140323
|
39
|
+
42085,0,0,0,0,0,1,0,20131221,20140323
|
data/data/feed_info.txt
ADDED