/** * Compute speed of the object taking into account the speed limits of the * object. * @param object traveling object * @param from The point on the graph the object is located * @param to The next point on the path it wants to reach * @return The maximum speed in the internal unit, must be ≥ 0. */ protected double getMaxSpeed(MovingRoadUser object, Point from, Point to) { final double objSpeed = unitConversion.toInSpeed(object.getSpeed()); if (!from.equals(to)) { final Connection<?> conn = getConnection(from, to); if (conn.data().isPresent() && conn.data().get() instanceof MultiAttributeData) { final MultiAttributeData maed = (MultiAttributeData) conn.data().get(); if (maed.getMaxSpeed().isPresent()) { return Math.min(unitConversion.toInSpeed(maed.getMaxSpeed().get()), objSpeed); } return objSpeed; } } return objSpeed; }
PlaneRoadModel(RoadModelBuilders.AbstractPlaneRMB<?, ?> b) { super(b.getDistanceUnit(), b.getSpeedUnit()); min = b.getMin(); max = b.getMax(); width = max.x - min.x; height = max.y - min.y; maxSpeed = unitConversion.toInSpeed(b.getMaxSpeed()); snapshot = PlaneRoadModelSnapshot.create(this); planeGraph = new PlaneGraph<>(); registry = MapSpatialRegistry.create(); }
final double speed = min(unitConversion.toInSpeed(object.getSpeed()), maxSpeed); if (speed == 0d) {