package org.opentrafficsim.demo.geometry; import java.awt.Color; import java.io.Serializable; import java.rmi.RemoteException; import javax.naming.NamingException; import org.djunits.unit.util.UNITS; import org.djunits.value.vdouble.scalar.Direction; import org.djunits.value.vdouble.scalar.Length; import org.djunits.value.vdouble.scalar.Speed; import org.opentrafficsim.core.dsol.AbstractOTSModel; 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.NetworkException; import org.opentrafficsim.draw.road.LaneAnimation; import org.opentrafficsim.draw.road.ShoulderAnimation; import org.opentrafficsim.road.network.OTSRoadNetwork; 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.OTSRoadNode; import org.opentrafficsim.road.network.lane.Shoulder; import org.opentrafficsim.road.network.lane.changing.LaneKeepingPolicy; import nl.tudelft.simulation.dsol.SimRuntimeException; /** *
* Copyright (c) 2013-2020 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 extends AbstractOTSModel implements UNITS
{
/**
* @param simulator OTSSimulatorInterface; the simulator
*/
public TestModel(final OTSSimulatorInterface simulator)
{
super(simulator);
}
/** */
private static final long serialVersionUID = 1L;
/** the network. */
private OTSRoadNetwork network = new OTSRoadNetwork("geometry test network", true, getSimulator());
/** {@inheritDoc} */
@Override
public final void constructModel() throws SimRuntimeException
{
// create a small graph and a road around it.
try
{
OTSRoadNode n0 = new OTSRoadNode(this.network, "N0", new OTSPoint3D(-25.0, 0.0), Direction.ZERO);
OTSRoadNode n1 = new OTSRoadNode(this.network, "N1", new OTSPoint3D(0.0, 0.0), Direction.ZERO);
CrossSectionLink l01 =
new CrossSectionLink(this.network, "L01", n0, n1, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(-25.0, 0.0), new OTSPoint3D(0.0, 0.0)}),
LaneKeepingPolicy.KEEPRIGHT);
OTSRoadNode n2 = new OTSRoadNode(this.network, "N2", new OTSPoint3D(25.0, 20.0), Direction.ZERO);
CrossSectionLink l12 =
new CrossSectionLink(this.network, "L12", n1, n2, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(0.0, 0.0), new OTSPoint3D(25.0, 20.0)}),
LaneKeepingPolicy.KEEPRIGHT);
OTSRoadNode n3 = new OTSRoadNode(this.network, "N3", new OTSPoint3D(50.0, 0.0), Direction.ZERO);
CrossSectionLink l23 =
new CrossSectionLink(this.network, "L23", n2, n3, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(25.0, 20.0), new OTSPoint3D(50.0, 0.0)}),
LaneKeepingPolicy.KEEPRIGHT);
OTSRoadNode n4 = new OTSRoadNode(this.network, "N4", new OTSPoint3D(75.0, -20.0), Direction.ZERO);
CrossSectionLink l34 =
new CrossSectionLink(this.network, "L34", n3, n4, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(50.0, 0.0), new OTSPoint3D(75.0, -20.0)}),
LaneKeepingPolicy.KEEPRIGHT);
OTSRoadNode n5 = new OTSRoadNode(this.network, "N5", new OTSPoint3D(100.0, 0.0), Direction.ZERO);
CrossSectionLink l45 =
new CrossSectionLink(this.network, "L45", n4, n5, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(75.0, -20.0), new OTSPoint3D(100.0, 0.0)}),
LaneKeepingPolicy.KEEPRIGHT);
OTSRoadNode n6 = new OTSRoadNode(this.network, "N6", new OTSPoint3D(125.0, 0.0), Direction.ZERO);
CrossSectionLink l56 =
new CrossSectionLink(this.network, "L56", n5, n6, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(100.0, 0.0), new OTSPoint3D(125.0, 0.0)}),
LaneKeepingPolicy.KEEPRIGHT);
OTSRoadNode n7 = new OTSRoadNode(this.network, "N7", new OTSPoint3D(300.0, 0.0), Direction.ZERO);
CrossSectionLink l67 =
new CrossSectionLink(this.network, "L67", n6, n7, network.getLinkType(LinkType.DEFAULTS.ROAD),
new OTSLine3D(new OTSPoint3D[] {new OTSPoint3D(125.0, 0.0), new OTSPoint3D(150.0, 0.0),
new OTSPoint3D(175.0, 20.0), new OTSPoint3D(200.0, 0.0), new OTSPoint3D(225.0, -20.0),
new OTSPoint3D(250.0, 0.0), new OTSPoint3D(300.0, 0.0)}),
LaneKeepingPolicy.KEEPRIGHT);
add2x2Lanes(l01);
add2x2Lanes(l12);
add2x2Lanes(l23);
add2x2Lanes(l34);
add2x2Lanes(l45);
add2x2Lanes(l56);
add2x2Lanes(l67);
}
catch (NetworkException | OTSGeometryException exception)
{
exception.printStackTrace();
}
}
/**
* The road is as follows; The design line goes from left to right.
*
*
* ----------------------- +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 ** *