@Override public EdgeIteratorState edge(int a, int b) { return baseGraph.getEdgeIteratorState(a, b); }
private CHEdgeIteratorState getEdge(int edgeId, int adjNode) { return (CHEdgeIteratorState) routingGraph.getEdgeIteratorState(edgeId, adjNode); } }
@Override public EdgeIteratorState getEdgeIteratorState(int edgeId, int adjNode) { return baseGraph.getEdgeIteratorState(edgeId, adjNode); }
static List<String> getAltNames(Graph graph, SPTEntry ee) { if (ee == null || !EdgeIterator.Edge.isValid(ee.edge)) return Collections.emptyList(); EdgeIteratorState iter = graph.getEdgeIteratorState(ee.edge, Integer.MIN_VALUE); if (iter == null) return Collections.emptyList(); String str = iter.getName(); if (str.isEmpty()) return Collections.emptyList(); return Collections.singletonList(str); }
@Override public int doCalc(boolean warmup, int run) { while (true) { int edgeId = rand.nextInt(maxEdgesId); if (allowedEdges.contains(edgeId)) return graph.getEdgeIteratorState(edgeId, Integer.MIN_VALUE).getEdge(); } } }.setIterations(count).start();
/** * Yields the final edge of the path */ public EdgeIteratorState getFinalEdge() { return graph.getEdgeIteratorState(edgeIds.get(edgeIds.size() - 1), endNode); }
public static int getAdjNode(Graph g, int edge, int adjNode) { if (EdgeIterator.Edge.isValid(edge)) { EdgeIteratorState iterTo = g.getEdgeIteratorState(edge, adjNode); return iterTo.getAdjNode(); } return adjNode; }
EdgeIteratorState getEdgeIteratorState(int edgeId, int adjNode) { if (edgeId == -1) { throw new RuntimeException(); } for (EdgeIteratorState extraEdge : extraEdges) { if (extraEdge.getEdge() == edgeId) { if (extraEdge.getAdjNode() != adjNode) { throw new IllegalStateException(); } return extraEdge; } } EdgeIteratorState edge = graph.getEdgeIteratorState(edgeId, adjNode); if (edge.getAdjNode() != adjNode) { throw new IllegalStateException(); } return edge; }
@Override public EdgeIteratorState getEdgeIteratorState(int origEdgeId, int adjNode) { if (!isVirtualEdge(origEdgeId)) return mainGraph.getEdgeIteratorState(origEdgeId, adjNode); int edgeId = origEdgeId - mainEdges; EdgeIteratorState eis = virtualEdges.get(edgeId); if (eis.getAdjNode() == adjNode || adjNode == Integer.MIN_VALUE) return eis; edgeId = getPosOfReverseEdge(edgeId); EdgeIteratorState eis2 = virtualEdges.get(edgeId); if (eis2.getAdjNode() == adjNode) return eis2; throw new IllegalStateException("Edge " + origEdgeId + " not found with adjNode:" + adjNode + ". found edges were:" + eis + ", " + eis2); }
/** * Calculates the distance and time of the specified edgeId. Also it adds the edgeId to the path list. * * @param prevEdgeId here the edge that comes before edgeId is necessary. I.e. for the reverse search we need the * next edge. */ protected void processEdge(int edgeId, int adjNode, int prevEdgeId) { EdgeIteratorState iter = graph.getEdgeIteratorState(edgeId, adjNode); distance += iter.getDistance(); time += weighting.calcMillis(iter, false, prevEdgeId); addEdge(edgeId); }
/** * Iterates over all edges in this path sorted from start to end and calls the visitor callback * for every edge. * <p> * * @param visitor callback to handle every edge. The edge is decoupled from the iterator and can * be stored. */ private void forEveryEdge(EdgeVisitor visitor) { int tmpNode = getFromNode(); int len = edgeIds.size(); int prevEdgeId = EdgeIterator.NO_EDGE; for (int i = 0; i < len; i++) { EdgeIteratorState edgeBase = graph.getEdgeIteratorState(edgeIds.get(i), tmpNode); if (edgeBase == null) throw new IllegalStateException("Edge " + edgeIds.get(i) + " was empty when requested with node " + tmpNode + ", array index:" + i + ", edges:" + edgeIds.size()); tmpNode = edgeBase.getBaseNode(); // more efficient swap, currently not implemented for virtual edges: visitor.next(edgeBase.detach(true), i); edgeBase = graph.getEdgeIteratorState(edgeBase.getEdge(), tmpNode); visitor.next(edgeBase, i, prevEdgeId); prevEdgeId = edgeBase.getEdge(); } visitor.finish(); }
while (iter.hasNext()) { int edgeId = iter.next().value; EdgeIteratorState edge = graph.getEdgeIteratorState(edgeId, Integer.MIN_VALUE); if (props.containsKey("access")) { boolean value = (boolean) props.get("access");
@Test public void testCalcTime() { GenericWeighting weighting = new GenericWeighting(encoder, new HintsMap()); EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1); assertEquals(edgeWeight, weighting.calcMillis(edge, false, EdgeIterator.NO_EDGE), .1); }
@Before public void setUp() { ReaderWay way = new ReaderWay(27l); way.setTag("highway", "primary"); way.setTag("maxspeed", "10"); way.setTag("maxheight", "4.4"); graph = new GraphBuilder(em).create(); // 0-1 graph.edge(0, 1, 1, true); AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 0, 0.00, 0.00); AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 1, 0.01, 0.01); graph.getEdgeIteratorState(0, 1).setFlags(encoder.handleWayTags(way, 1, 0)); }
@Test public void testDisabledRoadAttributes() { DataFlagEncoder simpleEncoder = new DataFlagEncoder(); EncodingManager simpleEncodingManager = new EncodingManager(simpleEncoder); Graph simpleGraph = new GraphBuilder(simpleEncodingManager).create(); ReaderWay way = new ReaderWay(27l); way.setTag("highway", "primary"); way.setTag("maxspeed", "10"); way.setTag("maxheight", "4.4"); // 0-1 simpleGraph.edge(0, 1, 1, true); AbstractRoutingAlgorithmTester.updateDistancesFor(simpleGraph, 0, 0.00, 0.00); AbstractRoutingAlgorithmTester.updateDistancesFor(simpleGraph, 1, 0.01, 0.01); simpleGraph.getEdgeIteratorState(0, 1).setFlags(simpleEncoder.handleWayTags(way, 1, 0)); Weighting instance = new GenericWeighting(simpleEncoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 5.0)); EdgeIteratorState edge = simpleGraph.getEdgeIteratorState(0, 1); assertEquals(edgeWeight, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8); } }
@Test public void testRoadAttributeRestriction() { EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1); Weighting instance = new GenericWeighting(encoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 4.0)); assertEquals(edgeWeight, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8); instance = new GenericWeighting(encoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 5.0)); assertEquals(Double.POSITIVE_INFINITY, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8); }
@Test public void testBlockedById() { GraphEdgeIdFinder.BlockArea bArea = new GraphEdgeIdFinder.BlockArea(graph); EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1); BlockAreaWeighting instance = new BlockAreaWeighting(new FastestWeighting(encoder), bArea); assertEquals(94.35, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), .01); bArea.add(0); instance = new BlockAreaWeighting(new FastestWeighting(encoder), bArea); assertEquals(Double.POSITIVE_INFINITY, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), .01); }
@Test public void testBlockedByShape() { EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1); GraphEdgeIdFinder.BlockArea bArea = new GraphEdgeIdFinder.BlockArea(graph); BlockAreaWeighting instance = new BlockAreaWeighting(new FastestWeighting(encoder), bArea); assertEquals(94.35, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 0.01); bArea.add(new Circle(0.01, 0.01, 100)); assertEquals(Double.POSITIVE_INFINITY, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), .01); bArea = new GraphEdgeIdFinder.BlockArea(graph); instance = new BlockAreaWeighting(new FastestWeighting(encoder), bArea); // Do not match 1,1 of edge bArea.add(new Circle(0.1, 0.1, 100)); assertEquals(94.35, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), .01); }
public static int getAdjNode(Graph g, int edge, int adjNode) { if (EdgeIterator.Edge.isValid(edge)) { EdgeIteratorState iterTo = g.getEdgeIteratorState(edge, adjNode); return iterTo.getAdjNode(); } return adjNode; }
/** * Calls getDistance and adds the edgeId. */ protected void processEdge( int edgeId, int adjNode ) { EdgeIteratorState iter = graph.getEdgeIteratorState(edgeId, adjNode); double dist = iter.getDistance(); distance += dist; time += calcMillis(dist, iter.getFlags(), false); addEdge(edgeId); }