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