1 package org.opentrafficsim.demo.geometry.shape;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import org.djunits.value.vdouble.scalar.Time;
7 import org.opentrafficsim.core.dsol.AbstractOTSModel;
8 import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
9 import org.opentrafficsim.core.network.Link;
10 import org.opentrafficsim.core.network.OTSNetwork;
11 import org.opentrafficsim.core.network.OTSNode;
12
13 import nl.tudelft.simulation.dsol.SimRuntimeException;
14
15
16
17
18
19
20
21
22
23
24
25 public class ShapeModel extends AbstractOTSModel
26 {
27
28 private static final long serialVersionUID = 20140815L;
29
30
31 private Map<String, OTSNode> nodes;
32
33
34 private Map<String, Link> shpLinks;
35
36
37 private OTSNetwork network = new OTSNetwork("shape model network");
38
39
40
41
42 public ShapeModel(final OTSSimulatorInterface simulator)
43 {
44 super(simulator);
45 }
46
47
48 @Override
49 public final void constructModel() throws SimRuntimeException
50 {
51 try
52 {
53
54 this.nodes = ShapeFileReader.readNodes(network, "/gis/TESTcordonnodes.shp", "NODENR", true, true);
55 this.shpLinks = new HashMap<>();
56 ShapeFileReader.readLinks(network, "/gis/TESTcordonlinks_aangevuld.shp", this.shpLinks, this.nodes, this.simulator);
57
58 this.simulator.scheduleEventAbs(Time.ZERO, this, this, "ntmFlowTimestep", null);
59 }
60 catch (Throwable exception)
61 {
62 exception.printStackTrace();
63 }
64 }
65
66
67 @Override
68 public final OTSNetwork getNetwork()
69 {
70 return this.network;
71 }
72
73 }