Skip to content

feat: validate stair_count, traversal_time and max_slope against pathway_mode - #2170

Open
vssinghh wants to merge 3 commits into
MobilityData:masterfrom
vssinghh:feat/stair-count-recommended-for-stairs
Open

feat: validate stair_count, traversal_time and max_slope against pathway_mode#2170
vssinghh wants to merge 3 commits into
MobilityData:masterfrom
vssinghh:feat/stair-count-recommended-for-stairs

Conversation

@vssinghh

@vssinghh vssinghh commented Aug 5, 2026

Copy link
Copy Markdown

Summary:

Adds PathwayModeFieldsValidator, covering the four pathway fields whose expectations depend on pathway_mode:

field rule notice
length recommended for modes 1, 6, 7 missing_recommended_field
stair_count recommended for stairs (mode 2) missing_recommended_field
traversal_time recommended for modes 3, 4, 5 missing_recommended_field
max_slope should only be used with modes 1 and 3 irrelevant_max_slope_set_for_pathway_mode (new, WARNING)

Closes #1787, #1788 and #1789.

A max_slope of 0 is not reported, since the spec defines both an empty value and 0 as "no slope". A length of 0 is reported as defined, since the spec gives it no special meaning.

Expected behavior:

Running the CLI on the Archive.zip from #1788 gives 9 warnings:

length          1  (row 3)
stair_count     1  (row 5)
traversal_time  7  (rows 4, 11, 17, 20, 23, 28, 38)

max_slope gets no coverage from that sample because the file has no max_slope column. Unit tests cover it, 15 in total across the four rules.

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]"
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s) (validator output above)

The GTFS reference states that pathways.stair_count is recommended for
stairs (pathway_mode=2). Nothing checked this, so feeds could omit the
step count on stairs without any signal.

Adds PathwayStairCountValidator, which emits the existing
MissingRecommendedFieldNotice when a pathway has pathway_mode=2 and no
stair_count. This follows the same shape as FareMediaNameValidator and
RouteAgencyIdValidator, which raise the generic recommended-field notice
under a conditional rather than defining a new notice type.

Closes MobilityData#1788
@welcome

welcome Bot commented Aug 5, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! You're awesome. We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of titles with semantic prefixes:

  • fix: Bug with ssl network connections + Java module permissions.
  • feat: Initial support for multiple @PrimaryKey annotations.
  • docs: update RELEASE.md with new process
    To get this PR to the finish line, please do the following:
  • Read our Contribution Guidelines
  • Follow Google Java style coding standards
  • Include tests when adding/changing behavior
  • Include screenshots

@skalexch skalexch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vssinghh thank you for this addition! The logic looks correct along with the tests.

One question: Do you have a capacity to do the same for traversal_time and max_slope?
traversal_time is recommended for pathway_modes=3, 4 and 5 (missing_recommended_field). Why max_slope should only be used for pathway_modes=1 and 3 (maybe a new rule like irrelevent_max_slope_set_for_pathway_mode).

Let me know if you have the capacity to do them both or at least one of them. You could do it in the same file and rename the file.

@vssinghh

vssinghh commented Aug 5, 2026

Copy link
Copy Markdown
Author

Thank you for the comment. I will take those as well.

Extends the stair_count rule to the other two pathway fields whose
expectations depend on pathway_mode, as requested in review:

- traversal_time is recommended for pathway_mode 3, 4 and 5, reported
  with the existing missing_recommended_field notice
- max_slope should only be used with pathway_mode 1 and 3, reported with
  a new irrelevant_max_slope_set_for_pathway_mode warning

A max_slope of 0 is not reported, since the spec defines both an empty
value and 0 as "no slope".

Renames PathwayStairCountValidator to PathwayModeFieldsValidator.

Closes MobilityData#1789
@vssinghh vssinghh changed the title feat: recommend stair_count for stairs pathways feat: validate stair_count, traversal_time and max_slope against pathway_mode Aug 5, 2026
@vssinghh

vssinghh commented Aug 5, 2026

Copy link
Copy Markdown
Author

Updated the files.

@skalexch

skalexch commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@vssinghh thanks for the change! I tested on a deliberately incorrect pathways file and it worked! (check screenshot) One small thing that I forgot (my apologies), if you could add the missing_recommended_field notice to pathways.length, it's recommended for walkways (pathway_mode=1), fare gates (pathway_mode=6) and exit gates (pathway_mode=7).

Otherwise, everything looks great! I'll approve right after.

Screenshot 2026-08-06 at 10 27 54 AM

Completes the set of pathway fields whose expectations depend on
pathway_mode. The spec recommends length for walkways (pathway_mode=1),
fare gates (pathway_mode=6) and exit gates (pathway_mode=7), reported
with the existing missing_recommended_field notice.

Unlike max_slope, the spec gives no special meaning to a length of 0, so
a zero value counts as defined and is not reported.

Closes MobilityData#1787
@vssinghh

vssinghh commented Aug 6, 2026

Copy link
Copy Markdown
Author

Thank you for the comment. Added it.

@skalexch skalexch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on a spec side. I'll wait on a dev person to go through the code and then you're clear. @davidgamez @jcpitre @cka-y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pathways.length is recommended if pathway_mode is set to 1, 6 or 7.

3 participants