validator

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: GPL-3.0 Imports: 23 Imported by: 1

Documentation

Overview

Package validator provides GTFS and GTFS-RT validation utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveValidationReport added in v0.16.0

func SaveValidationReport(atx tldb.Adapter, result *Result, fvid int, reportStorage string) error

Types

type Options added in v0.8.0

type Options struct {
	BestPractices            bool
	CheckFileLimits          bool
	IncludeServiceLevels     bool
	IncludeEntities          bool
	IncludeEntitiesLimit     int
	IncludeRouteGeometries   bool
	UseHeaderTimestamp       bool
	ValidateRealtimeMessages []string
	IncludeRealtimeJson      bool
	MaxRTMessageSize         uint64
	EvaluateAt               time.Time
	EvaluateAtTimezone       string
	copier.Options
}

Options defines options for the Validator.

type RealtimeResult added in v0.14.0

type RealtimeResult struct {
	Url                  string          `json:"url"`
	Json                 map[string]any  `json:"json"`
	EntityCounts         rt.EntityCounts `json:"entity_counts"`
	TripUpdateStats      []rt.RTTripStat `json:"trip_update_stats"`
	VehiclePositionStats []rt.RTTripStat `json:"vehicle_position_stats"`
	Errors               []error
}

type Result added in v0.8.0

type Result struct {
	Validator               tt.String                              `json:"validator"`
	ValidatorVersion        tt.String                              `json:"validator_version"`
	Success                 tt.Bool                                `json:"success"`
	FailureReason           tt.String                              `json:"failure_reason"`
	ReportedAt              tt.Time                                `json:"reported_at"`
	ReportedAtLocal         tt.Time                                `json:"reported_at_local"`
	ReportedAtLocalTimezone tt.String                              `json:"reported_at_local_timezone"`
	File                    tt.String                              `json:"file"`
	IncludesStatic          tt.Bool                                `json:"includes_static"`
	IncludesRT              tt.Bool                                `json:"includes_rt"`
	Details                 ResultDetails                          `json:"details" db:"-"`
	Errors                  map[string]*ValidationReportErrorGroup `json:"errors" db:"-"`
	Warnings                map[string]*ValidationReportErrorGroup `json:"warnings" db:"-"`
	tt.BaseEntity
}

Result contains a validation report result,

func NewResult added in v0.16.0

func NewResult(evaluateAt time.Time, evaluateAtLocal time.Time) *Result

func (*Result) Key added in v0.16.0

func (r *Result) Key() string

func (*Result) TableName added in v0.16.0

func (e *Result) TableName() string

type ResultDetails added in v0.16.0

type ResultDetails struct {
	SHA1                 tt.String                      `json:"sha1"`
	Timezone             tt.String                      `json:"timezone"`
	EarliestCalendarDate tt.Date                        `json:"earliest_calendar_date"`
	LatestCalendarDate   tt.Date                        `json:"latest_calendar_date"`
	Agencies             []gtfs.Agency                  `json:"agencies"`
	Routes               []gtfs.Route                   `json:"routes"`
	Stops                []gtfs.Stop                    `json:"stops"`
	FeedInfos            []gtfs.FeedInfo                `json:"feed_infos"`
	Files                []dmfr.FeedVersionFileInfo     `json:"files"`
	ServiceLevels        []dmfr.FeedVersionServiceLevel `json:"service_levels"`
	Realtime             []RealtimeResult               `json:"realtime"`
}

type ValidationReportErrorExemplar added in v0.16.0

type ValidationReportErrorExemplar struct {
	ValidationReportErrorGroupID int
	Line                         int
	Message                      string
	EntityID                     string
	Value                        string
	Geometry                     tt.Geometry
	EntityJson                   tt.Map
	tt.DatabaseEntity
}

func (*ValidationReportErrorExemplar) TableName added in v0.16.0

func (e *ValidationReportErrorExemplar) TableName() string

type ValidationReportErrorGroup added in v0.16.0

type ValidationReportErrorGroup struct {
	ValidationReportID int
	Filename           string
	Field              string
	ErrorType          string
	ErrorCode          string
	GroupKey           string
	Level              int
	Count              int
	Errors             []ValidationReportErrorExemplar `db:"-"`
	tt.DatabaseEntity
}

func (*ValidationReportErrorGroup) TableName added in v0.16.0

func (e *ValidationReportErrorGroup) TableName() string

type ValidationReportTripUpdateStat added in v0.16.0

type ValidationReportTripUpdateStat struct {
	ValidationReportID      int
	AgencyID                string
	RouteID                 string
	TripScheduledIDs        tt.Strings `db:"trip_scheduled_ids"`
	TripRtIDs               tt.Strings `db:"trip_rt_ids"`
	TripScheduledCount      int
	TripScheduledMatched    int `db:"trip_match_count"`
	TripScheduledNotMatched int
	TripRtCount             int
	TripRtMatched           int
	TripRtNotMatched        int
	TripRtAddedIDs          tt.Strings `db:"trip_rt_added_ids"`
	TripRtAddedCount        int
	TripRtNotFoundIDs       tt.Strings `db:"trip_rt_not_found_ids"`
	TripRtNotFoundCount     int
	tt.DatabaseEntity
}

func (*ValidationReportTripUpdateStat) TableName added in v0.16.0

func (e *ValidationReportTripUpdateStat) TableName() string

type ValidationReportVehiclePositionStat added in v0.16.0

type ValidationReportVehiclePositionStat struct {
	ValidationReportID      int
	AgencyID                string
	RouteID                 string
	TripScheduledIDs        tt.Strings `db:"trip_scheduled_ids"`
	TripRtIDs               tt.Strings `db:"trip_rt_ids"`
	TripScheduledCount      int
	TripScheduledMatched    int `db:"trip_match_count"`
	TripScheduledNotMatched int
	TripRtCount             int
	TripRtMatched           int
	TripRtNotMatched        int
	TripRtAddedIDs          tt.Strings `db:"trip_rt_added_ids"`
	TripRtAddedCount        int
	TripRtNotFoundIDs       tt.Strings `db:"trip_rt_not_found_ids"`
	TripRtNotFoundCount     int
	tt.DatabaseEntity
}

func (*ValidationReportVehiclePositionStat) TableName added in v0.16.0

type Validator

type Validator struct {
	Reader  adapters.Reader
	Options Options
	// contains filtered or unexported fields
}

Validator checks a GTFS source for errors and warnings.

func NewValidator

func NewValidator(reader adapters.Reader, options Options) (*Validator, error)

NewValidator returns a new Validator.

func (*Validator) AddExtension added in v0.8.5

func (v *Validator) AddExtension(ext any) error

func (*Validator) Validate

func (v *Validator) Validate() (*Result, error)

Validate performs a basic validation, as well as optional extended reports.

func (*Validator) ValidateRT added in v0.16.0

func (v *Validator) ValidateRT(fn string, evaluateAt time.Time, evaluateAtLocal time.Time) (RealtimeResult, error)

Validate realtime messages

func (*Validator) ValidateRTs added in v0.16.0

func (v *Validator) ValidateRTs(rtUrls []string, evaluateAt time.Time, evaluateAtLocal time.Time) (*Result, error)

func (*Validator) ValidateStatic added in v0.16.0

func (v *Validator) ValidateStatic(reader adapters.Reader, evaluateAt time.Time, evaluateAtLocal time.Time) (*Result, error)

Jump to

Keyboard shortcuts

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