public class XmlNetworkLaneParser2 extends Object
<?xml version="1.0" encoding="UTF-8"?>
<NETWORK xmlns="http://www.opentrafficsim.org/ots-infra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opentrafficsim.org/ots-infra ots-infra.xsd">
<GLOBAL WIDTH="3.6m" SPEED="100km/h" />
<GTU NAME="CAR" GTUTYPE="CAR" FOLLOWING="IDM+" LENGTH="UNIF(5,7) m" WIDTH="UNIF(1.7, 2) m"
LANECHANGE="EGOISTIC" MAXSPEED="CONST(120) km/h" />
<GTU NAME="TRUCK" GTUTYPE="TRUCK" FOLLOWING="IDM+" LENGTH="UNIF(16,24) m" WIDTH="UNIF(2.2, 2.7) m"
LANECHANGE="ALTRUISTIC" MAXSPEED="CONST(100) km/h" />
<GTUMIX NAME="C60T40">
<GTU NAME="CAR" WEIGHT="60"></GTU>
<GTU NAME="TRUCK" WEIGHT="40"></GTU>
</GTUMIX>
<NODE NAME="N1" COORDINATE="(0.0, 0.0)" ANGLE="90" />
<NODE NAME="N2" />
<NODE NAME="NE" />
<LINK NAME="L1" FROM="N1" TO="N2" ELEMENTS="S1-X1|A1:D:A2|X2-S2">
<ARC RADIUS="1000m" ANGLE="180" DIRECTION="L" />
<LANE NAME="X1" WIDTH="2.5m" />
<LANE NAME="X2" WIDTH="2.5m" />
<LANE NAME="S1" WIDTH="2m" />
<LANE NAME="S2" WIDTH="2m" />
</LINK>
<LINK NAME="L2" FROM="N2" TO="N1" ELEMENTS="S1-X1|A1:D:A2|X2-S2">
<ARC RADIUS="1000m" ANGLE="180" DIRECTION="L" />
<LANE NAME="X1" WIDTH="2.5m" />
<LANE NAME="X2" WIDTH="2.5m" />
<LANE NAME="S1" WIDTH="2m" />
<LANE NAME="S2" WIDTH="2m" />
</LINK>
<GTUMIX NAME="C80T20">
<GTU NAME="CAR" WEIGHT="80" />
<GTU NAME="TRUCK" WEIGHT="20" />
</GTUMIX>
<LINK NAME="ENTRY" FROM="NE" TO="N1" ELEMENTS="S1-X1|A1:D:A2|X2-S2">
<STRAIGHT LENGTH="200m" />
<LANE NAME="A1" SPEED="100 km/h" />
<LANE NAME="X1" WIDTH="2.5m" />
<LANE NAME="X2" WIDTH="2.5m" />
<LANE NAME="S1" WIDTH="2m" />
<LANE NAME="S2" WIDTH="2m" />
<GENERATOR LANE="A1" IAT="EXPO(30) s" INITIALSPEED="TRIA(80,90,100) km/h" MAXGTU="50" GTUMIX="C60T40" />
<GENERATOR LANE="A2" IAT="EXPO(45) s" INITIALSPEED="TRIA(80,90,100) km/h" MAXGTU="25" GTUMIX="C80T20" />
</LINK>
</NETWORK>
Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
XmlNetworkLaneParser2.ArcDirection
direction of the arc; LEFT or RIGHT.
|
protected class |
XmlNetworkLaneParser2.ArcTag
ARC element.
|
protected class |
XmlNetworkLaneParser2.CrossSectionElementTag
CROSSSECTION element.
|
protected static class |
XmlNetworkLaneParser2.ElementType
element types.
|
protected class |
XmlNetworkLaneParser2.FillTag
Fill element.
|
protected class |
XmlNetworkLaneParser2.GeneratorTag
Generator element.
|
protected class |
XmlNetworkLaneParser2.GlobalTag
GLOBAL element.
|
protected class |
XmlNetworkLaneParser2.GTUMixTag
GTUMIX element.
|
protected class |
XmlNetworkLaneParser2.GTUTag
GTU element.
|
protected class |
XmlNetworkLaneParser2.LinkTag
LINK element.
|
protected class |
XmlNetworkLaneParser2.NodeTag
NODE element.
|
protected class |
XmlNetworkLaneParser2.RoadTypeTag
ROADTYPE element.
|
protected class |
XmlNetworkLaneParser2.RouteMixTag
ROUTEMIX element.
|
protected class |
XmlNetworkLaneParser2.RouteTag
ROUTE element.
|
protected class |
XmlNetworkLaneParser2.ShortestRouteMixTag
SHORTESTROUTEMIX element.
|
protected class |
XmlNetworkLaneParser2.ShortestRouteTag
SHORTESTROUTE element.
|
protected class |
XmlNetworkLaneParser2.StraightTag
STRAIGHT element.
|
protected static class |
XmlNetworkLaneParser2.StripeType
stripe types.
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,XmlNetworkLaneParser2.GTUMixTag> |
gtuMixTags
the gtumix tags for further reference.
|
protected Map<String,XmlNetworkLaneParser2.GTUTag> |
gtuTags
the gtu tags for further reference.
|
protected Map<String,GTUType<String>> |
gtuTypes
the GTUTypes that have been created.
|
protected Class<?> |
linkClass
the class of the Link.
|
protected Class<?> |
linkIdClass
the ID class of the Link.
|
protected Map<String,Link> |
links
the links for further reference.
|
protected Class<?> |
networkIdClass
the ID class of the Network.
|
protected Class<?> |
nodeClass
the class of the Node.
|
protected Class<?> |
nodeIdClass
the ID class of the Node.
|
protected Class<?> |
nodePointClass
the Point class of the Node.
|
protected Map<String,Node> |
nodes
the processed nodes for further reference.
|
protected Map<String,XmlNetworkLaneParser2.NodeTag> |
nodeTags
the UNprocessed nodes for further reference.
|
protected int |
phase
the phase of parsing.
|
protected Map<String,XmlNetworkLaneParser2.RoadTypeTag> |
roadTypeTags
the road type tags for further reference.
|
protected Map<String,XmlNetworkLaneParser2.RouteMixTag> |
routeMixTags
the route mix tags for further reference.
|
protected Map<String,XmlNetworkLaneParser2.RouteTag> |
routeTags
the route tags for further reference.
|
protected Map<String,XmlNetworkLaneParser2.ShortestRouteMixTag> |
shortestRouteMixTags
the shortest route mix tags for further reference.
|
protected Map<String,XmlNetworkLaneParser2.ShortestRouteTag> |
shortestRouteTags
the shortest route tags for further reference.
|
protected OTSDEVSSimulatorInterface |
simulator
the simulator for creating the animation.
|
| Constructor and Description |
|---|
XmlNetworkLaneParser2(Class<?> networkIdClass,
Class<?> nodeClass,
Class<?> nodeIdClass,
Class<?> nodePointClass,
Class<?> linkClass,
Class<?> linkIdClass,
OTSDEVSSimulatorInterface simulator) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyRoadTypeToLink(XmlNetworkLaneParser2.RoadTypeTag roadTypeTag,
CrossSectionLink csl,
XmlNetworkLaneParser2.LinkTag linkTag,
XmlNetworkLaneParser2.GlobalTag globalTag) |
Network<?,?> |
build(String s) |
Network<?,?> |
build(URL url) |
protected void |
calculateNodeCoordinates(XmlNetworkLaneParser2.LinkTag linkTag)
One of the nodes probably has a coordinate and the other not.
|
protected void |
calculateRoadTypeOffsets(XmlNetworkLaneParser2.RoadTypeTag roadTypeTag,
XmlNetworkLaneParser2.GlobalTag globalTag)
Calculates the offsets and widths of the lanes and stripes in a RoadTypeTag by a forward pass from the first found
offset, and then a backward pass from the end to the beginning.
|
protected void |
makeGenerator(XmlNetworkLaneParser2.GeneratorTag generatorTag)
Make a generator.
|
protected Object |
makeId(Class<?> clazz,
String ids)
Generate an ID of the right type.
|
protected CrossSectionLink |
makeLink(XmlNetworkLaneParser2.LinkTag linkTag)
FIXME LinkGeotools should extend CrossSectionLink and not the other way around.
|
protected Node |
makeNode(Class<?> clazz,
XmlNetworkLaneParser2.NodeTag nodeTag) |
protected Object |
makePoint(Class<?> clazz,
Point3d p)
Generate an ID of the right type.
|
protected Color |
parseColor(String colorStr) |
protected Point3d |
parseCoordinate(String cs)
Parse a coordinate with (x,y) or (x,y,z).
|
protected LongitudinalDirectionality |
parseDirection(String dirStr) |
protected GTUFollowingModel |
parseFollowingModel(String modelName)
XXX probably ok to generate a new model for each GTU 'type'.
|
protected GTUType<String> |
parseGTUType(String typeName) |
protected LaneChangeModel |
parseLaneChangeModel(String modelName)
XXX probably ok to generate a new model for each GTU 'type'.
|
protected DoubleScalar.Abs<LengthUnit> |
parseLengthAbs(String s) |
protected DistContinuousDoubleScalar.Abs<LengthUnit> |
parseLengthDistAbs(String s)
Parse an absolute length distribution, e.g.
|
protected DistContinuousDoubleScalar.Rel<LengthUnit> |
parseLengthDistRel(String s)
Parse a relative length distribution, e.g.
|
protected DoubleScalar.Rel<LengthUnit> |
parseLengthRel(String s) |
protected List<XmlNetworkLaneParser2.NodeTag> |
parseNodeList(String nodeNames) |
protected DoubleScalar.Abs<LinearDensityUnit> |
parsePerLengthAbs(String s) |
protected DoubleScalar.Abs<FrequencyUnit> |
parsePerTimeAbs(String s) |
protected DoubleScalar.Abs<SpeedUnit> |
parseSpeedAbs(String s) |
protected DistContinuousDoubleScalar.Abs<SpeedUnit> |
parseSpeedDistAbs(String s)
Parse an absolute speed distribution, e.g.
|
protected DistContinuousDoubleScalar.Rel<SpeedUnit> |
parseSpeedDistRel(String s)
Parse a relative speed distribution, e.g.
|
protected DoubleScalar.Rel<SpeedUnit> |
parseSpeedRel(String s) |
protected XmlNetworkLaneParser2.StripeType |
parseStripeType(String stripeStr) |
protected DoubleScalar.Abs<TimeUnit> |
parseTimeAbs(String s) |
protected DistContinuousDoubleScalar.Abs<TimeUnit> |
parseTimeDistAbs(String s)
Parse an absolute time distribution, e.g.
|
protected DistContinuousDoubleScalar.Rel<TimeUnit> |
parseTimeDistRel(String s)
Parse a relative time distribution, e.g.
|
protected DoubleScalar.Rel<TimeUnit> |
parseTimeRel(String s) |
protected final Class<?> networkIdClass
protected final Class<?> nodeClass
protected final Class<?> nodeIdClass
protected final Class<?> nodePointClass
protected final Class<?> linkClass
protected final Class<?> linkIdClass
protected Map<String,XmlNetworkLaneParser2.NodeTag> nodeTags
protected Map<String,XmlNetworkLaneParser2.GTUTag> gtuTags
protected Map<String,XmlNetworkLaneParser2.GTUMixTag> gtuMixTags
protected Map<String,XmlNetworkLaneParser2.RouteTag> routeTags
protected Map<String,XmlNetworkLaneParser2.RouteMixTag> routeMixTags
protected Map<String,XmlNetworkLaneParser2.ShortestRouteTag> shortestRouteTags
protected Map<String,XmlNetworkLaneParser2.ShortestRouteMixTag> shortestRouteMixTags
protected Map<String,XmlNetworkLaneParser2.RoadTypeTag> roadTypeTags
protected OTSDEVSSimulatorInterface simulator
protected int phase
public XmlNetworkLaneParser2(Class<?> networkIdClass, Class<?> nodeClass, Class<?> nodeIdClass, Class<?> nodePointClass, Class<?> linkClass, Class<?> linkIdClass, OTSDEVSSimulatorInterface simulator)
networkIdClass - the ID class of the Network.nodeClass - the class of the Node.nodeIdClass - the ID class of the Node.nodePointClass - the Point class of the Node.linkClass - the class of the Link.linkIdClass - the ID class of the Link.simulator - the simulator for creating the animation. Null if no animation needed.public final Network<?,?> build(URL url) throws NetworkException, ParserConfigurationException, SAXException, IOException
url - the file with the network in the agreed xml-grammar.NetworkException - in case of parsing problems.SAXException - in case of parsing problems.ParserConfigurationException - in case of parsing problems.IOException - in case of file reading problems.public final Network<?,?> build(String s) throws NetworkException, ParserConfigurationException, SAXException, IOException
s - the string with the network in the agreed xml-grammar.NetworkException - in case of parsing problems.SAXException - in case of parsing problems.ParserConfigurationException - in case of parsing problems.IOException - in case of file reading problems.protected final Object makeId(Class<?> clazz, String ids) throws NetworkException
clazz - the class to instantiate.ids - the id as a String.NetworkException - when id cannot be instantiatedprotected final Object makePoint(Class<?> clazz, Point3d p) throws NetworkException
clazz - the class to instantiate.p - the point as a String.NetworkException - when point cannot be instantiatedprotected final Node makeNode(Class<?> clazz, XmlNetworkLaneParser2.NodeTag nodeTag) throws NetworkException, RemoteException, NamingException
clazz - the node classnodeTag - the tag with the infor for the node.NetworkException - when point cannot be instantiatedNamingException - when animation context cannot be found.RemoteException - when communication error occurs when trying to find animation context.protected final void calculateNodeCoordinates(XmlNetworkLaneParser2.LinkTag linkTag) throws RemoteException, NetworkException, NamingException
linkTag - the parsed information from the XML file.NetworkException - when both nodes are null.RemoteException - when coordinate cannot be reached.NamingException - when node animation cannot link to the animation context.protected final CrossSectionLink makeLink(XmlNetworkLaneParser2.LinkTag linkTag) throws SAXException, RemoteException, NamingException
linkTag - the link information from XML.SAXException - when point cannot be instantiatedNamingException - when animation context cannot be found.RemoteException - when communication error occurs when reaching animation context.protected final void makeGenerator(XmlNetworkLaneParser2.GeneratorTag generatorTag) throws SimRuntimeException, RemoteException
generatorTag - SimRuntimeExceptionRemoteExceptionprotected final void calculateRoadTypeOffsets(XmlNetworkLaneParser2.RoadTypeTag roadTypeTag, XmlNetworkLaneParser2.GlobalTag globalTag) throws SAXException
roadTypeTag - the road type tag to calculate the offsets for.globalTag - to provide the global length.SAXException - when the width of a lane cannot be calculated.protected final void applyRoadTypeToLink(XmlNetworkLaneParser2.RoadTypeTag roadTypeTag, CrossSectionLink csl, XmlNetworkLaneParser2.LinkTag linkTag, XmlNetworkLaneParser2.GlobalTag globalTag) throws NetworkException, RemoteException, NamingException, SAXException
protected final List<XmlNetworkLaneParser2.NodeTag> parseNodeList(String nodeNames) throws SAXException
nodeNames - the node names as a space-separated StringSAXException - when node could not be foundprotected final GTUType<String> parseGTUType(String typeName)
typeName - the name of the GTU type.protected final GTUFollowingModel parseFollowingModel(String modelName) throws NetworkException
modelName - the name of the GTU following model.NetworkException - in case of unknown model.protected final LaneChangeModel parseLaneChangeModel(String modelName) throws NetworkException
modelName - the name of the lane change model.NetworkException - in case of unknown model.protected final Point3d parseCoordinate(String cs)
cs - the string containing the coordinate.protected final LongitudinalDirectionality parseDirection(String dirStr) throws NetworkException
dirStr - the direction.NetworkException - in case of unknown model.protected final XmlNetworkLaneParser2.StripeType parseStripeType(String stripeStr) throws NetworkException
stripeStr - the stripe string.NetworkException - in case of unknown model.protected final Color parseColor(String colorStr) throws NetworkException
colorStr - the color as a string.NetworkException - in case of unknown model.protected final DoubleScalar.Abs<SpeedUnit> parseSpeedAbs(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Rel<SpeedUnit> parseSpeedRel(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Abs<LengthUnit> parseLengthAbs(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Rel<LengthUnit> parseLengthRel(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Abs<TimeUnit> parseTimeAbs(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Rel<TimeUnit> parseTimeRel(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Abs<FrequencyUnit> parsePerTimeAbs(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DoubleScalar.Abs<LinearDensityUnit> parsePerLengthAbs(String s) throws NetworkException
s - the string to parseNetworkException - when parsing failsprotected final DistContinuousDoubleScalar.Rel<LengthUnit> parseLengthDistRel(String s) throws NetworkException
UNIFORM(1, 3) m.s - the string to be parsed.NetworkException - in case of a parse error.protected final DistContinuousDoubleScalar.Abs<LengthUnit> parseLengthDistAbs(String s) throws NetworkException
UNIFORM(1, 3) m.s - the string to be parsed.NetworkException - in case of a parse error.protected final DistContinuousDoubleScalar.Rel<TimeUnit> parseTimeDistRel(String s) throws NetworkException
UNIFORM(1, 3) s.s - the string to be parsed.NetworkException - in case of a parse error.protected final DistContinuousDoubleScalar.Abs<TimeUnit> parseTimeDistAbs(String s) throws NetworkException
UNIFORM(1, 3) s.s - the string to be parsed.NetworkException - in case of a parse error.protected final DistContinuousDoubleScalar.Rel<SpeedUnit> parseSpeedDistRel(String s) throws NetworkException
TRIANGULAR(80, 90, 110) km/h.s - the string to be parsed.NetworkException - in case of a parse error.protected final DistContinuousDoubleScalar.Abs<SpeedUnit> parseSpeedDistAbs(String s) throws NetworkException
TRIANGULAR(80, 90, 110) km/h.s - the string to be parsed.NetworkException - in case of a parse error.Copyright © 2014–2015 Delft University of Technology. All rights reserved.