BlinkTagInc / gtfs-to-geojson

Generate geoJSON of transit route data from a GTFS file.
MIT License
114 stars 23 forks source link

Does this lib generate lines geojson when no shapes.txt is present ? #24

Closed laem closed 6 months ago

laem commented 6 months ago

Hi, I'm having a hard time to determine if this is the case.

My use case is a GTFS that has no shapes. So I'd like to create approximate geojson based on routes -> trips -> stopTimes -> stops coords.

When I run the tool, it gives me an empty geojson.

Thanks for your work.

brendannee commented 6 months ago

Can you share the GTSF you are using with me so I can try? I'll update the library so that it can handle this type of GTFS.

laem commented 6 months ago

This line of code makes me think it's not the case. https://github.com/BlinkTagInc/gtfs-to-geojson/blob/master/lib/formats/lines.js#L6

laem commented 6 months ago

This GTFS https://transport.data.gouv.fr/datasets/horaires-des-tgv

France's high speed trains.

Direct link to the zip file https://eu.ftp.opendatasoft.com/sncf/gtfs/export_gtfs_voyages.zip

laem commented 6 months ago

When I check the .txt files manually, it looks like it should be possible. Routes, trips, stopTimes, stops are present with coords.

image

laem commented 6 months ago

But it looks to me like building geojson from a zip without shapes is not coded yet in node-gtfs ?

laem commented 6 months ago

This lib might be the best option to do that https://github.com/ad-freiburg/pfaedle.

Maybe just mention it clearly in the docs :) ?

laem commented 6 months ago

Done here in a naïve form https://github.com/laem/gtfs/blob/master/server.js#L57

brendannee commented 6 months ago

Thanks for pointing this out.

I released a new version 3.5.0 https://github.com/BlinkTagInc/gtfs-to-geojson/releases/tag/3.5.0 which handles GTFS with no shapes.txt by falling back to getting all stops and drawing straight lines between them. It uses toposort to determine the correct order of stops for routes that have trips which vary and falls back to just using the trip with the most stop times if that doesn't work.

Check it out and let me know what you think.

laem commented 6 months ago

Awesome, thanks, I'll try. It will provide better results than my algo I guess :) Should it also be included in node-GTFS's getShapesAsGeojson ?

laem commented 6 months ago

It did work. This is the ouput of your lib.

image

This is my algo :

image

Note : one is not better than another. Depends on the UX we want. The first is cleaner, but the second tells us that a direct from Paris to Toulouse exists :)

I'm going to try to play with the opacity of routes depending on their frequencies.