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