MATSIM
FacilitiesConfigGroup.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * FacilitiesConfigGroup.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007 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.core.config.groups;
22 
23 import java.net.URL;
24 import java.util.Map;
25 
28 
32 public final class FacilitiesConfigGroup extends ReflectiveConfigGroup {
33 
34  public static final String GROUP_NAME = "facilities";
35 
36  private static final String INPUT_FILE= "inputFacilitiesFile";
37  private static final String INPUT_FACILITY_ATTRIBUTES_FILE = "inputFacilityAttributesFile";
38  private static final String INPUT_CRS = "inputCRS";
39  private static final String INSISTING_ON_USING_DEPRECATED_ATTRIBUTE_FILE = "insistingOnUsingDeprecatedFacilitiesAttributeFile" ;
40 
41  private String inputFile = null;
42  private String inputFacilitiesAttributesFile = null;
43  private String inputCRS = null;
45 
46  // following params are required only if activitiesFacilities are generated internally (e.g., FacilitiesSource.onePerActivityLocationInPlansFile). Amit Jan'18
47  private String idPrefix = "f_auto_";
48 // private boolean removingLinksAndCoordinates = true;
49 // private boolean assigningOpeningTime = false;
50 // private boolean assigningLinksToFacilitiesIfMissing = true;
51 
52  private static final String FACILITIES_SOURCE = "facilitiesSource";
53  public enum FacilitiesSource {none, fromFile, setInScenario, onePerActivityLinkInPlansFile,
54  onePerActivityLinkInPlansFileExceptWhenCoordinatesAreGiven, onePerActivityLocationInPlansFile}
55 
57 // private boolean addEmptyActivityOption = false;
58 
59 // private static final String ADD_EMPTY_ACTIVITY_OPTIONS = "addEmptyActivityOption";
60  private static final String ID_PREFIX="idPrefix";
61 // private static final String REMOVING_LINKS_AND_COORDINATES = "removingLinksAndCoordinates";
62 // private static final String ASSIGNING_OPENING_TIME = "assigningOpeningTime";
63 // private static final String ASSIGNING_LINKS_TO_FACILITIES_IF_MISSING="assigningLinksToFacilitiesIfMissing";
64 
65  public static final String FACILITIES_ATTRIBUTES_DEPRECATION_MESSAGE = "using the separate facilities attribute file is deprecated. Add the information directly into each facility, using " +
66  "the Attributable feature. If you insist on continuing to use the separate facility attribute file, set " +
67  "insistingOnUsingDeprecatedFacilityAttributeFile to true. The file will then be read, but the values " +
68  "will be entered into each facility using Attributable, and written as such to output_facilities.";
69 
71  super(GROUP_NAME);
72  }
73 
74  @Override
75  public Map<String,String> getComments() {
76  final Map<String,String> comments = super.getComments();
77 
78  comments.put( INPUT_CRS , "The Coordinates Reference System in which the coordinates are expressed in the input file." +
79  " At import, the coordinates will be converted to the coordinate system defined in \"global\", and will" +
80  "be converted back at export. If not specified, no conversion happens." );
81 
82  {
83  StringBuilder options = new StringBuilder();
84  for ( FacilitiesSource source : FacilitiesSource.values() ) {
85  options.append(source);
86  options.append(' ');
87  }
88  comments.put(FACILITIES_SOURCE, "This defines how facilities should be created. Possible values: "+options.toString());
89  }
90 
91  comments.put( ID_PREFIX, "A prefix to be used for auto-generated IDs.");
92 
93 // comments.put(ONE_FACILITY_PER_LINK, "Sets whether all activities on a link should be collected within one ActivityFacility." +
94 // " Default is 'true'. If set to 'false', for each coordinate found in the population's activities a separate ActivityFacility will be created.");
95 
96 // comments.put(REMOVING_LINKS_AND_COORDINATES, "If set to 'true' (which is the default), the link and coordinate attributes " +
97 // "are replaced by null reference in the activities, as this information is now available via the facility.");
98 //
99 // comments.put(ADD_EMPTY_ACTIVITY_OPTIONS, "If set to 'true', empty activity option will be created.");
100 //
101 // comments.put(ASSIGNING_OPENING_TIME, "If set to 'true', opening time will be assigned to activity facilities from ActivityParams. Default is false. This will NOT override option 'addEmptyActivityOption'.");
102 
103 // comments.put(ASSIGNING_LINKS_TO_FACILITIES_IF_MISSING, "Default is 'true'. In the case that a facility has no link assigned, the ActivityFacility can be assigned to the closest link." +
104 // " If there should be only one ActivityFacility per link and if no link-assignment should be done, set to 'false'." +
105 // "This will create a new ActivityFacility at the coordinate and the facility will not be assigned to a link.");
106  return comments;
107  }
108 
109  /* direct access */
110 
111  @StringGetter( INPUT_FILE )
112  public String getInputFile() {
113  return this.inputFile;
114  }
116  public void setInputFile(final String inputFile) {
117  this.inputFile = inputFile;
118  }
119 
120  public URL getInputFileURL(URL context) {
121  return ConfigGroup.getInputFileURL(context, this.inputFile);
122  }
123 
125  @Deprecated // I think that this should be phased out; use Attributes inside each facility. kai, mar'19
127  return this.inputFacilitiesAttributesFile;
128  }
129 
131  @Deprecated // I think that this should be phased out; use Attributes inside each facility. kai, mar'19
133  this.inputFacilitiesAttributesFile = inputFacilitiesAttributesFile;
134  }
135 
137  public String getInputCRS() {
138  return inputCRS;
139  }
140 
142  public void setInputCRS(String inputCRS) {
143  this.inputCRS = inputCRS;
144  }
145 
147  public String getIdPrefix() {
148  return idPrefix;
149  }
150 
152  public void setIdPrefix(String idPrefix) {
153  this.idPrefix = idPrefix;
154  }
155 
156 // @StringGetter(ONE_FACILITY_PER_LINK)
157 // public boolean isOneFacilityPerLink() {
158 // return oneFacilityPerLink;
159 // }
160 //
161 // @StringSetter(ONE_FACILITY_PER_LINK)
162 // public void setOneFacilityPerLink(boolean oneFacilityPerLink) {
163 // this.oneFacilityPerLink = oneFacilityPerLink;
164 // }
165 
166 // @StringGetter(REMOVING_LINKS_AND_COORDINATES)
167 // public boolean isRemovingLinksAndCoordinates() {
168 // return removingLinksAndCoordinates;
169 // }
170 
171 // @StringSetter(REMOVING_LINKS_AND_COORDINATES)
172 // public void setRemovingLinksAndCoordinates(boolean removingLinksAndCoordinates) {
173 // this.removingLinksAndCoordinates = removingLinksAndCoordinates;
174 // }
175 //
177 // public boolean isAssigningOpeningTime() {
178 // return assigningOpeningTime;
179 // }
180 //
182 // public void setAssigningOpeningTime(boolean assigningOpeningTime) {
183 // this.assigningOpeningTime = assigningOpeningTime;
184 // }
185 
186 // @StringGetter(ASSIGNING_LINKS_TO_FACILITIES_IF_MISSING)
187 // public boolean isAssigningLinksToFacilitiesIfMissing() {
188 // return assigningLinksToFacilitiesIfMissing;
189 // }
190 
191 // @StringSetter(ASSIGNING_LINKS_TO_FACILITIES_IF_MISSING)
192 // public void setAssigningLinksToFacilitiesIfMissing(boolean assigningLinksToFacilitiesIfMissing) {
193 // this.assigningLinksToFacilitiesIfMissing = assigningLinksToFacilitiesIfMissing;
194 // }
195 
198  return this.facilitiesSource;
199  }
200 
204  }
205 
207  public final void setInsistingOnUsingDeprecatedFacilitiesAttributeFile( boolean val ) {
209  }
213  }
214 
216 // public boolean isAddEmptyActivityOption() {
217 // return addEmptyActivityOption;
218 // }
219 //
221 // public void setAddEmptyActivityOption(boolean addEmptyActivityOption) {
222 // this.addEmptyActivityOption = addEmptyActivityOption;
223 // }
224 }
void setInputFacilitiesAttributesFile(String inputFacilitiesAttributesFile)
void setFacilitiesSource(FacilitiesSource facilitiesSource)
static URL getInputFileURL(URL context, String filename)