Skip to content
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

Saving shape information in network.dat (r5r) #751

Open
mvpsaraiva opened this issue Sep 26, 2021 · 2 comments · May be fixed by #945
Open

Saving shape information in network.dat (r5r) #751

mvpsaraiva opened this issue Sep 26, 2021 · 2 comments · May be fixed by #945

Comments

@mvpsaraiva
Copy link

R5 currently doesn’t save shape information into the network.dat, which is useful for PointToPointQuery used by r5r’s detailed_itineraries() function. This could be easily changed in this line, by making SAVE_SHAPES not final so we could change it at runtime from r5r.

Perhaps if you prefer a more robust implementation, like passing a parameter via TNBuilderConfig (#644), I'm happy to help.

@ansoncfit
Copy link
Member

Thanks, @mvpsaraiva.

Including saveShapes as an option in a new networkBuildConfig would be interesting. Beyond PointToPoint mode, this could also allow for more precise path display in Conveyal's publishable stakeholder engagement sites. Without saving shapes, these sites fall back to stop-to-stop lines:

if (shape != null) {
// This pattern has a shape. Using the segment indexes and segment fractions that were recorded for each
// stop when the R5 network was built, split that shape up into segments between each pair of stops.
LocationIndexedLine unprojectedLine = new LocationIndexedLine(shape);
for (int stopPos = 0; stopPos < stops.length - 1; stopPos++) {
LinearLocation fromLocation =
new LinearLocation(stopShapeSegment[stopPos], stopShapeFraction[stopPos]);
LinearLocation toLocation =
new LinearLocation(stopShapeSegment[stopPos + 1], stopShapeFraction[stopPos + 1]);
geometries.add((LineString)unprojectedLine.extractLine(fromLocation, toLocation));
}
} else {
// This pattern does not have a shape, but Transitive expects geometries. Use straight lines between stops.

@abyrd
Copy link
Member

abyrd commented Sep 28, 2021

I think this constant SAVE_SHAPES exists because we had the functionality to save shapes and didn't need it for any current use case, but we didn't want to remove the code, expecting we would have use cases in the future. It is just a hardcoded placeholder parameter. It makes sense to me to promote this to a TNBuilderConfig field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants