示例#1
0
func seedVertex(src *models.TrainEvent, outEdges map[VertexKey][]*Edge) (*Vertex, error) {
	key := NewVertex(src.ScheduledDepartureDate(), src).HashKey()
	edges := outEdges[key]
	if len(edges) > 0 {
		srcV := edges[0].from
		srcV.SetTimeFromSource(0)
		logger.Printf("Looking for %p, %v", src, *src)
		return srcV, nil
	}
	return nil, errors.New("src has no outgoing edges!")
}
示例#2
0
// ConvertTrain takes a models.TrainEvent and returns a JSONTrainEvent
func (c trainConverter) ConvertTrain(t *models.TrainEvent) (*JSONTrainEvent, error) {
	trainNumner, err := strconv.Atoi(t.TrainNumber)
	currentStationId, err := strconv.Atoi(t.StationUic)
	if err != nil {
		return nil, err
	}

	arrivalDate := t.ScheduledArrivalDate().Format("2006-01-02")
	arrivalTime := t.ScheduledArrivalDate().Format("15:04")

	departureDate := t.ScheduledDepartureDate().Format("2006-01-02")
	departureTime := t.ScheduledDepartureDate().Format("15:04")

	return &JSONTrainEvent{
		trainNumner,
		currentStationId,
		t.StationName,
		t.DestinationName,
		arrivalTime,
		arrivalDate,
		departureTime,
		departureDate,
	}, nil
}