gtfstools icon indicating copy to clipboard operation
gtfstools copied to clipboard

New `disambiguate_shapes()` and `trim_shapes()` functions

Open dhersz opened this issue 4 years ago • 0 comments

Oftentimes the same shape_id will be assigned to trips that follow the same "general" shape, but that are actually different.

Let's say for example that shape_id 1 goes from A, to B, to C and to D.

trip_id 1 describes a trip that goes from A to C, and trip_id 2 describes a trip that goes from B to D. In my opinion, these trips should be assigned to different shapes, even though they share the same "general" path.

In practice, GTFS from many different agencies will assign the same shape (shape_id 1) to the two different trips.

This issue can be fixed in two steps:

  • First identifying the shape_ids that are shared inadequately (in this case, let's say it would rename it to 1_1 and 1_2). disambiguate_shapes()
  • Then for each distinct shape, trim it to the first and the last stops associated to the trip it describes. trim_shapes()

trim_shapes() will behave weirdly if the shapes are not disambiguated first. In the aforementioned example, should it trim to A or B? So trim_shapes() MUST call disambiguate_shapes() first.

dhersz avatar Oct 28 '21 16:10 dhersz