Closed
Description
Complete the below when receiving a research request, and continue to add to this issue as you receive additional details and produce deliverables. Be sure to also add the appropriate project-level label to this issue (eg gtfs-rt, DLA).
Research Question
Single sentence description: Handle inlining / loopy edge cases correctly while cutting segments. shapely.project
will not give us clean chunks to easily slice up a shape's geometry for these edge cases Add a "super project" function to do it in with more detail (consider prior and subsequent stops while dealing with current stop).
- Epic: Epic - Daskify RT segment speeds #592
- Related to Research Request - Segment-trip speed diagnostics #594
(3) How are routes that inline / loop handled?
- Related to Research Request - aggregate stop-level metrics by segment #663: stop-level metrics incorrectly aggregated because of edge cases.
Detailed description:
- Set up shapes and stops to be comprised of 3 points and draw a vector / arrow from it
- For a stop of interest, we look to the prior and subsequent stop to get at directionality
- vectors:
vec1.x = (x2-x1)
andvec1.y = (y2-y1)
...use projected CRS to take difference --stop vector
- do the same for
vec2
--shape vector
- Take dot product:
vec1.x*vec2.x + vec1.y*vec2.y
- Dot product
- +1 / >0: same direction
- -1 / <0: opposite direction
- 0 = orthogonal
- retry if it is not positive (0 or negative) after removing these erroneous coords from the shape geom. anticipate we should only retry a couple times.
loop_utils
currently identifies these edge cases, but potentially needs to be expanded because it's looking at a stop being revisited. This might not identify all the possible inlining if it's not revisiting the samestop_id
while on the same trip. Expand function to identify our universe of cases.
How will this research be used?
Use this to correctly slice up stop-to-stop segments.
Deliverables:
- Add a script to handle these edge cases for cutting stop segments.
- TODO: check how vehicle positions end up attaching to these correctly cut segments. We might want to tighten the buffer then for these cases.
- Note: Greg Newmark's paper: spatial accuracy. 50m necessary for freeways, but for local roads, something like 20m can grab most of the points (for the select operators he looked at).