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

Take routing algorithm factory out of PrepareContractionHierarchies #1819

Merged
merged 23 commits into from
Dec 11, 2019

Conversation

easbar
Copy link
Member

@easbar easbar commented Dec 5, 2019

This PR puts the CH algorithm factory into a separate class instead of making PrepareContractionHierarchies a routing algorithm factory. With this change I was able to change the PrepareContractionHierarchies constructor to what I think it should look like now:

PrepareContractionHierarchies(GraphHopperStorage graph, CHProfile chProfile);

We get the base graph (GraphHopperStorage) and a CHProfile and our goal is to create a CH preparation (a CHGraph currently) for this profile on the base graph. This is all this class should be concerned with. Creating an algorithm on an already prepared CH graph is another story and now done in CHRoutingAlgorithmFactory. I still kept PrepareContractionHierarchies#getRoutingAlgorithmFactory() for convenience for now.

# Conflicts:
#	core/src/main/java/com/graphhopper/routing/ch/NodeBasedNodeContractor.java
# Conflicts:
#	core/src/main/java/com/graphhopper/routing/ch/EdgeBasedNodeContractor.java
#	core/src/main/java/com/graphhopper/routing/ch/EdgeBasedWitnessPathSearcher.java
#	core/src/test/java/com/graphhopper/routing/ch/EdgeBasedWitnessPathSearcherTest.java
# Conflicts:
#	core/src/test/java/com/graphhopper/routing/ch/PrepareContractionHierarchiesTest.java
Copy link
Member

@karussell karussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I still kept PrepareContractionHierarchies#getRoutingAlgorithmFactory() for convenience for now.

Ah, ok. This looks a bit strange but not too bad :)

}

private TurnWeighting createTurnWeightingForEdgeBased(Graph graph) {
// important: do not simply take the turn cost storage from ghStorage, because we need the wrapped storage from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what this comment was meant for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If graph is a QueryGraph (not just a CHGraph) we have to use QueryGraphTurnCostStorage which provides some special handling for virtual nodes (do not apply turn costs) and converts the virtual edge ids to the underlying real edge ids before getting the turn costs from the actual turn cost storage. This is a problem also for #1820, because it means that TurnWeighting is not just another Weighting but it uses information that is only available after the query graph has been constructed. This works because currently we always create a TurnWeighting for each request (compared to the Weighting objects that always live in CHDecorator/CHProfile), but if we want to include calcTurnWeight etc. in Weighting this is a problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I understand - thanks!

This is a problem also for #1820

Yeah, I stumbled over this already in #1775

it means that TurnWeighting is not just another Weighting but it uses information that is only available after the query graph has been constructed

This is interesting. The BlockAreaWeighting is similar: it requires a query graph. But when I thought about it in more detail I found that it could use a base graph and just throw an exception if query points are inside the blocked areas, which should help to resolve the dependency problem (QueryGraph->BlockAreaWeighting, LocationIndex->BlockAreaWeighting and LocationIndex->QueryGraph).

but if we want to include calcTurnWeight etc. in Weighting this is a problem.

You mean for CH this is a problem? Because for non-CH we already create a Weighting per request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean for CH this is a problem? Because for non-CH we already create a Weighting per request.

Yes I meant for CH (or at least this is the one place where I know its problematic, not sure if there are other places).

@easbar easbar mentioned this pull request Dec 11, 2019
@easbar easbar merged commit 498e00d into master Dec 11, 2019
@karussell karussell added this to the 1.0 milestone Dec 11, 2019
@easbar easbar deleted the ch_routing_algo_factory branch December 13, 2019 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants