GTFS双向航线的行程与站点序列定义及轮渡Feed配置问询
Got it, let's break down how to define the trips and stop sequences for your bidirectional A↔B ferry service (including support for 2 ferries) in GTFS, building on the config you already have. Here's a step-by-step, practical approach:
1. First: Formalize Direction IDs for Bidirectional Service
GTFS uses direction_id (0 or 1, typically) to distinguish opposite directions of the same route. For your ferry:
- Assign
direction_id=0to trips traveling A → B - Assign
direction_id=1to trips traveling B → A
This keeps your feed consistent and makes it easy for routing tools to parse the two directions.
2. Update trips.txt for Both Directions & Multiple Ferries
Your existing trips.txt has the core fields; here's how to populate it for both directions and 2 ferries. We'll use unique trip_id values for each distinct sailing, clear trip_headsign values to show destination, and fill in the wheelchair_accessible field (assuming your ferries are accessible):
route_id,service_id,trip_id,trip_headsign,direction_id,shape_id,wheelchair_accessible AB,FULLWEEK,AB_FERRY1_0800,Port B,0,SHAPE_AB,1 AB,FULLWEEK,BA_FERRY1_0900,Port A,1,SHAPE_BA,1 AB,FULLWEEK,AB_FERRY2_0830,Port B,0,SHAPE_AB,1 AB,FULLWEEK,BA_FERRY2_0930,Port A,1,SHAPE_BA,1
trip_idfollows a clear pattern:[Direction]_[FerryNumber]_[DepartureTime]for readabilityshape_idlinks to the geographic path of the ferry (we'll cover this later)- If both ferries use the same route path, you can reuse the same
shape_idfor their trips
3. Define Your Stops (stops.txt)
You'll need a stops.txt file to list your two ports—this is required to map trip sequences. Here's the setup:
stop_id,stop_name,stop_lat,stop_lon,location_type STOP_A,Port A,40.7128,-74.0060,0 STOP_B,Port B,40.7308,-73.9973,0
location_type=0marks these as regular passenger stops- Fill in the actual latitude/longitude coordinates for your ports
4. Map Trip Stop Sequences (stop_times.txt)
This is the key file that defines the order of stops and timing for each trip. The critical fields are trip_id, arrival_time, departure_time, stop_id, and stop_sequence.
Example for A → B Trips
trip_id,arrival_time,departure_time,stop_id,stop_sequence,pickup_type,drop_off_type AB_FERRY1_0800,08:00:00,08:00:00,STOP_A,1,0,1 AB_FERRY1_0800,08:30:00,08:30:00,STOP_B,2,1,0 AB_FERRY2_0830,08:30:00,08:30:00,STOP_A,1,0,1 AB_FERRY2_0830,09:00:00,09:00:00,STOP_B,2,1,0
stop_sequence=1is the origin (Port A),stop_sequence=2is the destination (Port B)pickup_type=0allows boarding,pickup_type=1disallows boarding (for the destination)drop_off_type=0allows alighting,drop_off_type=1disallows alighting (for the origin)
Example for B → A Trips
trip_id,arrival_time,departure_time,stop_id,stop_sequence,pickup_type,drop_off_type BA_FERRY1_0900,09:00:00,09:00:00,STOP_B,1,0,1 BA_FERRY1_0900,09:30:00,09:30:00,STOP_A,2,1,0 BA_FERRY2_0930,09:30:00,09:30:00,STOP_B,1,0,1 BA_FERRY2_0930,10:00:00,10:00:00,STOP_A,2,1,0
5. Handling Multiple Ferries (2 Vessels)
If you have 2 ferries running, you just add additional trips to trips.txt and stop_times.txt with staggered departure times (like the example above). This lets riders see all available sailings. If the ferries have different accessibility features, adjust the wheelchair_accessible field accordingly.
6. Optional: Shape Definitions for Ferry Routes
If you want to map the actual geographic path of the ferry (instead of just straight lines between ports), use shapes.txt:
shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence SHAPE_AB,40.7128,-74.0060,1 SHAPE_AB,40.7218,-73.9996,2 SHAPE_AB,40.7308,-73.9973,3 SHAPE_BA,40.7308,-73.9973,1 SHAPE_BA,40.7218,-73.9996,2 SHAPE_BA,40.7128,-74.0060,3
shape_pt_sequencedefines the order of points along the route- Use the same
shape_idfor trips that follow the same path
内容的提问来源于stack exchange,提问作者Titan

