Пример #1
0
func createStopTime(r map[string]string, stops map[string]*gtfs.Stop, trips map[string]*gtfs.Trip) {
	a := new(gtfs.StopTime)
	var trip *gtfs.Trip

	if val, ok := trips[getString("trip_id", r, true)]; ok {
		trip = val
	} else {
		panic("No trip with id " + getString("trip_id", r, true) + " found.")
	}

	if val, ok := stops[getString("stop_id", r, true)]; ok {
		a.Stop = val
	} else {
		panic("No stop with id " + getString("stop_id", r, true) + " found.")
	}

	a.Arrival_time = getString("arrival_time", r, true)
	a.Departure_time = getString("departure_time", r, true)
	a.Sequence = getInt("stop_sequence", r, true)
	a.Headsign = getString("stop_headsign", r, false)
	a.Pickup_type = getInt("pickup_type", r, false)
	a.Drop_off_type = getInt("drop_off_type", r, false)
	a.Shape_dist_traveled = getFloat("shape_dist_traveled", r, false)
	a.Timepoint = getBool("Timepoint", r, false)

	trip.StopTimes = append(trip.StopTimes, a)

}
Пример #2
0
func createFrequency(r map[string]string, trips map[string]*gtfs.Trip) {
	a := new(gtfs.Frequency)
	var trip *gtfs.Trip

	tripid := getString("trip_id", r, true)

	if val, ok := trips[tripid]; ok {
		trip = val
	} else {
		panic("No trip with id " + r["trip_id"] + " found.")
	}

	a.Exact_times = getBool("exact_times", r, false)
	a.Start_time = getString("start_time", r, true)
	a.End_time = getString("end_time", r, true)
	a.Headway_secs = getInt("headway_secs", r, false)
	trip.Frequencies = append(trip.Frequencies, a)
}
Пример #3
0
func createTrip(r map[string]string, routes map[string]*gtfs.Route,
	services map[string]*gtfs.Service,
	shapes map[string]*gtfs.Shape) *gtfs.Trip {
	a := new(gtfs.Trip)
	a.Id = getString("trip_id", r, true)

	if val, ok := routes[getString("route_id", r, true)]; ok {
		a.Route = val
	} else {
		panic(fmt.Sprintf("No route with id %s found", getString("route_id", r, true)))
	}

	if val, ok := services[getString("service_id", r, true)]; ok {
		a.Service = val
	} else {
		panic(fmt.Sprintf("No service with id %s found", getString("service_id", r, true)))
	}

	a.Headsign = getString("trip_headsign", r, false)
	a.Short_name = getString("trip_short_name", r, false)
	a.Direction_id = getInt("direction_id", r, false)
	a.Block_id = getString("block_id", r, false)

	shapeId := getString("shape_id", r, false)

	if len(shapeId) > 0 {
		if val, ok := shapes[shapeId]; ok {
			a.Shape = val
		} else {
			panic(fmt.Sprintf("No shape with id %s found", shapeId))
		}
	}

	a.Wheelchair_accessible = getInt("wheelchair_accessible", r, false)
	a.Bikes_allowed = getInt("bikes_allowed", r, false)

	return a
}