Пример #1
0
func createServiceFromCalendarDates(r map[string]string, services map[string]*gtfs.Service) *gtfs.Service {
	update := false
	var service *gtfs.Service

	// first, check if the service already exists
	if val, ok := services[getString("service_id", r, true)]; ok {
		service = val
		update = true
	} else {
		service = new(gtfs.Service)
		service.Id = getString("service_id", r, true)
	}

	// create exception
	exc := new(gtfs.ServiceException)
	var t int
	t = getInt("exception_type", r, true)
	exc.Type = int8(t)
	exc.Date = getDate("date", r, true)

	service.Exceptions = append(service.Exceptions, exc)

	if update {
		return nil
	} else {
		return service
	}
}
Пример #2
0
func createServiceFromCalendar(r map[string]string, services map[string]*gtfs.Service) *gtfs.Service {
	service := new(gtfs.Service)
	service.Id = getString("service_id", r, true)

	// fill daybitmap
	service.Daymap[1] = getBool("monday", r, true)
	service.Daymap[2] = getBool("tuesday", r, true)
	service.Daymap[3] = getBool("wednesday", r, true)
	service.Daymap[4] = getBool("thursday", r, true)
	service.Daymap[5] = getBool("friday", r, true)
	service.Daymap[6] = getBool("saturday", r, true)
	service.Daymap[0] = getBool("sunday", r, true)
	service.Start_date = getDate("start_date", r, true)
	service.End_date = getDate("end_date", r, true)

	return service
}