Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gtfs/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Stop struct {
StopTimezone tt.Timezone
WheelchairBoarding tt.Int `enum:"0,1,2"`
LevelID tt.Key `target:"levels.txt"`
StopAccess tt.Int `enum:"0,1"`
Geometry tt.Point `csv:"-" db:"geometry"`
tt.BaseEntity
}
Expand Down Expand Up @@ -105,5 +106,18 @@ func (ent *Stop) ConditionalErrors() []error {
if (lt == 2 || lt == 3 || lt == 4) && ent.ParentStation.Val == "" {
errs = append(errs, causes.NewConditionallyRequiredFieldError("parent_station"))
}

// Validate stop_access field
if ent.StopAccess.Valid {
// Forbidden for stations, entrances, generic nodes, and boarding areas
if lt == 1 || lt == 2 || lt == 3 || lt == 4 {
errs = append(errs, causes.NewInvalidFieldError("stop_access", fmt.Sprint(ent.StopAccess.Val), fmt.Errorf("stop_access is forbidden for location_type %d", lt)))
}
// Forbidden when parent_station is empty
if ent.ParentStation.Val == "" {
errs = append(errs, causes.NewInvalidFieldError("stop_access", fmt.Sprint(ent.StopAccess.Val), fmt.Errorf("stop_access is forbidden when parent_station is empty")))
}
}

return errs
}
2 changes: 1 addition & 1 deletion internal/testreadme/main.go
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package main
package main
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;

ALTER TABLE gtfs_stops DROP COLUMN stop_access;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;

ALTER TABLE gtfs_stops ADD COLUMN stop_access integer;

COMMIT;
1 change: 1 addition & 0 deletions schema/sqlite/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ CREATE TABLE IF NOT EXISTS "gtfs_stops" (
"level_id" integer,
"tts_stop_name" text,
"platform_code" text,
"stop_access" integer,
"geometry" BLOB,
foreign key(feed_version_id) REFERENCES feed_versions(id),
foreign key(parent_station) references gtfs_stops(id),
Expand Down
Loading