Giter Site home page Giter Site logo

traingraph's Introduction

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 (TrainGraph) GeneratePDF

func (t TrainGraph) GeneratePDF(filename string)

model

import "github.com/joushx/traingraph/pkg/model"

Index

type Ifopt

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

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

traingraph's People

Contributors

joushx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.