@Override public ImmutableSet<ModelBuilder<?, ?>> getModelBuilders() { return ImmutableSet.<ModelBuilder<?, ?>>builder() .add( TimeModel.builder() .withTickLength(1L) .withTimeUnit(NonSI.MINUTE)) .add( RoadModelBuilders.plane() .withMinPoint(getMin()) .withMaxPoint(getMax()) .withDistanceUnit(SI.KILOMETER) .withMaxSpeed(MAX_SPEED) .withSpeedUnit( SI.KILOMETRE.divide(NonSI.MINUTE).asType(Velocity.class))) .add( DefaultPDPModel.builder() .withTimeWindowPolicy(TimeWindowPolicies.TARDY_ALLOWED)) .add( StatsTracker.builder()) .build(); }
RoadModelBuilders.plane() .withMinPoint(MIN) .withMaxPoint(MAX) .withDistanceUnit(SI.KILOMETER) .withSpeedUnit(MAX_SPEED.getUnit())
/** * Tests that min and max points are correctly set (important because they are * both points). */ @Test public void testPlaneRMB() { final PlaneRMB b = RoadModelBuilders.plane() .withMinPoint(new Point(1, 1)) .withMaxPoint(new Point(2, 2)); assertThat(b.getMin()).isEqualTo(new Point(1, 1)); assertThat(b.getMax()).isEqualTo(new Point(2, 2)); final PlaneRoadModel prm = b.build(mock(DependencyProvider.class)); assertThat(prm.min).isEqualTo(b.getMin()); assertThat(prm.max).isEqualTo(b.getMax()); }
RoadModelBuilders.plane() .withMinPoint(MIN_POINT) .withMaxPoint(MAX_POINT) .withMaxSpeed(MAX_VEHICLE_SPEED_KMH)))
RoadModelBuilders.plane() .withMinPoint(MIN_POINT) .withMaxPoint(MAX_POINT) .withMaxSpeed(MAX_VEHICLE_SPEED_KMH)))
RoadModelBuilders.plane() .withMinPoint(MIN_POINT) .withMaxPoint(MAX_POINT) .withMaxSpeed(VEHICLE_SPEED_KMH))
RoadModelBuilders.plane() .withMinPoint(new Point(0, 0)) .withMaxPoint(new Point(10, 10)) .withDistanceUnit(SI.KILOMETER) .withMaxSpeed(0.1)
RoadModelBuilders.plane() .withMinPoint(MIN_POINT) .withMaxPoint(MAX_POINT) .withMaxSpeed(VEHICLE_SPEED_KMH))
plane().withMaxPoint(new Point(7, 7))); assertThat(stat).isEqualTo( staticGraph(new MultimapGraph<>()));
.addModel(RoadModelBuilders.plane() .withDistanceUnit(SI.CENTIMETER) .withMaxPoint(new Point(7d, 8.4)) .withMinPoint(new Point(-1, 3)) .withMaxSpeed(7d)
.addModel(RoadModelBuilders.plane() .withMinPoint(new Point(0, 0)) .withMaxPoint(new Point(10, 10)) .withMaxSpeed(10d)) .addModel(
.addModel(RoadModelBuilders.plane() .withMinPoint(MIN_POINT) .withMaxPoint(max) .withDistanceUnit(SI.METER) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR)
.addModel(RoadModelBuilders.plane() .withMinPoint(MIN_POINT) .withMaxPoint(max) .withDistanceUnit(SI.METER) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR)
RoadModelBuilders.plane() .withMinPoint(new Point(6, 6)) .withMaxPoint(new Point(1034, 32)) .withDistanceUnit(SI.METER) .withSpeedUnit(SI.METERS_PER_SECOND)
/** * Supplying the builder with illegal points should yield an exception. */ @Test public void builderIllegalPoints() { boolean fail = false; try { RoadModelBuilders.plane() .withMinPoint(new Point(1, 0)) .withMaxPoint(new Point(0, 1)) .build(mock(DependencyProvider.class)); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); fail = false; try { RoadModelBuilders.plane() .withMinPoint(new Point(0, 1)) .withMaxPoint(new Point(1, 0)) .build(mock(DependencyProvider.class)); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); }
/** * Creates a snapshot of a {@link PlaneRoadModel}. * @param minimum The minimum bound of the plane. * @param maximum The maximum bound of the plane. * @param planeDistanceUnit The distance unit of the model. * @return A snapshot with the desired properties. */ public static RoadModelSnapshot createPlaneRoadModelSnapshot( Point minimum, Point maximum, Unit<Length> planeDistanceUnit) { return new AutoValue_PlaneRoadModelSnapshot( new PlaneRoadModel(RoadModelBuilders.plane().withMinPoint(minimum) .withMaxPoint(maximum).withDistanceUnit(planeDistanceUnit))); }
@Override public GenericRoadModel create(ForwardingRoadModelTest testClass) { return new ForwardingRoadModel( RoadModelBuilders.plane() .withMinPoint(new Point(0, 0)) .withMaxPoint(new Point(10, 10)) .withDistanceUnit(SI.METER) .withSpeedUnit(SI.METERS_PER_SECOND) .withMaxSpeed(10d) .build(mock(DependencyProvider.class))); } }}, {new Creator() {
@Override public void doSetUp() { model = RoadModelBuilders.plane() .withMinPoint(new Point(0, 0)) .withMaxPoint(new Point(10, 10)) .withMaxSpeed(10d) .build(mock(DependencyProvider.class)); }