google / transitfeed

A Python library for reading, validating, and writing transit schedule information in the GTFS format.
https://github.com/google/transitfeed/wiki
Apache License 2.0
680 stars 253 forks source link

hello,I want to add shape,but the trip haven't the shape_id #422

Open pengjin0609 opened 7 years ago

pengjin0609 commented 7 years ago

when I add shape_point by using addpoint and create zip but

the trip.txt haven't shape_id

kyleingraham commented 6 years ago

You must first create a shape: shape = transitfeed.Shape(shape_id="my_shape")

Then you need to add shape points: shape.AddPoint(lat=25.0754225104636, lon=-77.3429507017135)

Once your shape is complete add it to a schedule: schedule = transitfeed.Schedule() schedule.AddShapeObject(shape)

And finally, associate your shape with a trip: route = schedule.AddRoute(short_name="1A", long_name="Route 1A", route_type="Bus", route_id="R1A") trip = route.AddTrip(schedule=schedule, trip_id="my_trip") trip.shape_id = "my_shape"

Once you perform the above steps you will see the shape listed with the associated trip in your trips.txt file.