MobilityData / gtfs-validator

Canonical GTFS Validator project for schedule (static) files.
https://gtfs-validator.mobilitydata.org/
Apache License 2.0
288 stars 101 forks source link

New Rule: Check if shapes listed in `shapes.txt` have more than one `shape_point` #1733

Closed praneethd7 closed 5 months ago

praneethd7 commented 7 months ago

Describe the problem

Hello All!

Thank you for building this amazing validator. I found this issue of shapes in shapes.txt having a single shape_point. The error is pretty much self-descriptive. Constructing a line or segment with a single shape point is impossible. Therefore, these shapes cannot be visualized on any GIS software (which requires LineString) or used for computations such as stop spacings. The error could be named shape_with_single_shape_point

Describe the new validation rule

Here is a sample code written in Python. Here the variable shapes is the pandas DataFrame of shapes.txt

shape_grp_df = shapes.groupby("shape_id").count()['shape_pt_sequence'].reset_index(name='count')
len1_shapes_count = len(shape_grp_df[shape_grp_df['count'] == 1])
if len1_shapes_count > 0: Trigger Error

Sample GTFS datasets

I checked all feeds in the database catalogs. I could not do an exhaustive search as some feeds needed API keys for access. Here is a list of agencies with this issue:

Here is a zip file for an example feed: LANTA lanta_gtfs_feed.zip

Severity

ERROR Shapes are supposed to describe the path that a vehicle travels along a route alignment. Having a single point in the shapes does not yield a path. Therefore, I see it as a violation of the original purpose. However, it currently does not violate the specification.

Additional context

I am happy to discuss more on this and collaborate if possible. Thank you!

welcome[bot] commented 7 months ago

Thanks for opening your first issue in this project! If you haven't already, you can join our slack and join the #gtfs-validators channel to meet our awesome community. Come say hi :wave:!

Welcome to the community and thank you for your engagement in open source! :tada:

emmambd commented 6 months ago

Hi @praneethd7 — thanks for your patience and for this detailed breakdown of the rule (including examples of feeds that generate this issue — incredible!)

We talked about this amongst the MobilityData team and agreed with you that this should be a notice (this is implicit in the spec), with the caveat that we think it's a WARNING rather than an ERROR since it's not a breaking change for consumers.

Would you be interested in contributing this rule to the validator? We'd be happy to support you in making this happen!

praneethd7 commented 6 months ago

Hi @emmambd👋 -Thank you for the update. Yes, it is indeed not a breaking change. I would be happy to contribute in the process of implementing this rule🤗