Spaces:
Sleeping

dn commited on
Commit
1d0385c
·
1 Parent(s): fb9b022

update gtfs.zip

Browse files
notebooks/public/oc-streetcar_gtfs.zip CHANGED
Binary files a/notebooks/public/oc-streetcar_gtfs.zip and b/notebooks/public/oc-streetcar_gtfs.zip differ
 
tests/test_gtfs_to_parcels.py CHANGED
@@ -364,8 +364,58 @@ class TestParseGtfsZip:
364
  finally:
365
  path.unlink(missing_ok=True)
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  def test_mixed_route_types(self):
368
  """Station with route_types '0,1' should be Tier 1 (has subway)."""
 
369
  gtfs_bytes = _make_gtfs_zip(
370
  routes=[
371
  {"route_id": "801", "route_type": "1", "agency_id": "metro"},
 
364
  finally:
365
  path.unlink(missing_ok=True)
366
 
367
+ def test_no_parent_stations(self):
368
+ """Feed with only location_type=0 stops (no parent stations) should still work.
369
+
370
+ Some GTFS feeds (e.g. OC Streetcar) have no location_type=1 entries.
371
+ Each boarding stop should be treated as its own station.
372
+ """
373
+ gtfs_bytes = _make_gtfs_zip(
374
+ routes=[{"route_id": "801", "route_type": "0", "agency_id": "metro"}],
375
+ trips=[
376
+ {"route_id": "801", "trip_id": "t1", "service_id": "wk", "direction_id": "0"},
377
+ {"route_id": "801", "trip_id": "t2", "service_id": "wk", "direction_id": "1"},
378
+ ],
379
+ stop_times=[
380
+ {"trip_id": "t1", "stop_id": "S1"},
381
+ {"trip_id": "t2", "stop_id": "S1"},
382
+ ],
383
+ stops=[
384
+ {
385
+ "stop_id": "S1",
386
+ "stop_name": "Stop 1",
387
+ "stop_lat": "34.0",
388
+ "stop_lon": "-118.0",
389
+ "location_type": "0",
390
+ },
391
+ ],
392
+ calendar=[
393
+ {
394
+ "service_id": "wk",
395
+ "monday": "1",
396
+ "tuesday": "1",
397
+ "wednesday": "1",
398
+ "thursday": "1",
399
+ "friday": "1",
400
+ "saturday": "0",
401
+ "sunday": "0",
402
+ }
403
+ ],
404
+ )
405
+ path = Path(tempfile.gettempdir()) / "_test_gtfs_no_parent.zip"
406
+
407
+ path.write_bytes(gtfs_bytes)
408
+ try:
409
+ result = parse_gtfs_zip(path)
410
+ assert len(result) == 1
411
+ assert result.iloc[0]["stop_id"] == "S1"
412
+ assert result.iloc[0]["Tier"] == 2 # route_type=0, 2 trips/5=0.4/day < 72
413
+ finally:
414
+ path.unlink(missing_ok=True)
415
+
416
  def test_mixed_route_types(self):
417
  """Station with route_types '0,1' should be Tier 1 (has subway)."""
418
+
419
  gtfs_bytes = _make_gtfs_zip(
420
  routes=[
421
  {"route_id": "801", "route_type": "1", "agency_id": "metro"},