-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.go
164 lines (135 loc) · 3.1 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package model
import (
"encoding/json"
"github.com/interline-io/transitland-lib/dmfr"
"github.com/interline-io/transitland-lib/rt/pb"
"github.com/interline-io/transitland-lib/tl"
"github.com/interline-io/transitland-lib/tl/tt"
)
type Feed struct {
SearchRank *string
tl.Feed
}
type FeedLicense struct {
tl.FeedLicense
}
type FeedUrls struct {
tl.FeedUrls
}
type FeedAuthorization struct {
tl.FeedAuthorization
}
type Agency struct {
OnestopID string `json:"onestop_id"`
FeedOnestopID string `json:"feed_onestop_id"`
FeedVersionSHA1 string `json:"feed_version_sha1"`
Geometry *tl.Polygon `json:"geometry"`
SearchRank *string
CoifID *int
tl.Agency
}
type Calendar struct {
tl.Calendar
}
type FeedState struct {
dmfr.FeedState
}
type FeedFetch struct {
ResponseSha1 tl.String // confusing but easier than alternative fixes
dmfr.FeedFetch
}
type FeedVersion struct {
SHA1Dir tl.String `json:"sha1_dir"`
tl.FeedVersion
}
type Operator struct {
ID int
Generated bool
FeedID int
FeedOnestopID *string
SearchRank *string // internal
AgencyID int // internal
tl.Operator
}
type Route struct {
FeedOnestopID string
FeedVersionSHA1 string
OnestopID *string
HeadwaySecondsWeekdayMorning *int
SearchRank *string
tl.Route
}
type Trip struct {
RTTripID string // internal: for ADDED trips
tl.Trip
}
type StopTime struct {
ServiceDate tl.Date
RTTripID string // internal: for ADDED trips
RTStopTimeUpdate *pb.TripUpdate_StopTimeUpdate // internal
tl.StopTime
}
type Stop struct {
FeedOnestopID string
FeedVersionSHA1 string
OnestopID *string
SearchRank *string
tl.Stop
}
type Frequency struct {
tl.Frequency
}
type CalendarDate struct {
tl.CalendarDate
}
type Shape struct {
tl.Shape
}
type Level struct {
Geometry tl.Polygon
ParentStation tt.Key
tl.Level
}
type FeedInfo struct {
tl.FeedInfo
}
type Pathway struct {
tl.Pathway
}
type FeedVersionFileInfo struct {
dmfr.FeedVersionFileInfo
}
type FeedVersionGtfsImport struct {
WarningCount *json.RawMessage `json:"warning_count"`
EntityCount *json.RawMessage `json:"entity_count"`
SkipEntityErrorCount *json.RawMessage `json:"skip_entity_error_count"`
SkipEntityReferenceCount *json.RawMessage `json:"skip_entity_reference_count"`
SkipEntityFilterCount *json.RawMessage `json:"skip_entity_filter_count"`
SkipEntityMarkedCount *json.RawMessage `json:"skip_entity_marked_count"`
dmfr.FeedVersionImport
}
type FeedVersionServiceLevel struct {
dmfr.FeedVersionServiceLevel
}
// Some enum helpers
var specTypeMap = map[string]FeedSpecTypes{
"gtfs": FeedSpecTypesGtfs,
"gtfs-rt": FeedSpecTypesGtfsRt,
"gbfs": FeedSpecTypesGbfs,
"mds": FeedSpecTypesMds,
}
func (f FeedSpecTypes) ToDBString() string {
for k, v := range specTypeMap {
if f == v {
return k
}
}
return ""
}
func (f FeedSpecTypes) FromDBString(s string) *FeedSpecTypes {
a, ok := specTypeMap[s]
if !ok {
return nil
}
return &a
}