package org.opentrafficsim.demo.geometry; import java.awt.Color; import java.rmi.RemoteException; import javax.naming.NamingException; import nl.tudelft.simulation.dsol.SimRuntimeException; import nl.tudelft.simulation.dsol.simulators.SimulatorInterface; import org.djunits.unit.TimeUnit; import org.djunits.unit.UNITS; import org.djunits.value.vdouble.scalar.DoubleScalar.Abs; import org.djunits.value.vdouble.scalar.DoubleScalar.Rel; import org.djunits.value.vdouble.scalar.Length; import org.djunits.value.vdouble.scalar.Speed; import org.opentrafficsim.core.dsol.OTSModelInterface; import org.opentrafficsim.core.dsol.OTSSimTimeDouble; import org.opentrafficsim.core.dsol.OTSSimulatorInterface; import org.opentrafficsim.core.geometry.OTSGeometryException; import org.opentrafficsim.core.geometry.OTSLine3D; import org.opentrafficsim.core.geometry.OTSPoint3D; import org.opentrafficsim.core.network.LinkType; import org.opentrafficsim.core.network.LongitudinalDirectionality; import org.opentrafficsim.core.network.NetworkException; import org.opentrafficsim.core.network.OTSNode; import org.opentrafficsim.road.network.animation.LaneAnimation; import org.opentrafficsim.road.network.animation.ShoulderAnimation; import org.opentrafficsim.road.network.lane.CrossSectionLink; import org.opentrafficsim.road.network.lane.Lane; import org.opentrafficsim.road.network.lane.NoTrafficLane; import org.opentrafficsim.road.network.lane.Shoulder; import org.opentrafficsim.road.network.lane.changing.LaneKeepingPolicy; import org.opentrafficsim.road.network.lane.changing.OvertakingConditions; /** *
* Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* $LastChangedDate$, @version $Revision$, by $Author$,
* initial version ct 17, 2014
* @author Alexander Verbraeck
*/
/** */
public class TestModel implements OTSModelInterface, UNITS
{
/** */
private static final long serialVersionUID = 1L;
/** simulator. */
private OTSSimulatorInterface simulator;
/** {@inheritDoc} */
@Override
public final void
constructModel(final SimulatorInterface
* ----------------------- +9.50
* SSSSS Shoulder SL SSSSS +9.00 (width = 1.0)
* ----------------------- +8.50
* EEEEE Emergency ELL EEE +8.25 (width = 0.5)
* ----------------------- +8.00
* LLLLL Lane L1 LLLLLLLLL +6.25 (width = 3.5)
* ----------------------- +4.50
* LLLLL Lane L2 LLLLLLLLL +2.75 (width = 3.5)
* ----------------------- +1.00
* EEEEE Emergency ELM EEE +0.75 (width = 0.5)
* ----------------------- +0.50
* SSSSS Shoulder SM SSSSS +0.00 (width = 1.0)
* ----------------------- -0.50
* EEEEE Emergency ERM EEE -0.75 (width = 0.5)
* ----------------------- -1.00
* LLLLL Lane R2 LLLLLLLLL -2.75 (width = 3.5)
* ----------------------- -4.50
* LLLLL Lane R1 LLLLLLLLL -6.25 (width = 3.5)
* ----------------------- -8.00
* EEEEE Emergency ERR EEE -8.25 (width = 0.5)
* ----------------------- -8.50
* SSSSS Shoulder SR SSSSS -9.00 (width = 1.0)
* ----------------------- -9.50
*
*
*
* @param link link.
* @throws NetworkException on network inconsistency
* @throws OTSGeometryException on network inconsistency
*/
private void add2x2Lanes(final CrossSectionLink link) throws NetworkException, OTSGeometryException
{
// four lanes, grass underneath, lines between lane1-2 and lane 2-3, barrier between lane 2-3
// lane is 3.5 meters wide. gap between 3-4 is one meter. outside 0.5 meters on both sides
Length.Rel m05 = new Length.Rel(0.5, METER);
Length.Rel m10 = new Length.Rel(1.0, METER);
Length.Rel m35 = new Length.Rel(3.5, METER);
Speed speedLimit = new Speed(100, KM_PER_HOUR);
Shoulder sL = new Shoulder(link, "sL", new Length.Rel(9.0, METER), m10);
Lane laneELL =
new NoTrafficLane(link, "ELL", new Length.Rel(8.25, METER), new Length.Rel(8.25, METER), m05, m05);
Lane laneL1 =
new Lane(link, "L1", new Length.Rel(6.25, METER), new Length.Rel(6.25, METER), m35, m35, null,
LongitudinalDirectionality.DIR_MINUS, speedLimit, new OvertakingConditions.LeftAndRight());
Lane laneL2 =
new Lane(link, "L2", new Length.Rel(2.75, METER), new Length.Rel(2.75, METER), m35, m35, null,
LongitudinalDirectionality.DIR_MINUS, speedLimit, new OvertakingConditions.LeftAndRight());
Lane laneELM =
new NoTrafficLane(link, "ELM", new Length.Rel(0.75, METER), new Length.Rel(0.75, METER), m05, m05);
Shoulder sM = new Shoulder(link, "sM", new Length.Rel(0.0, METER), m10);
Lane laneERM =
new NoTrafficLane(link, "ERM", new Length.Rel(-0.75, METER), new Length.Rel(-0.75, METER), m05, m05);
Lane laneR2 =
new Lane(link, "R2", new Length.Rel(-2.75, METER), new Length.Rel(-2.75, METER), m35, m35, null,
LongitudinalDirectionality.DIR_PLUS, speedLimit, new OvertakingConditions.LeftAndRight());
Lane laneR1 =
new Lane(link, "R1", new Length.Rel(-6.25, METER), new Length.Rel(-6.25, METER), m35, m35, null,
LongitudinalDirectionality.DIR_PLUS, speedLimit, new OvertakingConditions.LeftAndRight());
Lane laneERR =
new NoTrafficLane(link, "ERR", new Length.Rel(-8.25, METER), new Length.Rel(-8.25, METER), m05, m05);
Shoulder sR = new Shoulder(link, "sR", new Length.Rel(-9.0, METER), m10);
try
{
new LaneAnimation(laneELL, this.simulator, Color.GRAY, false);
new LaneAnimation(laneL1, this.simulator, Color.GRAY, false);
new LaneAnimation(laneL2, this.simulator, Color.GRAY, false);
new LaneAnimation(laneELM, this.simulator, Color.GRAY, false);
new LaneAnimation(laneERM, this.simulator, Color.GRAY, false);
new LaneAnimation(laneR2, this.simulator, Color.GRAY, false);
new LaneAnimation(laneR1, this.simulator, Color.GRAY, false);
new LaneAnimation(laneERR, this.simulator, Color.GRAY, false);
new ShoulderAnimation(sL, this.simulator, Color.GREEN);
new ShoulderAnimation(sM, this.simulator, Color.GREEN);
new ShoulderAnimation(sR, this.simulator, Color.GREEN);
}
catch (NamingException | RemoteException ne)
{
//
}
}
/** {@inheritDoc} */
@Override
public final SimulatorInterface