@Override public void serialize(InstructionList instructions, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeObject(instructions.createJson()); } }
/** * case starting in Roundabout */ @Test public void testCalcInstructionsRoundaboutBegin() { Path p = new Dijkstra(roundaboutGraph.g, new ShortestWeighting(encoder), TraversalMode.NODE_BASED) .calcPath(2, 8); assertTrue(p.isFound()); InstructionList wayList = p.calcInstructions(tr); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("At roundabout, take exit 3 onto 5-8", "Arrive at destination"), tmpList); }
List<Map<String, Object>> res = instr.createJson(); Map<String, Object> tmp = res.get(0); assertEquals(3000.0, tmp.get("distance")); path.extract(); instr = path.calcInstructions(tr); res = instr.createJson(); res = instr.createJson(); tmp = res.get(0); assertEquals(2000.0, tmp.get("distance"));
/** * case with one node being containig already exit */ @Test public void testCalcInstructionsRoundaboutDirectExit() { roundaboutGraph.inverse3to9(); Path p = new Dijkstra(roundaboutGraph.g, new ShortestWeighting(encoder), TraversalMode.NODE_BASED) .calcPath(6, 8); assertTrue(p.isFound()); InstructionList wayList = p.calcInstructions(tr); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto 3-6", "At roundabout, take exit 3 onto 5-8", "Arrive at destination"), tmpList); roundaboutGraph.inverse3to9(); }
/** * clockwise roundabout */ @Test public void testCalcInstructionsRoundaboutClockwise() { roundaboutGraph.setRoundabout(true); Path p = new Dijkstra(roundaboutGraph.g, new ShortestWeighting(encoder), TraversalMode.NODE_BASED) .calcPath(1, 8); assertTrue(p.isFound()); InstructionList wayList = p.calcInstructions(tr); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto MainStreet 1 2", "At roundabout, take exit 1 onto 5-8", "Arrive at destination"), tmpList); // Test Radian double delta = roundaboutGraph.getAngle(1, 2, 5, 8); RoundaboutInstruction instr = (RoundaboutInstruction) wayList.get(1); assertEquals(delta, instr.getTurnAngle(), 0.01); }
/** * case with one edge being not an exit */ @Test public void testCalcInstructionsRoundabout2() { roundaboutGraph.inverse3to6(); Path p = new Dijkstra(roundaboutGraph.g, new ShortestWeighting(encoder), TraversalMode.NODE_BASED) .calcPath(1, 8); assertTrue(p.isFound()); InstructionList wayList = p.calcInstructions(tr); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto MainStreet 1 2", "At roundabout, take exit 2 onto 5-8", "Arrive at destination"), tmpList); // Test Radian double delta = roundaboutGraph.getAngle(1, 2, 5, 8); RoundaboutInstruction instr = (RoundaboutInstruction) wayList.get(1); assertEquals(delta, instr.getTurnAngle(), 0.01); roundaboutGraph.inverse3to6(); }
InstructionList wayList = p.calcInstructions(tr); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto MainStreet 1 2", "At roundabout, take exit 3 onto 5-8", calcPath(1, 7); wayList = p.calcInstructions(tr); tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto MainStreet 1 2", "At roundabout, take exit 2 onto MainStreet 4 7",
List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto 2-4", "Turn slight right onto 3-4", "Arrive at destination"), tmpList); tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto 3-4", "Keep right onto 4-5", "Arrive at destination"), tmpList);
@Test public void testNoInstructionIfSameStreet() { Graph g = new GraphBuilder(carManager).create(); // 2 // \. 5 // \/ // 4 // / // 3 NodeAccess na = g.getNodeAccess(); na.setNode(2, 10.3, 10.15); na.setNode(3, 10.0, 10.05); na.setNode(4, 10.1, 10.10); na.setNode(5, 10.2, 10.15); g.edge(3, 4, 100, true).setName("street"); g.edge(4, 5, 100, true).setName("4-5"); EdgeIteratorState iter = g.edge(2, 4, 100, true); iter.setName("street"); PointList list = new PointList(); list.add(10.20, 10.05); iter.setWayGeometry(list); Path p = new Dijkstra(g, new ShortestWeighting(carEncoder), tMode).calcPath(2, 3); InstructionList wayList = p.calcInstructions(usTR); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto street", "Turn right onto street", "Arrive at destination"), tmpList); }
List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto 0-1", "Turn right onto 1-4", "Turn left onto 7-8", "Arrive at destination"), tmpList); tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Dem Straßenverlauf von 0-1 folgen", "Rechts abbiegen auf 1-4", "Links abbiegen auf 7-8", "Ziel erreicht"), tmpList); tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("Continue onto 6-7", "Turn left onto 5-8", "Arrive at destination"), tmpList);
@Override public void serialize(InstructionList instructions, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeObject(instructions.createJson()); } }
assertTrue(p.isFound()); InstructionList wayList = p.calcInstructions(tr); List<String> tmpList = pick("text", wayList.createJson()); assertEquals(Arrays.asList("At roundabout, take exit 1 onto MainStreet 1 11", "Arrive at destination"),