@Override public Measure<Double, Length> getDistanceOfPath(Iterable<Point> path) throws IllegalArgumentException { final List<Point> pathAsList = Lists.newArrayList(path); checkArgument(pathAsList.size() > 1, "Cannot evaluate the distance of a path with less than two points."); return Measure.valueOf(Graphs.pathLength(pathAsList), getDistanceUnit()); }
@Override public RoadPath getPathTo(Point from, Point to, Unit<Duration> timeUnit, Measure<Double, Velocity> speed, GeomHeuristic heuristic) { return RoadPath.create( asList(from, to), heuristic.calculateCost(planeGraph, from, to), heuristic.calculateTravelTime(planeGraph, from, to, getDistanceUnit(), speed, timeUnit)); }
/** * Tests that units are correctly set. */ @Test public void testAbstractRMBUnits() { final PlaneRoadModel prm = RoadModelBuilders.plane() .withDistanceUnit(NonSI.LIGHT_YEAR) .withSpeedUnit(NonSI.C) .build(mock(DependencyProvider.class)); assertThat(prm.getDistanceUnit()).isEqualTo(NonSI.LIGHT_YEAR); assertThat(prm.getSpeedUnit()).isEqualTo(NonSI.C); }
getDistanceUnit()); final Measure<Long, Duration> dur = Measure.valueOf(0L, time.getTimeUnit());