Traingraph generation in go
What is this? See https://de.wikipedia.org/wiki/Bildfahrplan
Usage
infrastructure := []model.InfrastructureObject{
{
Name: "A",
Distance: 0,
Location: 123.45,
Type: "station",
Id: model.ObjectID{
Db640: "Aa",
Ifopt: util.NewIfOpt("at:44:1234:0:1"),
},
},
{
Name: "A Ort",
Distance: 0.5,
Location: 123.7,
Type: "stop",
Id: model.ObjectID{
Db640: "Aa H1",
Ifopt: util.NewIfOpt("at:44:1235"),
},
},
{
Name: "B",
Distance: 1,
Location: 124.45,
Type: "station",
Id: model.ObjectID{
Db640: "Bb",
Ifopt: util.NewIfOpt("at:44:5678:0:2"),
},
},
{
Name: "C",
Distance: 1,
Location: 125.0,
Type: "station",
Id: model.ObjectID{
Db640: "Cc",
Ifopt: util.NewIfOpt("at:44:9876:0:2"),
},
},
}
timetable := []model.Journey{
{
ID: "1234",
Name: "REX 1234",
Stops: []model.StopTime{
{
Id: model.ObjectID{
Ifopt: util.NewIfOpt("at:44:1234:0:1"),
},
Departure: "09:00",
},
{
Id: model.ObjectID{
Ifopt: util.NewIfOpt("at:44:1235"),
},
Arrival: "09:05",
Departure: "09:06",
},
{
Id: model.ObjectID{
Ifopt: util.NewIfOpt("at:44:5678:0:2"),
},
Arrival: "09:15",
Departure: "09:17",
},
{
Id: model.ObjectID{
Ifopt: util.NewIfOpt("at:44:9876:0:2"),
},
Arrival: "09:30",
},
},
},
}
renderer := oebb.NewOebbStyleRenderer(
"A - B",
"Blatt 1234",
time.Now(),
time.Now().AddDate(0, 0, 1),
)
traingraph := traingraph.NewTrainGraph(
infrastructure,
timetable,
&renderer,
)
traingraph.GeneratePDF("out.pdf")
Example
see the examples
folder
traingraph
import "github.com/joushx/traingraph/pkg/traingraph"
Index
type TrainGraph struct {
// contains filtered or unexported fields
}
func NewTrainGraph(infrastructure []model.InfrastructureObject, journeys []model.Journey, renderer render.Renderer) TrainGraph
func (t TrainGraph) GeneratePDF(filename string)
model
import "github.com/joushx/traingraph/pkg/model"
Index
type Ifopt struct {
Country string
State string
Stop string
Area string
Platform string
}
type InfrastructureObject struct {
Name string `yaml:"name"`
Location float32 `yaml:"location"`
Distance float32 `yaml:"distance"`
Type string `yaml:"type"`
Id ObjectID `yaml:"id"`
}
type Journey struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Stops []StopTime `yaml:"stops"`
}
type ObjectID struct {
Db640 string `yaml:"db640,omitempty"`
ExtId string `yaml:"extId,omitempty"`
Ifopt Ifopt `yaml:"ifopt,omitempty"`
}
type StopTime struct {
Id ObjectID `yaml:"id"`
Arrival string `yaml:"arrival,omitempty"`
Departure string `yaml:"departure,omitempty"`
}
util
import "github.com/joushx/traingraph/pkg/util"
Index
func NewIfOpt(value string) model.Ifopt
Generated by gomarkdoc