copier

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterpolateStopTimes

func InterpolateStopTimes(stoptimes []tl.StopTime) ([]tl.StopTime, error)

InterpolateStopTimes sets missing ArrivalTime, DestinationTime values. StopTimes must be sorted and valid.

Types

type Copier

type Copier struct {
	Reader    tl.Reader
	Writer    tl.Writer
	BatchSize int
	// Attempt to save an entity that returns validation errors
	AllowEntityErrors    bool
	AllowReferenceErrors bool
	// Interpolate any missing StopTime values: ArrivalTime/DepartureTime/ShapeDistTraveled
	InterpolateStopTimes bool
	// Create a stop-to-stop Shape for Trips without a ShapeID.
	CreateMissingShapes bool
	// Create missing Calendar entries
	NormalizeServiceIDs bool
	// Convert extended route types to primitives
	UseBasicRouteTypes bool
	// Default AgencyID
	DefaultAgencyID string
	// Entity selection strategy
	Marker Marker
	// Error handler, called for each entity
	ErrorHandler ErrorHandler

	*tl.EntityMap
	// contains filtered or unexported fields
}

Copier copies from Reader to Writer

func NewCopier

func NewCopier(reader tl.Reader, writer tl.Writer) Copier

NewCopier creates and initializes a new Copier.

func (*Copier) AddEntityFilter

func (copier *Copier) AddEntityFilter(ef tl.EntityFilter) error

AddEntityFilter adds an EntityFilter to the copy process.

func (*Copier) AddExtension

func (copier *Copier) AddExtension(e ext.Extension) error

AddExtension adds an Extension to the copy process.

func (*Copier) Copy

func (copier *Copier) Copy() *CopyResult

Copy copies Base GTFS entities from the Reader to the Writer, returning the summary as a CopyResult.

func (*Copier) CopyEntity

func (copier *Copier) CopyEntity(ent tl.Entity) (string, error, error)

CopyEntity performs validation and saves errors and warnings, returns new EntityID if written, otherwise an entity error or write error. An entity error means the entity was not not written because it had an error or was filtered out; not fatal. A write error should be considered fatal and should stop any further write attempts. Any errors and warnings are added to the CopyResult.

type CopyError

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

CopyError wraps an underlying GTFS Error with the filename and entity ID.

func NewCopyError

func NewCopyError(efn string, eid string, err error) *CopyError

NewCopyError returns a new CopyError error with filename and id set.

func (*CopyError) Cause

func (ce *CopyError) Cause() error

Cause returns the underlying GTFS Error

func (*CopyError) Context

func (ce *CopyError) Context() *causes.Context

Context returns the error Context

func (*CopyError) Error

func (ce *CopyError) Error() string

Error returns the error string.

type CopyResult

type CopyResult struct {
	WriteError                error
	Errors                    []error
	Warnings                  []error
	InterpolatedStopTimeCount int
	EntityCount               map[string]int
	GeneratedCount            map[string]int
	SkipEntityErrorCount      map[string]int
	SkipEntityReferenceCount  map[string]int
	SkipEntityFilterCount     map[string]int
	SkipEntityMarkedCount     map[string]int
}

CopyResult stores Copier results and statistics.

func NewCopyResult

func NewCopyResult() *CopyResult

NewCopyResult returns a new CopyResult.

func (*CopyResult) DisplayErrors

func (cr *CopyResult) DisplayErrors()

DisplayErrors shows individual errors in log.Info

func (*CopyResult) DisplaySummary

func (cr *CopyResult) DisplaySummary()

DisplaySummary shows entity and error counts in log.Info

func (*CopyResult) HandleEntityErrors

func (cr *CopyResult) HandleEntityErrors(ent tl.Entity, errs []error, warns []error)

HandleEntityErrors .

func (*CopyResult) HandleSourceErrors

func (cr *CopyResult) HandleSourceErrors(fn string, errs []error, warns []error)

HandleSourceErrors .

type ErrorHandler

type ErrorHandler interface {
	HandleEntityErrors(tl.Entity, []error, []error)
	HandleSourceErrors(string, []error, []error)
}

ErrorHandler is called on each source file and entity; errors can be nil

type Marker

type Marker interface {
	IsMarked(string, string) bool
	IsVisited(string, string) bool
}

Marker visits and marks entities.

Jump to

Keyboard shortcuts

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