rules

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rules provides a number of GTFS validation rules and examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateStopTimes added in v0.18.0

func ValidateStopTimes(stoptimes []gtfs.StopTime) []error

ValidateStopTimes checks if the trip follows GTFS rules, including GTFS-Flex extensions.

Types

type AgencyIDConditionallyRequiredCheck

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

AgencyIDConditionallyRequiredCheck checks if agency_id is missing when more than one agency is present. This check is for when agency_id is *required* - see AgencyIDRecommendedCheck for when it is recommended but not required.

func (*AgencyIDConditionallyRequiredCheck) Validate

Validate .

type CalendarDuplicateDates added in v0.10.0

type CalendarDuplicateDates struct {
}

func (*CalendarDuplicateDates) Validate added in v0.10.0

func (e *CalendarDuplicateDates) Validate(ent tt.Entity) []error

type EntityDuplicateIDCheck added in v1.0.0

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

EntityDuplicateCheck determines if a unique entity ID is present more than once in the file.

func (*EntityDuplicateIDCheck) Validate added in v1.0.0

func (e *EntityDuplicateIDCheck) Validate(ent tt.Entity) []error

Validate .

type EntityDuplicateKeyCheck added in v1.0.0

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

func (*EntityDuplicateKeyCheck) Validate added in v1.0.0

func (e *EntityDuplicateKeyCheck) Validate(ent tt.Entity) []error

Validate .

type FareProductRiderCategoryDefaultCheck added in v1.1.0

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

FareProductRiderCategoryDefaultCheck checks if agency_id is missing when more than one agency is present.

func (*FareProductRiderCategoryDefaultCheck) Validate added in v1.1.0

Validate checks that no fare_product_id group allows more than one default rider category.

type FlexGeographyIDDuplicateError added in v1.3.0

type FlexGeographyIDDuplicateError struct {
	GeographyID string
	FirstFile   string
	SecondFile  string
	// contains filtered or unexported fields
}

FlexGeographyIDDuplicateError reports when a geography ID is duplicated across stops.txt, locations.geojson, or location_groups.txt.

func (*FlexGeographyIDDuplicateError) Error added in v1.3.0

type FlexGeographyIDUniqueCheck added in v1.3.0

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

FlexGeographyIDUniqueCheck validates that geography IDs are unique across stops.txt, locations.geojson, and location_groups.txt.

Per GTFS-Flex specification, these three ID spaces are merged into a single namespace that can be referenced in stop_times.txt via stop_id or location_id.

func (*FlexGeographyIDUniqueCheck) AfterWrite added in v1.3.0

func (e *FlexGeographyIDUniqueCheck) AfterWrite(eid string, ent tt.Entity, emap *tt.EntityMap) error

func (*FlexGeographyIDUniqueCheck) Validate added in v1.3.0

func (e *FlexGeographyIDUniqueCheck) Validate(ent tt.Entity) []error

type FlexLocationGeometryCheck added in v1.3.0

type FlexLocationGeometryCheck struct{}

FlexLocationGeometryCheck validates that locations have valid Polygon or MultiPolygon geometries.

func (*FlexLocationGeometryCheck) Validate added in v1.3.0

func (e *FlexLocationGeometryCheck) Validate(ent tt.Entity) []error

type FlexLocationGeometryError added in v1.3.0

type FlexLocationGeometryError struct {
	LocationID   string
	ErrorMessage string
	// contains filtered or unexported fields
}

FlexLocationGeometryError reports when a location has invalid geometry.

func (*FlexLocationGeometryError) Error added in v1.3.0

func (e *FlexLocationGeometryError) Error() string

type FlexStopLocationTypeCheck added in v1.3.0

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

FlexStopLocationTypeCheck validates that stops referenced in flex stop_times have appropriate location_type. According to GTFS-Flex, stops used in continuous stopping or location_id/location_group_id references must be location_type=0 (stop/platform).

func (*FlexStopLocationTypeCheck) AfterWrite added in v1.3.0

func (e *FlexStopLocationTypeCheck) AfterWrite(eid string, ent tt.Entity, emap *tt.EntityMap) error

func (*FlexStopLocationTypeCheck) Validate added in v1.3.0

func (e *FlexStopLocationTypeCheck) Validate(ent tt.Entity) []error

type FlexStopLocationTypeError added in v1.3.0

type FlexStopLocationTypeError struct {
	StopID       string
	LocationType int
	// contains filtered or unexported fields
}

FlexStopLocationTypeError reports when a stop referenced in a flex service has invalid location_type.

func (*FlexStopLocationTypeError) Error added in v1.3.0

