-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculating graphs on this #67
Comments
Hello 👋
By "static distances", do you mean geographic distance (i.e. length of the path the trip takes, e.g. in meters) or travel time from A to B? total geographic extent of a trip's shapeAssuming that your GTFS dataset's
However, geographic distance of a trip's shape between two stops
This sounds more as if you want to measure the trip's shape's geographic "length" between two adjacent stops. Note that, according to the GTFS Schedule spec, the shape doesn't have to visit the stops exactly:
The best approach is to find the point that's closest to each stop (using WITH
stop_a AS (
SELECT *
FROM stops
WHERE stop_id = 'stop A ID'
),
stop_b AS (
SELECT *
FROM stops
WHERE stop_id = 'stop B ID'
)
SELECT
trip_id,
ST_Length(ST_LineSubstring(
shape::geography,
ST_LineLocatePoint(shape::geography, stop_a.stop_loc),
ST_LineLocatePoint(shape::geography, stop_b.stop_loc)
)) AS segment_length
FROM stop_a, stop_b, trips
JOIN shapes_aggregated ON shapes_aggregated.shape_id = trips.shape_id
WHERE trip_id = 'some trip ID' If you don't already have a travel time between on a trip between two stops
For time-unexpanded access, you can use WITH
stop_time_a AS (
SELECT
coalesce(departure_time, arrival_time) AS time
FROM stop_times
WHERE stop_id = 'stop A ID'
AND trip_id = 'some trip ID'
),
stop_time_b AS (
SELECT
coalesce(arrival_time, departure_time) AS time
FROM stop_times
WHERE stop_id = 'stop B ID'
AND trip_id = 'some trip ID'
)
SELECT
stop_time_b.time - stop_time_a.time AS travel_time
FROM stop_time_a, stop_time_b If you don't already have a |
If your dataset doesn't have correct shapes, you can estimate them using pfaedle. |
Hey, What I was personally talking about was the distance in time. To your answer: So, will skip over the geographical answer and go directly to travel time. I assume I do not need the shapes.txt at all for my use case. I guess if I want to do this for the entire graph, I should use the time-_un_expanded data and run your query above for all pairs of stops? |
Hello. This project is a really amazing one, thank you for sharing this with us.
I was wondering about if it is actually possible to calculate static distances on a database in a smart way? It would be similar to your old generate-vbb-graph project.
I would like to end up with a bunch of edge-times describing how long it takes between pairs of stations which are directly connected with a line and no station in between.
I guess I will have to come up with a smart solution here, but I was wondering if you already are aware of some function doing this already? My first hunch after checking some of the views and the docs is that one could flatten out the
connections
view somehow?So this is actually not an issue, but I could find a help section in the readme.
Thanks in advance!
The text was updated successfully, but these errors were encountered: