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