package org.opentrafficsim.road.network; import java.util.LinkedHashMap; import java.util.Map; import org.djutils.exceptions.Throw; import org.djutils.immutablecollections.Immutable; import org.djutils.immutablecollections.ImmutableHashMap; import org.djutils.immutablecollections.ImmutableMap; import org.opentrafficsim.core.dsol.OTSSimulatorInterface; import org.opentrafficsim.core.network.Network; import org.opentrafficsim.road.gtu.lane.tactical.routesystem.RouteSystem; import org.opentrafficsim.road.network.lane.LaneType; /** * OTSRoadNetwork adds a number of methods to the Network class that are specific for roads, such as the LaneTypes. *

* Copyright (c) 2003-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. * BSD-style license. See OpenTrafficSim License. *

* @author Alexander Verbraeck */ public class RoadNetwork extends Network implements RoadNetworkInterface { /** */ private static final long serialVersionUID = 1L; /** LaneTypes registered for this network. */ private Map laneTypeMap = new LinkedHashMap<>(); /** Route system. */ private RouteSystem routeSystem; /** * Construction of an empty network. * @param id String; the network id. * @param simulator OTSSimulatorInterface; the DSOL simulator engine */ public RoadNetwork(final String id, final OTSSimulatorInterface simulator) { super(id, simulator); // TODO: not null once the route system works this.routeSystem = null; // new DefaultRouteSystem(); } /** {@inheritDoc} */ @Override public void addLaneType(final LaneType laneType) { this.laneTypeMap.put(laneType.getId(), laneType); } /** {@inheritDoc} */ @Override public LaneType getLaneType(final String laneTypeId) { return this.laneTypeMap.get(laneTypeId); } /** {@inheritDoc} */ @Override public ImmutableMap getLaneTypes() { return new ImmutableHashMap<>(this.laneTypeMap, Immutable.WRAP); } /** * Sets the route system. * @param routeSystem RouteSystem; route system */ public void setRouteSystem(final RouteSystem routeSystem) { Throw.whenNull(routeSystem, "Route system may not be null."); this.routeSystem = routeSystem; } /** * Returns the route system. * @return RouteSystem; route system */ public RouteSystem getRouteSystem() { return this.routeSystem; } }