MATSIM
TransitConfigGroup.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * TransitConfigGroup.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 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.pt.config;
22 
27 
28 import java.net.URL;
29 import java.util.Arrays;
30 import java.util.Collections;
31 import java.util.HashSet;
32 import java.util.LinkedHashSet;
33 import java.util.Map;
34 import java.util.Set;
35 
40 
41  public static final String GROUP_NAME = "transit";
42 
43  /*package*/ static final String TRANSIT_SCHEDULE_FILE = "transitScheduleFile";
44  private static final String TRANSIT_LINES_ATTRIBUTES = "transitLinesAttributesFile";
45  private static final String TRANSIT_STOPS_ATTRIBUTES = "transitStopsAttributesFile";
46  /*package*/ static final String VEHICLES_FILE = "vehiclesFile";
47  /*package*/ static final String TRANSIT_MODES = "transitModes";
48  private static final String SCHEDULE_CRS = "inputScheduleCRS";
49  private static final String ROUTINGALGORITHM_TYPE = "routingAlgorithmType";
50 
51  private static final String INSISTING_ON_USING_DEPRECATED_ATTRIBUTE_FILE = "insistingOnUsingDeprecatedAttributeFiles" ;
52  private static final String USING_TRANSIT_IN_MOBSIM = "usingTransitInMobsim" ;
53 
54  public enum TransitRoutingAlgorithmType {@Deprecated DijkstraBased, SwissRailRaptor}
55 
56  public static final String TRANSIT_ATTRIBUTES_DEPRECATION_MESSAGE = "using the separate transit stops and lines attribute files is deprecated." +
57  " Add the information directly into each stop or line, using " +
58  "the Attributable feature. If you insist on continuing to use the separate attribute files, set " +
59  "insistingOnUsingDeprecatedAttributeFiles to true. The files will then be read, but the values " +
60  "will be entered into each stop or line using Attributable, and written as such to output_transitSchedule.";
61 
62  private String transitScheduleFile = null;
63  private String vehiclesFile = null;
64  private String transitLinesAttributesFile = null;
65  private String transitStopsAttributesFile = null;
66  private String inputScheduleCRS = null;
67 
68  private Set<String> transitModes;
70 
71  // ---
72  private static final String USE_TRANSIT = "useTransit";
73  private boolean useTransit = false;
75 
76  // ---
77 
78  public TransitConfigGroup() {
79  super(GROUP_NAME);
80  Set<String> modes = new LinkedHashSet<>();
81  modes.add(TransportMode.pt);
82  this.transitModes = Collections.unmodifiableSet(modes);
83  }
84 
85  @StringSetter( TRANSIT_MODES )
86  private void setTransitModes( final String value ) {
87  this.transitModes = Collections.unmodifiableSet(CollectionUtils.stringToSet(value));
88  }
89 
90  @StringGetter( TRANSIT_MODES )
91  private String getTransitModeString() {
92  boolean isFirst = true;
93  StringBuilder str = new StringBuilder();
94  for (String mode : this.transitModes) {
95  if (!isFirst) {
96  str.append(',');
97  }
98  str.append(mode);
99  isFirst = false;
100  }
101  return str.toString();
102  }
103 
104  @Override
105  public Map<String, String> getComments() {
106  Map<String, String> comments = super.getComments();
107  comments.put(TRANSIT_SCHEDULE_FILE, "Input file containing the transit schedule to be simulated.");
108  comments.put(VEHICLES_FILE, "Input file containing the vehicles used by the departures in the transit schedule.");
109  comments.put(TRANSIT_MODES, "Comma-separated list of transportation modes that are handled as transit. Defaults to 'pt'.");
110  comments.put(TRANSIT_LINES_ATTRIBUTES, "Optional input file containing additional attributes for transit lines, stored as ObjectAttributes.");
111  comments.put(TRANSIT_STOPS_ATTRIBUTES, "Optional input file containing additional attributes for transit stop facilities, stored as ObjectAttributes.");
112  comments.put(USE_TRANSIT, "Set this parameter to true if transit should be simulated, false if not.");
113  comments.put(ROUTINGALGORITHM_TYPE, "The type of transit routing algorithm used, may have the values: " + Arrays.toString(TransitRoutingAlgorithmType.values()));
114 
115  comments.put( SCHEDULE_CRS , "The Coordinates Reference System in which the coordinates are expressed in the input file." +
116  " At import, the coordinates will be converted to the coordinate system defined in \"global\", and will" +
117  "be converted back at export. If not specified, no conversion happens." );
118  return comments;
119  }
120 
121  @StringSetter( TRANSIT_SCHEDULE_FILE )
122  public void setTransitScheduleFile(final String filename) {
123  this.testForLocked();
124  this.transitScheduleFile = filename;
125  }
126 
127  @StringGetter( TRANSIT_SCHEDULE_FILE )
128  public String getTransitScheduleFile() {
129  return this.transitScheduleFile;
130  }
131 
132  public URL getTransitScheduleFileURL(URL context) {
134  }
135 
136  @StringSetter( VEHICLES_FILE )
137  public void setVehiclesFile(final String filename) {
138  this.vehiclesFile = filename;
139  }
140 
141  @StringGetter( VEHICLES_FILE )
142  public String getVehiclesFile() {
143  return this.vehiclesFile;
144  }
145 
146  public URL getVehiclesFileURL(URL context) {
147  return ConfigGroup.getInputFileURL(context, getVehiclesFile() ) ;
148  }
149 
150  public void setTransitModes(final Set<String> modes) {
151  this.transitModes = Collections.unmodifiableSet(new HashSet<>(modes));
152  }
153 
154  public Set<String> getTransitModes() {
155  return this.transitModes;
156  }
157 
161  }
162 
166  }
167 
170  return this.transitStopsAttributesFile;
171  }
172  public URL getTransitStopsAttributesFileURL(URL context) {
174  }
175 
179  }
180 
182  public boolean isUseTransit() {
183  return this.useTransit;
184  }
186  public void setUseTransit( boolean val ) {
187  this.testForLocked();
188  this.useTransit = val ;
189  }
190 
193  return this.routingAlgorithmType;
194  }
195 
198  this.routingAlgorithmType = type;
199  }
200 
202  public String getInputScheduleCRS() {
203  return inputScheduleCRS;
204  }
205 
207  public void setInputScheduleCRS(String inputScheduleCRS) {
209  }
210 
211  public static final String BOARDING_ACCEPTANCE_CMT="under which conditions agent boards transit vehicle" ;
212  public enum BoardingAcceptance { checkLineAndStop, checkStopOnly }
215  return this.boardingAcceptance;
216  }
217  public void setBoardingAcceptance(BoardingAcceptance boardingAcceptance) {
218  this.boardingAcceptance = boardingAcceptance;
219  }
220 
221  private boolean usingTransitInMobsim = true ;
223  public final void setUsingTransitInMobsim( boolean val ) {
224  usingTransitInMobsim = val ;
225  }
227  public final boolean isUsingTransitInMobsim(){
228  return usingTransitInMobsim ;
229  }
230 
232  public final void setInsistingOnUsingDeprecatedAttributeFiles( boolean val ) {
234  }
238  }
239 
240 }
void setBoardingAcceptance(BoardingAcceptance boardingAcceptance)
void setInputScheduleCRS(String inputScheduleCRS)
void setTransitScheduleFile(final String filename)
static Set< String > stringToSet(final String values)
void setTransitModes(final Set< String > modes)
void setTransitLinesAttributesFile(final String transitLinesAttributesFile)
void setTransitStopsAttributesFile(final String transitStopsAttributesFile)
final void setInsistingOnUsingDeprecatedAttributeFiles(boolean val)
static final String INSISTING_ON_USING_DEPRECATED_ATTRIBUTE_FILE
void setVehiclesFile(final String filename)
static URL getInputFileURL(URL context, String filename)
void setRoutingAlgorithmType(final TransitRoutingAlgorithmType type)
TransitRoutingAlgorithmType getRoutingAlgorithmType()
static final String TRANSIT_ATTRIBUTES_DEPRECATION_MESSAGE
TransitRoutingAlgorithmType routingAlgorithmType