Skip to content

Commit

Permalink
fix NPE in CH preparation with GenericWeighting (graphhopper#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
boldtrn authored and karussell committed Dec 10, 2016
1 parent 776fdb2 commit fa94e48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public String getName() {
* Use this method to associate a graph with this weighting to calculate e.g. node locations too.
*/
public void setGraph(Graph graph) {
if(graph == null)
return;
this.na = graph.getNodeAccess();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,11 @@ public void testCalcTime() {
EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1);
assertEquals(edgeWeight, weighting.calcMillis(edge, false, EdgeIterator.NO_EDGE), .1);
}

@Test
public void testNullGraph() {
ConfigMap cMap = encoder.readStringMap(new PMap());
GenericWeighting weighting = new GenericWeighting(encoder, cMap);
weighting.setGraph(null);
}
}

0 comments on commit fa94e48

Please sign in to comment.