RoadPath extends GraphPath<RoadPath, RoadSegment, RoadConnection> { @Pure public Iterator<CrossRoad> crossRoads() { return new CrossRoadIterator(); } protected  RoadPath(List<RoadSegment> original);  RoadPath();  RoadPath(RoadSegment segment);  RoadPath(RoadSegment segment, RoadConnection starting_point);  RoadPath(RoadPath path); static boolean addPathToPath(RoadPath inside, RoadPath elements); static RoadPath of(List<RoadSegment> original); @Override @Pure Object[] toArray(); @Pure Direction1D getSegmentDirectionAt(int index); @Pure boolean isConnectableTo(RoadPath path); @Pure RoadSegment getConnectableSegmentToFirstPoint(RoadPath path); @Pure RoadSegment getConnectableSegmentToLastPoint(RoadPath path); @Pure boolean isFirstPointConnectableTo(RoadPath path); @Pure boolean isLastPointConnectableTo(RoadPath path); @Pure boolean isCulDeSacWay(); @Pure RoadConnection getFirstCrossRoad(); @Pure CrossRoad getFirstJunctionPoint(); @Pure Iterator<CrossRoad> crossRoads();  }
@Test public void testCrossRoadsVoid_thru_segment6() { RoadPath path = new RoadPath(); path.add(this.segment3, this.segment3.getBeginPoint()); path.add(this.segment4); path.add(this.segment1); path.add(this.segment2); path.add(this.segment6, this.segment6.getEndPoint()); path.add(this.segment8); CrossRoad cross; double distance = this.segment3.getLength() +this.segment4.getLength() +this.segment1.getLength() +this.segment2.getLength(); Iterator<CrossRoad> iterator = path.crossRoads(); assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment2.getBeginPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(distance, cross.distanceFromPreviousCrossRoad); assertSame(this.segment2, cross.enteringSegment); assertSame(this.segment6, cross.exitingSegment); distance += this.segment6.getLength(); assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment6.getEndPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(this.segment6.getLength(), cross.distanceFromPreviousCrossRoad); assertSame(this.segment6, cross.enteringSegment); assertSame(this.segment8, cross.exitingSegment); distance += this.segment8.getLength(); assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment8.getBeginPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(this.segment8.getLength(), cross.distanceFromPreviousCrossRoad); assertSame(this.segment8, cross.enteringSegment); assertNull(cross.exitingSegment); assertFalse(iterator.hasNext()); }
@Test public void testCrossRoadsVoid_not_thru_segment6() { RoadPath path = new RoadPath(); path.add(this.segment3, this.segment3.getBeginPoint()); path.add(this.segment4); path.add(this.segment1); path.add(this.segment2); path.add(this.segment3); path.add(this.segment4); path.add(this.segment1); path.add(this.segment2); path.add(this.segment7); CrossRoad cross; double distance = this.segment3.getLength() +this.segment4.getLength() +this.segment1.getLength() +this.segment2.getLength(); Iterator<CrossRoad> iterator = path.crossRoads(); assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment2.getBeginPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(distance, cross.distanceFromPreviousCrossRoad); assertSame(this.segment2, cross.enteringSegment); assertSame(this.segment3, cross.exitingSegment); double deltaD = this.segment3.getLength() +this.segment4.getLength() +this.segment1.getLength() +this.segment2.getLength(); distance += deltaD; assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment2.getBeginPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(deltaD, cross.distanceFromPreviousCrossRoad); assertSame(this.segment2, cross.enteringSegment); assertSame(this.segment7, cross.exitingSegment); deltaD = this.segment7.getLength(); distance += deltaD; assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment7.getEndPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(deltaD, cross.distanceFromPreviousCrossRoad); assertSame(this.segment7, cross.enteringSegment); assertNull(cross.exitingSegment); assertFalse(iterator.hasNext()); }
@Test public void testCrossRoadsVoid_thru_segment11_with_culdesac() { RoadPath path = new RoadPath(); path.add(this.segment5, this.segment5.getBeginPoint()); path.add(this.segment10); path.add(this.segment10); path.add(this.segment11); CrossRoad cross; double deltaD = this.segment5.getLength(); double distance = deltaD; Iterator<CrossRoad> iterator = path.crossRoads(); assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment5.getEndPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(deltaD, cross.distanceFromPreviousCrossRoad); assertSame(this.segment5, cross.enteringSegment); assertSame(this.segment10, cross.exitingSegment); deltaD = this.segment10.getLength(); distance += deltaD; assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment10.getBeginPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(deltaD, cross.distanceFromPreviousCrossRoad); assertSame(this.segment10, cross.enteringSegment); assertSame(this.segment10, cross.exitingSegment); deltaD = this.segment10.getLength(); distance += deltaD; assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment10.getEndPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(deltaD, cross.distanceFromPreviousCrossRoad); assertSame(this.segment10, cross.enteringSegment); assertSame(this.segment11, cross.exitingSegment); deltaD = this.segment11.getLength(); distance += deltaD; assertTrue(iterator.hasNext()); cross = iterator.next(); assertNotNull(cross); assertEquals(this.segment11.getEndPoint(), cross.connectionPoint); assertEpsilonEquals(distance, cross.distance); assertEpsilonEquals(deltaD, cross.distanceFromPreviousCrossRoad); assertSame(this.segment11, cross.enteringSegment); assertNull(cross.exitingSegment); assertFalse(iterator.hasNext()); }