MATSIM
VisumNetwork.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * VisumNetwork.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2008 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.visum;
22 
23 import java.util.HashMap;
24 import java.util.LinkedHashMap;
25 import java.util.Map;
26 import java.util.TreeMap;
27 
28 import org.matsim.api.core.v01.Coord;
29 import org.matsim.api.core.v01.Id;
32 
37 public class VisumNetwork {
38 
39  public final Map<Id<EdgeType>, EdgeType> edgeTypes = new HashMap<>();
40  public final Map<Id<Stop>, Stop> stops = new TreeMap<>();
41  public final Map<Id<StopArea>, StopArea> stopAreas = new TreeMap<>();
42  public final Map<String, StopPoint> stopPoints = new TreeMap<String, StopPoint>();
43  public final Map<Id<TransitLine>, TransitLine> lines = new TreeMap<Id<TransitLine>, TransitLine>();
44  public final Map<String, TransitLineRoute> lineRoutes = new TreeMap<String, TransitLineRoute>();
45  public final Map<String, LineRouteItem> lineRouteItems = new TreeMap<String, LineRouteItem>();
46  public final Map<String, TimeProfile> timeProfiles = new TreeMap<String, TimeProfile>();
47  public final Map<String, TimeProfileItem> timeProfileItems = new LinkedHashMap<String, TimeProfileItem>();
48  public final Map<String, Departure> departures = new TreeMap<String, Departure>();
49  public final Map<String, Departure> departuresByNo = new TreeMap<String, Departure>();
50  public final Map<String, VehicleUnit> vehicleUnits = new HashMap<String, VehicleUnit>();
51  public final Map<String, VehicleCombination> vehicleCombinations = new HashMap<String, VehicleCombination>();
52 
53  public void addEdgeType(final EdgeType edgeType) {
54  EdgeType oldEdgeType = edgeTypes.put(edgeType.id, edgeType);
55  if (oldEdgeType != null) {
56  throw new IllegalArgumentException("Duplicate edge type.");
57  }
58  }
59 
60  public void addStop(final Stop stop) {
61  Stop oldStop = this.stops.put(stop.id, stop);
62  if (oldStop != null) {
63  // there was already a stop with the same id
64  // re-do the insertion
65  this.stops.put(oldStop.id, oldStop);
66  throw new IllegalArgumentException("There is already a stop with the same Name");
67  }
68 
69  }
70 
71  public void addStopArea(final StopArea stopAr) {
72  StopArea oldStopAr = this.stopAreas.put(stopAr.id, stopAr);
73  if (oldStopAr != null) {
74  // there was already a stop point with the same id
75  // re-do the insertion
76  this.stopAreas.put(oldStopAr.id, oldStopAr);
77  throw new IllegalArgumentException("There is already a stop area with the same id.");
78  }
79 
80  }
81 
82  public void addStopPoint(final StopPoint stopPt) {
83  StopPoint oldStopPt = this.stopPoints.put(stopPt.stopAreaId.toString()+stopPt.id.toString(), stopPt);
84  if (oldStopPt != null) {
85  // there was already a stop point with the same id
86  // re-do the insertion
87  this.stopPoints.put(oldStopPt.stopAreaId.toString()+oldStopPt.id.toString(), oldStopPt);
88  throw new IllegalArgumentException("There is already a stop with the same id.");
89  }
90 
91  }
92  public void addline(final TransitLine l1) {
93  TransitLine oldl = this.lines.put(l1.id, l1);
94  if (oldl != null) {
95  // there was already a line with the same id
96  // re-do the insertion
97  this.lines.put(oldl.id, oldl);
98  throw new IllegalArgumentException("There is already a line with the same id.");
99  }
100 
101  }
102  public void addLineRoute(final TransitLineRoute lr1) {
103  TransitLineRoute oldlr = this.lineRoutes.put(lr1.lineName.toString()+"/"+lr1.id.toString()+"/"+lr1.DCode, lr1);
104  if (oldlr != null) {
105  // there was already a line route with the same id
106  // re-do the insertion
107  this.lineRoutes.put(oldlr.lineName.toString()+"/"+oldlr.id.toString()+"/"+oldlr.DCode, oldlr);
108  throw new IllegalArgumentException("There is already a line route with the same id.");
109  }
110 
111  }
112  public void addLineRouteItem(final LineRouteItem lri1) {
113  LineRouteItem oldlri = this.lineRouteItems.put(lri1.lineName +"/"+ lri1.lineRouteName +"/"+lri1.index+"/"+lri1.DCode, lri1);
114  if (oldlri != null) {
115  // there was already a Line Route Item with the same id
116  // re-do the insertion
117  this.lineRouteItems.put(oldlri.lineName +"/"+oldlri.lineRouteName+"/"+oldlri.index+"/"+oldlri.DCode, oldlri);
118  throw new IllegalArgumentException("There is already a route item with the same id."+oldlri.lineName +"/"+ oldlri.lineRouteName +"/"+oldlri.index+"/"+ oldlri.DCode);
119  }
120 
121  }
122  public void addTimeProfile(final TimeProfile tp1) {
123  TimeProfile oldtp = this.timeProfiles.put(tp1.lineName.toString()+"/"+tp1.lineRouteName.toString() +"/"+tp1.dirCode+"/"+ tp1.index.toString(), tp1);
124  if (oldtp != null) {
125  // there was already a stop with the same id
126  // re-do the insertion
127  this.timeProfiles.put(oldtp.lineName.toString()+"/"+oldtp.lineRouteName.toString() +"/"+oldtp.dirCode+"/"+ oldtp.index.toString(), oldtp);
128  throw new IllegalArgumentException("There is already a time profile with the same id."+oldtp.lineRouteName.toString() +"/"+ oldtp.index.toString());
129  }
130 
131  }
132  public void addTimeProfileItem(final TimeProfileItem tpi1) {
133  TimeProfileItem oldtpi = this.timeProfileItems.put(tpi1.lineName+"/"+tpi1.lineRouteName+"/"+tpi1.timeProfileName+"/"+tpi1.dirCode+"/"+tpi1.index, tpi1);
134  if (oldtpi != null) {
135  // there was already ane entry with the same id
136  // re-do the insertion
137  this.timeProfileItems.put(oldtpi.lineName+"/"+oldtpi.lineRouteName+"/"+oldtpi.timeProfileName+"/"+oldtpi.dirCode+"/"+oldtpi.index, oldtpi);
138  throw new IllegalArgumentException("There is already a time profile item with the same id.");
139  }
140 
141  }
142  public void addDeparture(final Departure d) {
143  Departure oldD = this.departures.put(d.lineName +"/"+ d.lineRouteName +"/"+ d.index, d);
144  if (oldD != null) {
145  // there was already an entry with the same id
146  // re-do the insertion
147  this.departures.put(oldD.lineName+"/"+ oldD.lineRouteName +"/"+ oldD.index, oldD);
148  throw new IllegalArgumentException("There is already a departure with the same id.");
149  }
150  this.departuresByNo.put(d.index, d);
151  }
152 
153  public void addVehicleUnit(final VehicleUnit vehUnit) {
154  VehicleUnit oldVU = this.vehicleUnits.put(vehUnit.id, vehUnit);
155  if (oldVU != null) {
156  // there was already an entry with the same id
157  // re-do the insertion
158  this.vehicleUnits.put(oldVU.id, oldVU);
159  throw new IllegalArgumentException("There is already a vehicle unit with the same id.");
160  }
161  }
162 
163  public void addVehicleCombination(final VehicleCombination vehComb) {
164  VehicleCombination oldVC = this.vehicleCombinations.put(vehComb.id, vehComb);
165  if (oldVC != null) {
166  // there was already an entry with the same id
167  // re-do the insertion
168  this.vehicleCombinations.put(oldVC.id, oldVC);
169  throw new IllegalArgumentException("There is already a vehicle combination with the same id.");
170  }
171  }
172 
173  public static class EdgeType {
174  public final Id<EdgeType> id;
175  public final String kapIV;
176  public final String v0IV;
177  public final String noOfLanes;
178 
179  public EdgeType(Id<EdgeType> id, String kapIV, String v0IV, String noOfLanes) {
180  super();
181  this.id = id;
182  this.kapIV = kapIV;
183  this.v0IV = v0IV;
184  this.noOfLanes = noOfLanes;
185  }
186 
187  }
188 
189  public static class Stop {
190  public final Id<Stop> id;
191  public final String name;
192  public final Coord coord;
193 
194  public Stop(final Id<Stop> id, final String name, final Coord coord) {
195  this.id = id;
196  this.name = name;
197  this.coord = coord;
198  }
199  }
200  public static class StopArea {
201  public final Id<StopArea> id;
202  public final Id<Stop> StopId;
203 
204  public StopArea(final Id<StopArea> id, final Id<Stop> stopId) {
205  this.id = id;
206  this.StopId = stopId;
207  }
208  }
209  public static class StopPoint {
210  public final Id<StopPoint> id;
211  public final Id<StopArea> stopAreaId;
212  public final String name;
213  public final Id<Link> refLinkNo;
214  public final Id<Node> nodeId;
215 
216  public StopPoint(final Id<StopPoint> id, final Id<StopArea> stopAreaId, final String name, final Id<Link> refLinkNo, final Id<Node> nodeId) {
217  this.id = id;
218  this.stopAreaId = stopAreaId;
219  this.name = name;
220  this.refLinkNo = refLinkNo;
221  this.nodeId = nodeId;
222  }
223  }
224  public static class TransitLineRoute {
225 
226  public final Id<TransitLineRoute> id;
227  public final Id<TransitLine> lineName;
228  public final String DCode;
229  public String takt;
230 
231  public TransitLineRoute(final Id<TransitLineRoute> id,final Id<TransitLine> lineName,final String DCode) {
232  this.id = id;
233  this.lineName = lineName;
234  this.DCode = DCode;
235  }
236  }
237 
238  public static class TransitLine {
239 
240  public final Id<TransitLine> id;
241  public final String tCode;
242  public final String vehCombNo;
243 
244  public TransitLine(final Id<TransitLine> id, final String tCode,final String vehCombNo) {
245  this.id = id;
246  this.tCode = tCode;
247  this.vehCombNo = vehCombNo;
248  }
249  }
250 
251  public static class LineRouteItem {
252  public final String lineName;
253  public final String lineRouteName;
254  public final String index;
255  public final String DCode;
256  public final Id<Node> nodeId;
258 
259  public LineRouteItem(final String lineName, final String lineRouteName, final String index,final String DCode, final Id<Node> nodeId, final Id<StopPoint> stopPointNo) {
260  this.lineName = lineName;
261  this.lineRouteName = lineRouteName;
262  this.index = index;
263  this.nodeId = nodeId;
264  this.stopPointNo = stopPointNo;
265  this.DCode = DCode;
266  }
267  }
268 
269  public static class TimeProfile {
270  public final Id<TransitLine> lineName;
272  public final Id<TimeProfile> index;
273  public final String dirCode;
274  public final String vehCombNr;
275 
276  public TimeProfile(final Id<TransitLine> lineName, final Id<TransitLineRoute> lineRouteName, final Id<TimeProfile> index,final String dirCode, final String vehCombNr) {
277  this.lineName = lineName;
278  this.lineRouteName = lineRouteName;
279  this.index = index;
280  this.dirCode = dirCode;
281  this.vehCombNr = vehCombNr;
282  }
283  }
284 
285  public static class TimeProfileItem {
286  public final String lineName;
287  public final String lineRouteName;
288  public final String timeProfileName;
289  public final String index;
290  public final String arr;
291  public final String dep;
293  public final String dirCode;
294 
295  public TimeProfileItem(final String lineName, final String lineRouteName, final String timeProfileName,final String DCode,final String index, final String arr, final String dep, final Id<TimeProfileItem> lRIIndex) {
296  this.lineName = lineName;
297  this.lineRouteName = lineRouteName;
298  this.timeProfileName = timeProfileName;
299  this.dirCode = DCode;
300  this.index = index;
301  this.arr = arr;
302  this.dep = dep;
303  this.lRIIndex = lRIIndex;
304  }
305  }
306 
307  public static class Departure {
308  public final String lineName;
309  public final String lineRouteName;
310  public final String index;
311  public final String TRI;
312  public final String dep;
313  public final String dirCode;
314  public String vehCombinationNo = null;
315 
316  public Departure(final String lineName, final String lineRouteName, final String index, final String TRI, final String dep, final String dirCode) {
317  this.lineName = lineName;
318  this.lineRouteName = lineRouteName;
319  this.index = index;
320  this.TRI = TRI;
321  this.dep = dep;
322  this.dirCode = dirCode;
323  }
324  }
325 
326  public static class VehicleUnit {
327  public final String id;
328  public final String name;
329  public final int seats;
330  public final int passengerCapacity;
331 
332  public VehicleUnit(final String id, final String name, final int seats, final int passengerCapacity) {
333  this.id = id;
334  this.name = name;
335  this.seats = seats;
336  this.passengerCapacity = passengerCapacity;
337  }
338  }
339 
340  public static class VehicleCombination {
341  public final String id;
342  public final String name;
343  public String vehUnitId = null;
344  public int numOfVehicles = 0;
345 
346  public VehicleCombination(final String id, final String name) {
347  this.id = id;
348  this.name = name;
349  }
350  }
351 }
352 
Stop(final Id< Stop > id, final String name, final Coord coord)
void addLineRoute(final TransitLineRoute lr1)
final Map< Id< StopArea >, StopArea > stopAreas
void addStop(final Stop stop)
void addStopArea(final StopArea stopAr)
void addEdgeType(final EdgeType edgeType)
VehicleCombination(final String id, final String name)
void addline(final TransitLine l1)
final Map< String, Departure > departures
final Map< String, TimeProfileItem > timeProfileItems
final Map< String, StopPoint > stopPoints
TimeProfileItem(final String lineName, final String lineRouteName, final String timeProfileName, final String DCode, final String index, final String arr, final String dep, final Id< TimeProfileItem > lRIIndex)
Departure(final String lineName, final String lineRouteName, final String index, final String TRI, final String dep, final String dirCode)
void addStopPoint(final StopPoint stopPt)
void addVehicleCombination(final VehicleCombination vehComb)
EdgeType(Id< EdgeType > id, String kapIV, String v0IV, String noOfLanes)
void addTimeProfile(final TimeProfile tp1)
TransitLineRoute(final Id< TransitLineRoute > id, final Id< TransitLine > lineName, final String DCode)
final Map< String, Departure > departuresByNo
final Map< String, VehicleUnit > vehicleUnits
StopArea(final Id< StopArea > id, final Id< Stop > stopId)
final Map< Id< EdgeType >, EdgeType > edgeTypes
StopPoint(final Id< StopPoint > id, final Id< StopArea > stopAreaId, final String name, final Id< Link > refLinkNo, final Id< Node > nodeId)
final Map< Id< Stop >, Stop > stops
VehicleUnit(final String id, final String name, final int seats, final int passengerCapacity)
final Id< TransitLineRoute > lineRouteName
LineRouteItem(final String lineName, final String lineRouteName, final String index, final String DCode, final Id< Node > nodeId, final Id< StopPoint > stopPointNo)
final Map< String, VehicleCombination > vehicleCombinations
final Map< Id< TransitLine >, TransitLine > lines
TimeProfile(final Id< TransitLine > lineName, final Id< TransitLineRoute > lineRouteName, final Id< TimeProfile > index, final String dirCode, final String vehCombNr)
TransitLine(final Id< TransitLine > id, final String tCode, final String vehCombNo)
final Map< String, TransitLineRoute > lineRoutes
void addLineRouteItem(final LineRouteItem lri1)
void addTimeProfileItem(final TimeProfileItem tpi1)
final Map< String, TimeProfile > timeProfiles
void addDeparture(final Departure d)
void addVehicleUnit(final VehicleUnit vehUnit)
final Map< String, LineRouteItem > lineRouteItems