func (e *FlexStopLocationTypeError) Error() string

type FlexZoneIDConditionalCheck added in v1.3.0

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

FlexZoneIDConditionalCheck validates that locations have zone_id when fare_rules.txt exists.

func (*FlexZoneIDConditionalCheck) AfterWrite added in v1.3.0

func (e *FlexZoneIDConditionalCheck) AfterWrite(eid string, ent tt.Entity, emap *tt.EntityMap) error

func (*FlexZoneIDConditionalCheck) Validate added in v1.3.0

func (e *FlexZoneIDConditionalCheck) Validate(ent tt.Entity) []error

type FlexZoneIDRequiredError added in v1.3.0

type FlexZoneIDRequiredError struct {
	LocationID string
	// contains filtered or unexported fields
}

FlexZoneIDRequiredError reports when zone_id is missing in locations.geojson but fare_rules.txt exists.

func (*FlexZoneIDRequiredError) Error added in v1.3.0

func (e *FlexZoneIDRequiredError) Error() string

type InconsistentTimezoneCheck

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

InconsistentTimezoneCheck checks for InconsistentTimezoneErrors.

func (*InconsistentTimezoneCheck) Validate

func (e *InconsistentTimezoneCheck) Validate(ent tt.Entity) []error

Validate .

type InconsistentTimezoneError

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

InconsistentTimezoneError reports when agency.txt has more than 1 unique timezone present.

func NewInconsistentTimezoneError

func NewInconsistentTimezoneError(value string) *InconsistentTimezoneError

NewInconsistentTimezoneError returns a new InconsistentTimezoneError.

func (*InconsistentTimezoneError) Error

func (e *InconsistentTimezoneError) Error() string

type InvalidFarezoneError

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

InvalidFarezoneError reports when a farezone does not exist.

func NewInvalidFarezoneError

func NewInvalidFarezoneError(field string, value string) *InvalidFarezoneError

NewInvalidFarezoneError returns a new InvalidFarezoneError

func (*InvalidFarezoneError) Error

func (e *InvalidFarezoneError) Error() string

type InvalidParentStationError

type InvalidParentStationError struct {
	StopID            string
	LocationType      int
	ParentStation     string
	ParentStationType int
	// contains filtered or unexported fields
}

InvalidParentStationError reports when a parent_station has a location_type that is not allowed.

func (*InvalidParentStationError) Error

func (e *InvalidParentStationError) Error() string

type ParentStationLocationTypeCheck

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

ParentStationLocationTypeCheck checks for InvalidParentStationErrors.

func (*ParentStationLocationTypeCheck) AfterWrite added in v0.12.0

func (e *ParentStationLocationTypeCheck) AfterWrite(eid string, ent tt.Entity, emap *tt.EntityMap) error

func (*ParentStationLocationTypeCheck) Validate

func (e *ParentStationLocationTypeCheck) Validate(ent tt.Entity) []error

type StopTimeSequenceCheck

type StopTimeSequenceCheck struct{}

StopTimeSequenceCheck checks that all sequences stop_time sequences in a trip are valid. This should be split into multiple validators.

func (*StopTimeSequenceCheck) Validate

func (e *StopTimeSequenceCheck) Validate(ent tt.Entity) []error

Validate .

type TransferStopLocationTypeCheck added in v1.1.2

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

TransferStopLocationTypeCheck checks that stops referenced in transfers.txt have valid location_types. According to GTFS spec: - For transfer_type 0,1,2,3: stops must have location_type 0 (stop/platform) or 1 (station) - For transfer_type 4,5: fields are optional, but when provided must have location_type 0 (stop/platform)

func (*TransferStopLocationTypeCheck) AfterWrite added in v1.1.2

func (e *TransferStopLocationTypeCheck) AfterWrite(eid string, ent tt.Entity, emap *tt.EntityMap) error

func (*TransferStopLocationTypeCheck) Validate added in v1.1.2

func (e *TransferStopLocationTypeCheck) Validate(ent tt.Entity) []error

type TransferStopLocationTypeError added in v1.1.2

type TransferStopLocationTypeError struct {
	StopID       string
	FieldName    string // from_stop_id or to_stop_id
	LocationType int
	TransferType int64
}

TransferStopLocationTypeError reports when a transfer references a stop with an invalid location_type.

func (*TransferStopLocationTypeError) Error added in v1.1.2

type ValidFarezoneCheck

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

ValidFarezoneCheck checks for InvalidFarezoneErrors.

func (*ValidFarezoneCheck) Validate

func (e *ValidFarezoneCheck) Validate(ent tt.Entity) []error

Validate .

Jump to

Keyboard shortcuts

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