MCPcopy Create free account
hub / github.com/comaps/comaps / GetTimeTableFromJson

Function GetTimeTableFromJson

libs/transit/experimental/transit_data.cpp:176–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176TimeTable GetTimeTableFromJson(json_t * obj)
177{
178 json_t * arr = base::GetJSONOptionalField(obj, "timetable");
179 if (!arr)
180 return TimeTable{};
181
182 CHECK(json_is_array(arr), ());
183
184 TimeTable timetable;
185
186 for (size_t i = 0; i < json_array_size(arr); ++i)
187 {
188 json_t * item = json_array_get(arr, i);
189 CHECK(json_is_object(item), ());
190
191 TransitId lineId;
192 FromJSONObject(item, "line_id", lineId);
193
194 std::vector<TimeInterval> timeIntervals;
195
196 auto const & rawValues = GetVectorFromJson<uint64_t>(item, "intervals");
197 timeIntervals.reserve(rawValues.size());
198 for (auto const & rawValue : rawValues)
199 timeIntervals.push_back(TimeInterval(rawValue));
200
201 timetable[lineId] = timeIntervals;
202 }
203
204 return timetable;
205}
206
207Translations GetTranslationsFromJson(json_t * obj, std::string const & field)
208{

Callers 1

ReadFunction · 0.85

Calls 6

GetJSONOptionalFieldFunction · 0.85
TimeIntervalClass · 0.85
FromJSONObjectFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected