darwingraph

package
v0.0.0-...-fd78167 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeTiploc  = iota // Node is for a Tiploc
	NodeStation        // Node is for a Station
)
View Source
const (
	IdBase = 36 // Base for persisting id's, 36 = lowercase tiploc by coincidence
)
View Source
const (
	Legolash = "Legolash2o"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DarwinGraph

type DarwinGraph struct {
	// contains filtered or unexported fields
}

DarwinGraph is a Kernel service which maintains a TiplocGraph and delegate methods to it

func (*DarwinGraph) ComputeIfAbsent

func (d *DarwinGraph) ComputeIfAbsent(tiploc string, f func() RailNode) RailNode

ComputeIfAbsent returns an existing TiplocNode or creates one using the supplied function

func (*DarwinGraph) ForEachNode

func (d *DarwinGraph) ForEachNode(f func(node RailNode))

func (*DarwinGraph) ForEachStationEdge

func (d *DarwinGraph) ForEachStationEdge(f func(edge *StationEdge))

func (*DarwinGraph) ForEachStationNode

func (d *DarwinGraph) ForEachStationNode(f func(*StationNode))

func (*DarwinGraph) ForEachTiplocEdge

func (d *DarwinGraph) ForEachTiplocEdge(f func(*TiplocEdge))

func (*DarwinGraph) ForEachTiplocNode

func (d *DarwinGraph) ForEachTiplocNode(f func(*TiplocNode))

func (*DarwinGraph) GetTiplocNode

func (d *DarwinGraph) GetTiplocNode(tiploc string) *TiplocNode

GetTiplocNode returns an existing TiplocNode or nil if it doesn't exist

func (*DarwinGraph) Init

func (d *DarwinGraph) Init(_ *kernel.Kernel) error

func (*DarwinGraph) LinkTiplocs

func (d *DarwinGraph) LinkTiplocs(a, b string) *TiplocEdge

LinkTiplocs links two tiplocs together Returns the new TiplocEdge or nil if one already exists

func (*DarwinGraph) LoadGraph

func (d *DarwinGraph) LoadGraph() error

func (*DarwinGraph) Name

func (d *DarwinGraph) Name() string

func (*DarwinGraph) PostInit

func (d *DarwinGraph) PostInit() error

func (*DarwinGraph) SaveGraph

func (d *DarwinGraph) SaveGraph() error

func (*DarwinGraph) Start

func (d *DarwinGraph) Start() error

type ImportStations

type ImportStations struct {
	// contains filtered or unexported fields
}

func (*ImportStations) UnmarshalXML

func (r *ImportStations) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type ImportXml

type ImportXml struct {
	// contains filtered or unexported fields
}

func (*ImportXml) UnmarshalXML

func (r *ImportXml) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type RailGraph

type RailGraph struct {
	// contains filtered or unexported fields
}

RailGraph is a wrapper around a TiplocGraph & a StationGraph

func NewRailGraph

func NewRailGraph() *RailGraph

func (*RailGraph) AddNode

func (d *RailGraph) AddNode(n RailNode)

AddNode internal call to set a node in the graph

func (*RailGraph) ComputeIfAbsent

func (d *RailGraph) ComputeIfAbsent(id string, f func() RailNode) RailNode

func (*RailGraph) GetCrs

func (d *RailGraph) GetCrs(crs string) *StationNode

func (*RailGraph) GetNode

func (d *RailGraph) GetNode(s string) RailNode

GetNode returns an existing TiplocNode or nil if it doesn't exist

func (*RailGraph) GetTiploc

func (d *RailGraph) GetTiploc(tiploc string) *TiplocNode

func (*RailGraph) LinkTiplocs

func (d *RailGraph) LinkTiplocs(a, b string) *TiplocEdge

LinkTiplocs links two tiplocs together Returns the new TiplocEdge or nil if one already exists

func (*RailGraph) MarshalXML

func (d *RailGraph) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*RailGraph) NewStationNode

func (d *RailGraph) NewStationNode(tiploc *TiplocNode) *StationNode

func (*RailGraph) UnmarshalXML

func (d *RailGraph) UnmarshalXML(decoder *xml.Decoder, _ xml.StartElement) error

type RailNode

type RailNode interface {
	graph.Node
	NodeType() int
	Clone() RailNode
}

type StationEdge

type StationEdge struct {
	F   int64  // from tiploc - used in XML parser only
	T   int64  // to  tiploc - used in XML parser only
	Src string // Source of edge
	// contains filtered or unexported fields
}

func (*StationEdge) ForEachTiploc

func (e *StationEdge) ForEachTiploc(f func(node *TiplocNode))

func (StationEdge) From

func (e StationEdge) From() graph.Node

From returns the from-node of the edge.

func (*StationEdge) MarshalXML

func (e *StationEdge) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

func (StationEdge) ReversedEdge

func (e StationEdge) ReversedEdge() graph.Edge

ReversedEdge returns a new Edge with the F and T fields swapped.

func (StationEdge) To

func (e StationEdge) To() graph.Node

To returns the to-node of the edge.

func (*StationEdge) UnmarshalXML

func (e *StationEdge) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type StationNode

type StationNode struct {
	Crs  string // CRS of this station
	Name string // Name of the station
	// contains filtered or unexported fields
}

StationNode is a node in StationGraph representing a station

func (StationNode) Clone

func (n StationNode) Clone() RailNode

func (*StationNode) ForEachTiploc

func (n *StationNode) ForEachTiploc(f func(node *TiplocNode))

func (StationNode) ID

func (n StationNode) ID() int64

func (*StationNode) MarshalXML

func (n *StationNode) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (StationNode) NodeType

func (n StationNode) NodeType() int

func (StationNode) String

func (n StationNode) String() string

func (*StationNode) UnmarshalXML

func (n *StationNode) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type TiplocEdge

type TiplocEdge struct {
	F   int64  // from tiploc - used in XML parser only
	T   int64  // to  tiploc - used in XML parser only
	Src string // Source of edge
	// contains filtered or unexported fields
}

func (TiplocEdge) From

func (e TiplocEdge) From() graph.Node

From returns the from-node of the edge.

func (*TiplocEdge) MarshalXML

func (e *TiplocEdge) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

func (TiplocEdge) ReversedEdge

func (e TiplocEdge) ReversedEdge() graph.Edge

ReversedEdge returns a new Edge with the F and T fields swapped.

func (TiplocEdge) To

func (e TiplocEdge) To() graph.Node

To returns the to-node of the edge.

func (*TiplocEdge) UnmarshalXML

func (e *TiplocEdge) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type TiplocEntry

type TiplocEntry struct {
	Tiploc    string  `json:"Tiploc"`    // Tiploc to map to
	Stanox    int     `json:"Stanox"`    // Stanox code
	Name      string  `json:"Name"`      // Name of location
	Latitude  float32 `json:"Latitude"`  // Latitude
	Longitude float32 `json:"Longitude"` // Longitude
	InTPS     bool    `json:"InTPS"`     //
	InBPlan   bool    `json:"InBPlan"`   //
	Details   struct {
		CRS                string `json:"CRS"`                 // CRS code
		OffNetwork         bool   `json:"OffNetwork"`          // Is tiploc off the network
		Zone               int    `json:"Zone"`                // Travel card zone
		Nalco              int    `json:"Nalco"`               //
		UIC                int    `json:"UIC"`                 //
		ForceLPB           string `json:"ForceLPB"`            //
		CompulsoryStop     bool   `json:"CompulsoryStop"`      //
		TpsStationType     string `json:"TPS_StationType"`     //
		TpsStationCategory string `json:"Tps_StationCategory"` //
		BPlanTimingPoint   string `json:"BPlan_TimingPoint"`   //
	} `json:"Details"`
}

TiplocEntry represents individual entry in the json export.

type TiplocLocExport

type TiplocLocExport struct {
	ExportDate string        `json:"ExportDate"` // Export date
	Tiplocs    []TiplocEntry `json:"Tiplocs"`    // Entries 1 per tiploc
}

TiplocLocExport handles importing an extract of tiplocs to locations posted to the OpenRailData-Talk google group.

You can download the json from https://groups.google.com/g/openraildata-talk/c/RI7rumYXM84/m/7ZvumfZyBAAJ

type TiplocNode

type TiplocNode struct {
	darwinref.Location         // Location entry
	LocSrc             string  // Source of Location
	Lat                float32 // Latitude of point
	Lon                float32 // Longitude of point
	LLSrc              string  // Source of Lat/Lon
	// contains filtered or unexported fields
}

TiplocNode is a node on our generated map

func (TiplocNode) Clone

func (n TiplocNode) Clone() RailNode

func (*TiplocNode) HasPosition

func (n *TiplocNode) HasPosition() bool

func (TiplocNode) ID

func (n TiplocNode) ID() int64

func (*TiplocNode) MarshalXML

func (n *TiplocNode) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (TiplocNode) NodeType

func (n TiplocNode) NodeType() int

func (TiplocNode) String

func (n TiplocNode) String() string

func (*TiplocNode) UnmarshalXML

func (n *TiplocNode) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL