@Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("[Candidate: "); builder.append(this.route.toString()); builder.append(", Cost: "); builder.append(this.cost); builder.append("]"); return builder.toString(); }
public Iterable<LocationIterableProperties> asGeoJsonRestrictedPath() { return this.turnRestrictions().stream() .map(turnRestriction -> new LocationIterableProperties( turnRestriction.getRoute().asPolyLine(), Maps.hashMap("highway", "motorway", "oneway", "yes", "route", turnRestriction.getRoute().toString()))) .collect(Collectors.toList()); }
@Test public void testTurnRestrictionsFromComplexBigNodes() { final int expectedCountOfRestrictedRoutes = 302; // There's an only turn restriction (http://www.openstreetmap.org/relation/6643212) // specifying that 447301069000000 must go to 447301070000000. This route has a corner case // where an otherToOption (-447301069000000) is found before the from edge. Specifically // check to make sure this path is restricted. final String expectedRestrictedRoute = "[Route: 447301065000000, -447301070000000, -447301069000000, 447301069000000, 447301074000000, 447301068000000, 338286211000000]"; final Atlas complexBigNodeAtlas = this.rule.getBigNodeWithOnlyTurnRestrictionsAtlas(); final List<Route> restrictedRoutes = StreamSupport .stream(new BigNodeFinder().find(complexBigNodeAtlas, Finder::ignore).spliterator(), false) .filter(bigNode -> bigNode.getType() == BigNode.Type.DUAL_CARRIAGEWAY) .flatMap(bigNode -> bigNode.turnRestrictions().stream()) .map(RestrictedPath::getRoute).collect(Collectors.toList()); Assert.assertEquals("Verify that the expected number of restricted routes is returned", expectedCountOfRestrictedRoutes, restrictedRoutes.size()); Assert.assertTrue("Verify that this explicit restricted path is returned", restrictedRoutes .stream().anyMatch(route -> route.toString().equals(expectedRestrictedRoute))); }