public class XmlNetworkLaneParser extends Object
<?xml version="1.0" encoding="UTF-8"?>
<NETWORK xmlns="http://www.example.org/ots-infra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/ots-infra ots-infra.xsd ">
<GLOBAL WIDTH="4m" SPEED="80km/h" />
<NODE NAME="N1" COORDINATE="(0,0)" />
<NODE NAME="N2" />
<LINK NAME="A4_12" FROM="N1" TO="N2" ELEMENTS="X1|V2:V1|D|A1:A2|X2">
<STRAIGHT LENGTH="50m" SPEED="80km/h" WIDTH="4m" />
<LANE NAME="X1" WIDTH="1m" />
<LANE NAME="X2" WIDTH="1m" />
</LINK>
<NODE NAME="N3b2" />
<LINK NAME="A4_13" FROM="N2" TO="N3 b2" ELEMENTS="X1|V2:V1|D|A1:A2|X2">
<ARC RADIUS="100m" ANGLE="90" />
<LANE NAME="X1" WIDTH="1m" />
<LANE NAME="X2" WIDTH="1m" />
</LINK>
<NODE NAME="N4" />
<LINK NAME="A4_14" FROM="N3b2" TO="N4" ELEMENTS="X1|V2:V1|D|A1:A2|:A3|X2">
<STRAIGHT LENGTH="50m" SPEED="80km/h" WIDTH="4m" />
<LANE NAME="X1" WIDTH="1m" />
<LANE NAME="X2" WIDTH="1m" />
<LANE NAME="A3" SPEED="60km/h" />
</LINK>
<NODE NAME="N5" />
<NODE NAME="ENTRY5" />
<LINK NAME="A4_15" FROM="N4" TO="N5" ELEMENTS="X1|V2:V1|D|A1:A2|X2">
<STRAIGHT LENGTH="100m" SPEED="80km/h" WIDTH="4m" />
<LANE NAME="X1" WIDTH="1m" />
<LANE NAME="X2" WIDTH="1m" />
</LINK>
<LINK NAME="LE1" FROM="ENTRY5" TO="N3b2(A3)" ELEMENTS="|AD|">
<ARC RADIUS="100m" ANGLE="-45" SPEED="60km/h" />
</LINK>
<NODE NAME="ENTRY6" />
<LINK NAME="LE2" FROM="ENTRY6" TO="ENTRY5" ELEMENTS="|AD|">
<ARC RADIUS="100m" ANGLE="45" SPEED="60km/h" />
</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 |
XmlNetworkLaneParser.ArcDirection
direction of the arc; LEFT or RIGHT.
|
protected class |
XmlNetworkLaneParser.ArcTag
ARC element.
|
protected class |
XmlNetworkLaneParser.FillTag
Fill element.
|
protected class |
XmlNetworkLaneParser.GeneratorTag
Generator element.
|
protected class |
XmlNetworkLaneParser.GlobalTag
GLOBAL element.
|
protected class |
XmlNetworkLaneParser.GTUTag
GTU element.
|
protected class |
XmlNetworkLaneParser.LaneTag
LANE element.
|
protected class |
XmlNetworkLaneParser.LinkTag
LINK element.
|
protected class |
XmlNetworkLaneParser.NodeTag
NODE element.
|
protected class |
XmlNetworkLaneParser.StraightTag
STRAIGHT element.
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,XmlNetworkLaneParser.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,XmlNetworkLaneParser.NodeTag> |
nodeTags
the UNprocessed nodes for further reference.
|
| Constructor and Description |
|---|
XmlNetworkLaneParser(Class<?> networkIdClass,
Class<?> nodeClass,
Class<?> nodeIdClass,
Class<?> nodePointClass,
Class<?> linkClass,
Class<?> linkIdClass,
OTSSimulatorInterface simulator) |
| Modifier and Type | Method and Description |
|---|---|
Network<?,?> |
build(InputStream is) |
protected void |
calculateNodeCoordinates(XmlNetworkLaneParser.LinkTag linkTag)
One of the nodes probably has a coordinate and the other not.
|
static void |
main(String[] args)
Test.
|
protected Object |
makeId(Class<?> clazz,
String ids)
Generate an ID of the right type.
|
protected CrossSectionLink |
makeLink(XmlNetworkLaneParser.LinkTag linkTag)
FIXME LinkGeotools should extend CrossSectionLink and not the other way around.
|
protected Node |
makeNode(Class<?> clazz,
XmlNetworkLaneParser.NodeTag nodeTag) |
protected Object |
makePoint(Class<?> clazz,
Point3d p)
Generate an ID of the right type.
|
protected Point3d |
parseCoordinate(String cs)
Parse a coordinate with (x,y) or (x,y,z).
|
protected List<CrossSectionElement> |
parseElements(String elements,
CrossSectionLink csl,
XmlNetworkLaneParser.LinkTag linkTag,
XmlNetworkLaneParser.GlobalTag globalTag) |
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 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 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,XmlNetworkLaneParser.NodeTag> nodeTags
protected Map<String,XmlNetworkLaneParser.GTUTag> gtuTags
public XmlNetworkLaneParser(Class<?> networkIdClass, Class<?> nodeClass, Class<?> nodeIdClass, Class<?> nodePointClass, Class<?> linkClass, Class<?> linkIdClass, OTSSimulatorInterface 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(InputStream is) throws NetworkException, ParserConfigurationException, SAXException, IOException
is - 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.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, XmlNetworkLaneParser.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(XmlNetworkLaneParser.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(XmlNetworkLaneParser.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 List<CrossSectionElement> parseElements(String elements, CrossSectionLink csl, XmlNetworkLaneParser.LinkTag linkTag, XmlNetworkLaneParser.GlobalTag globalTag) throws SAXException, RemoteException, NamingException
elements - the string such as "X1|V2:V1|D|A1:A2|:A3|X2"csl - the cross-section link to which the cross-section elements belong.linkTag - the link with possible information about speed and width.globalTag - the global tag with possible information about speed and width.SAXException - for unknown lane type or other inconsistencies.NamingException - when animation context cannot be found.RemoteException - when animation context cannot be reached.protected 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 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 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.public static void main(String[] args) throws NetworkException, ParserConfigurationException, SAXException, IOException
args - none.NetworkExceptionIOExceptionSAXExceptionParserConfigurationExceptionCopyright © 2014–2015 Delft University of Technology. All rights reserved.