SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Sets and checks options for netbuild
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <fstream>
35 #include "NBFrame.h"
36 #include "NBNodeCont.h"
37 #include "NBEdgeCont.h"
39 #include "NBDistrictCont.h"
40 #include "NBDistribution.h"
41 #include "NBRequest.h"
42 #include "NBTypeCont.h"
47 #include <utils/common/ToString.h>
51 
52 #ifdef CHECK_MEMORY_LEAKS
53 #include <foreign/nvwa/debug_new.h>
54 #endif // CHECK_MEMORY_LEAKS
55 
56 
57 // ===========================================================================
58 // method definitions
59 // ===========================================================================
60 void
61 NBFrame::fillOptions(bool forNetgen) {
63  // register building defaults
64  oc.doRegister("default.lanenumber", 'L', new Option_Integer(1));
65  oc.addSynonyme("default.lanenumber", "lanenumber", true);
66  oc.addDescription("default.lanenumber", "Building Defaults", "The default number of lanes in an edge");
67 
68  oc.doRegister("default.speed", 'S', new Option_Float((SUMOReal) 13.9));
69  oc.addSynonyme("default.speed", "speed", true);
70  oc.addDescription("default.speed", "Building Defaults", "The default speed on an edge (in m/s)");
71 
72  oc.doRegister("default.priority", 'P', new Option_Integer(-1));
73  oc.addSynonyme("default.priority", "priority", true);
74  oc.addDescription("default.priority", "Building Defaults", "The default priority of an edge");
75 
76  oc.doRegister("default.sidewalk-width", new Option_Float((SUMOReal) 2.0));
77  oc.addDescription("default.sidewalk-width", "Building Defaults", "The default width of added sidewalks");
78 
79  // register the data processing options
80  oc.doRegister("no-internal-links", new Option_Bool(false)); // !!! not described
81  oc.addDescription("no-internal-links", "Processing", "Omits internal links");
82 
83  if (!forNetgen) {
84  oc.doRegister("dismiss-vclasses", new Option_Bool(false));
85  oc.addDescription("dismiss-vclasses", "Processing", "Removes vehicle class restrictions from imported edges");
86  }
87 
88  oc.doRegister("no-turnarounds", new Option_Bool(false));
89  oc.addDescription("no-turnarounds", "Processing", "Disables building turnarounds");
90 
91  oc.doRegister("no-turnarounds.tls", new Option_Bool(false));
92  oc.addSynonyme("no-turnarounds.tls", "no-tls-turnarounds", true);
93  oc.addDescription("no-turnarounds.tls", "Processing", "Disables building turnarounds at tls-controlled junctions");
94 
95  oc.doRegister("no-left-connections", new Option_Bool(false));
96  oc.addDescription("no-left-connections", "Processing", "Disables building connections to left");
97 
98  if (!forNetgen) {
99  oc.doRegister("geometry.split", new Option_Bool(false)); // !!!not described
100  oc.addSynonyme("geometry.split", "split-geometry", true);
101  oc.addDescription("geometry.split", "Processing", "Splits edges across geometry nodes");
102 
103  oc.doRegister("geometry.remove", 'R', new Option_Bool(false));
104  oc.addSynonyme("geometry.remove", "remove-geometry", true);
105  oc.addDescription("geometry.remove", "Processing", "Replace nodes which only define edge geometry by geometry points (joins edges)");
106 
107  oc.doRegister("geometry.max-segment-length", new Option_Float(0));
108  oc.addDescription("geometry.max-segment-length", "Processing", "splits geometry to restrict segment length");
109 
110  oc.doRegister("geometry.min-dist", new Option_Float());
111  oc.addDescription("geometry.min-dist", "Processing", "reduces too similar geometry points");
112 
113  oc.doRegister("geometry.max-angle", new Option_Float(99));
114  oc.addDescription("geometry.max-angle", "Processing", "Warn about edge geometries with an angle above DEGREES in successive segments");
115 
116  oc.doRegister("geometry.min-radius", new Option_Float(9));
117  oc.addDescription("geometry.min-radius", "Processing", "Warn about edge geometries with a turning radius less than METERS at the start or end");
118 
119  oc.doRegister("geometry.min-radius.fix", new Option_Bool(false));
120  oc.addDescription("geometry.min-radius.fix", "Processing", "Straighten edge geometries to avoid turning radii less than geometry.min-radius");
121 
122  oc.doRegister("geometry.junction-mismatch-threshold", new Option_Float(20));
123  oc.addDescription("geometry.junction-mismatch-threshold", "Processing", "Warn if the junction shape is to far away from the original node position");
124  }
125 
126  oc.doRegister("offset.disable-normalization", new Option_Bool(false));
127  oc.addSynonyme("offset.disable-normalization", "disable-normalize-node-positions", true);
128  oc.addDescription("offset.disable-normalization", "Processing", "Turn off normalizing node positions");
129 
130  oc.doRegister("offset.x", new Option_Float(0));
131  oc.addSynonyme("offset.x", "x-offset-to-apply", true);
132  oc.addDescription("offset.x", "Processing", "Adds FLOAT to net x-positions");
133 
134  oc.doRegister("offset.y", new Option_Float(0));
135  oc.addSynonyme("offset.y", "y-offset-to-apply", true);
136  oc.addDescription("offset.y", "Processing", "Adds FLOAT to net y-positions");
137 
138  oc.doRegister("flip-y-axis", new Option_Bool(false));
139  oc.addSynonyme("flip-y-axis", "flip-y");
140  oc.addDescription("flip-y-axis", "Processing", "Flips the y-coordinate along zero");
141 
142  oc.doRegister("roundabouts.guess", new Option_Bool(false));
143  oc.addSynonyme("roundabouts.guess", "guess-roundabouts", true);
144  oc.addDescription("roundabouts.guess", "Processing", "Enable roundabout-guessing");
145 
146  oc.doRegister("lefthand", new Option_Bool(false));
147  oc.addDescription("lefthand", "Processing", "Assumes left-hand traffic on the network");
148 
149  oc.doRegister("junctions.join", new Option_Bool(false));
150  oc.addDescription("junctions.join", "Processing",
151  "Joins junctions that are close to each other (recommended for OSM import)");
152 
153  oc.doRegister("junctions.join-dist", new Option_Float(10));
154  oc.addDescription("junctions.join-dist", "Processing",
155  "Determines the maximal distance for joining junctions (defaults to 10)");
156 
157  if (!forNetgen) {
158  oc.doRegister("junctions.join-exclude", new Option_String());
159  oc.addDescription("junctions.join-exclude", "Processing", "Interprets STR as list of junctions to exclude from joining");
160 
161  oc.doRegister("speed.offset", new Option_Float(0));
162  oc.addDescription("speed.offset", "Processing", "Modifies all edge speeds by adding FLOAT");
163 
164  oc.doRegister("speed.factor", new Option_Float(1));
165  oc.addDescription("speed.factor", "Processing", "Modifies all edge speeds by multiplying FLOAT");
166  }
167 
168 
169  oc.doRegister("check-lane-foes.roundabout", new Option_Bool(true));
170  oc.addDescription("check-lane-foes.roundabout", "Processing",
171  "Allow driving onto a multi-lane road if there are foes on other lanes (at roundabouts)");
172 
173  oc.doRegister("check-lane-foes.all", new Option_Bool(false));
174  oc.addDescription("check-lane-foes.all", "Processing",
175  "Allow driving onto a multi-lane road if there are foes on other lanes (everywhere)");
176 
177  oc.doRegister("sidewalks.guess", new Option_Bool(false));
178  oc.addDescription("sidewalks.guess", "Processing",
179  "Guess pedestrian sidewalks based on edge speed");
180 
181  oc.doRegister("sidewalks.guess.max-speed", new Option_Float((SUMOReal) 13.89));
182  oc.addDescription("sidewalks.guess.max-speed", "Processing",
183  "Add sidewalks for edges with a speed equal or below the given limit");
184 
185  oc.doRegister("sidewalks.guess.min-speed", new Option_Float((SUMOReal) 5.8));
186  oc.addDescription("sidewalks.guess.min-speed", "Processing",
187  "Add sidewalks for edges with a speed above the given limit");
188 
189  oc.doRegister("crossings.guess", new Option_Bool(false));
190  oc.addDescription("crossings.guess", "Processing",
191  "Guess pedestrian crossings based on the presence of sidewalks");
192 
193  // tls setting options
194  // explicit tls
195  oc.doRegister("tls.set", new Option_String());
196  oc.addSynonyme("tls.set", "explicite-tls", true);
197  oc.addDescription("tls.set", "TLS Building", "Interprets STR as list of junctions to be controlled by TLS");
198 
199  oc.doRegister("tls.unset", new Option_String());
200  oc.addSynonyme("tls.unset", "explicite-no-tls", true);
201  oc.addDescription("tls.unset", "TLS Building", "Interprets STR as list of junctions to be not controlled by TLS");
202 
203  // tls-guessing
204  oc.doRegister("tls.guess", new Option_Bool(false));
205  oc.addSynonyme("tls.guess", "guess-tls", true);
206  oc.addDescription("tls.guess", "TLS Building", "Turns on TLS guessing");
207 
208  if (!forNetgen) {
209  oc.doRegister("tls.taz-nodes", new Option_Bool(false));
210  oc.addSynonyme("tls.taz-nodes", "tls-guess.district-nodes", true);
211  oc.addDescription("tls.taz-nodes", "TLS Building", "Sets district nodes as tls-controlled"); // !!! describe
212  }
213 
214  oc.doRegister("tls-guess.joining", new Option_Bool(false));
215  oc.addDescription("tls-guess.joining", "TLS Building", "Includes node clusters into guess"); // !!! describe
216 
217  oc.doRegister("tls.join", new Option_Bool(false));
218  oc.addSynonyme("tls.join", "try-join-tls", true);
219  oc.addDescription("tls.join", "TLS Building", "Tries to cluster tls-controlled nodes"); // !!! describe
220 
221  oc.doRegister("tls.join-dist", new Option_Float(20));
222  oc.addDescription("tls.join-dist", "Processing",
223  "Determines the maximal distance for joining traffic lights (defaults to 20)");
224 
225  if (!forNetgen) {
226  oc.doRegister("tls.guess-signals", new Option_Bool(false));
227  oc.addDescription("tls.guess-signals", "Processing", "Interprets tls nodes surrounding an intersection as signal positions for a larger TLS. This is typical pattern for OSM-derived networks");
228 
229  oc.doRegister("tls.guess-signals.dist", new Option_Float(25));
230  oc.addDescription("tls.guess-signals.dist", "Processing", "Distance for interpreting nodes as signal locations");
231  }
232 
233 
234  // computational
235  oc.doRegister("tls.green.time", new Option_Integer(31));
236  oc.addSynonyme("tls.green.time", "traffic-light-green", true);
237  oc.addDescription("tls.green.time", "TLS Building", "Use INT as green phase duration");
238 
239  oc.doRegister("tls.yellow.min-decel", 'D', new Option_Float(3.0));
240  oc.addSynonyme("tls.yellow.min-decel", "min-decel", true);
241  oc.addDescription("tls.yellow.min-decel", "TLS Building", "Defines smallest vehicle deceleration");
242 
243  oc.doRegister("tls.yellow.patch-small", new Option_Bool(false));
244  oc.addSynonyme("tls.yellow.patch-small", "patch-small-tyellow", true);
245  oc.addDescription("tls.yellow.patch-small", "TLS Building", "Given yellow times are patched even if being too short");
246 
247  oc.doRegister("tls.yellow.time", new Option_Integer());
248  oc.addSynonyme("tls.yellow.time", "traffic-light-yellow", true);
249  oc.addDescription("tls.yellow.time", "TLS Building", "Set INT as fixed time for yellow phase durations");
250 
251  // tls-shifts
252  oc.doRegister("tls.half-offset", new Option_String());
253  oc.addSynonyme("tls.half-offset", "tl-logics.half-offset", true);
254  oc.addDescription("tls.half-offset", "TLS Building", "TLSs in STR will be shifted by half-phase");
255 
256  oc.doRegister("tls.quarter-offset", new Option_String());
257  oc.addSynonyme("tls.quarter-offset", "tl-logics.quarter-offset", true);
258  oc.addDescription("tls.quarter-offset", "TLS Building", "TLSs in STR will be shifted by quarter-phase");
259 
260  // tls type
261  oc.doRegister("tls.default-type", new Option_String("static"));
262  oc.addDescription("tls.default-type", "TLS Building", "TLSs with unspecified type will use STR as their algorithm");
263 
264 
265  // edge pruning
266  oc.doRegister("keep-edges.min-speed", new Option_Float());
267  oc.addSynonyme("keep-edges.min-speed", "edges-min-speed", true);
268  oc.addDescription("keep-edges.min-speed", "Edge Removal", "Only keep edges with speed in meters/second > FLOAT");
269 
270  oc.doRegister("remove-edges.explicit", new Option_String());
271  oc.addSynonyme("remove-edges.explicit", "remove-edges");
272  oc.addDescription("remove-edges.explicit", "Edge Removal", "Remove edges in STR");
273 
274  oc.doRegister("keep-edges.explicit", new Option_String());
275  oc.addSynonyme("keep-edges.explicit", "keep-edges");
276  oc.addDescription("keep-edges.explicit", "Edge Removal", "Only keep edges in STR");
277 
278  oc.doRegister("keep-edges.input-file", new Option_FileName());
279  oc.addDescription("keep-edges.input-file", "Edge Removal", "Only keep edges in FILE");
280 
281  if (!forNetgen) {
282  oc.doRegister("keep-edges.postload", new Option_Bool(false));
283  oc.addDescription("keep-edges.postload", "Edge Removal", "Remove edges after joining");
284  }
285 
286  oc.doRegister("keep-edges.in-boundary", new Option_String());
287  oc.addDescription("keep-edges.in-boundary", "Edge Removal", "Only keep edges which are located within the given boundary (given either as CARTESIAN corner coordinates <xmin,ymin,xmax,ymax> or as polygon <x0,y0,x1,y1,...>)");
288 
289  oc.doRegister("keep-edges.in-geo-boundary", new Option_String());
290  oc.addDescription("keep-edges.in-geo-boundary", "Edge Removal", "Only keep edges which are located within the given boundary (given either as GEODETIC corner coordinates <lon-min,lat-min,lon-max,lat-max> or as polygon <lon0,lat0,lon1,lat1,...>)");
291 
292  if (!forNetgen) {
293  oc.doRegister("keep-edges.by-vclass", new Option_String());
294  oc.addDescription("keep-edges.by-vclass", "Edge Removal", "Only keep edges which allow one of the vclasss in STR");
295 
296  oc.doRegister("remove-edges.by-vclass", new Option_String());
297  oc.addDescription("remove-edges.by-vclass", "Edge Removal", "Remove edges which allow only vclasses from STR");
298 
299  oc.doRegister("keep-edges.by-type", new Option_String());
300  oc.addDescription("keep-edges.by-type", "Edge Removal", "Only keep edges where type is in STR");
301 
302  oc.doRegister("remove-edges.by-type", new Option_String());
303  oc.addDescription("remove-edges.by-type", "Edge Removal", "Remove edges where type is in STR");
304 
305  oc.doRegister("remove-edges.isolated", new Option_Bool(false));
306  oc.addSynonyme("remove-edges.isolated", "remove-isolated", true);
307  oc.addDescription("remove-edges.isolated", "Edge Removal", "Removes isolated edges");
308  }
309 
310 
311  // unregulated nodes options
312  oc.doRegister("keep-nodes-unregulated", new Option_Bool(false));
313  oc.addSynonyme("keep-nodes-unregulated", "keep-unregulated");
314  oc.addDescription("keep-nodes-unregulated", "Unregulated Nodes", "All nodes will be unregulated");
315 
316  oc.doRegister("keep-nodes-unregulated.explicit", new Option_String());
317  oc.addSynonyme("keep-nodes-unregulated.explicit", "keep-unregulated.explicit");
318  oc.addSynonyme("keep-nodes-unregulated.explicit", "keep-unregulated.nodes", true);
319  oc.addDescription("keep-nodes-unregulated.explicit", "Unregulated Nodes", "Do not regulate nodes in STR");
320 
321  oc.doRegister("keep-nodes-unregulated.district-nodes", new Option_Bool(false));
322  oc.addSynonyme("keep-nodes-unregulated.district-nodes", "keep-unregulated.district-nodes");
323  oc.addDescription("keep-nodes-unregulated.district-nodes", "Unregulated Nodes", "Do not regulate district nodes");
324 
325 
326  // ramp guessing options
327  if (!forNetgen) {
328  oc.doRegister("ramps.guess", new Option_Bool(false));
329  oc.addSynonyme("ramps.guess", "guess-ramps", true);
330  oc.addDescription("ramps.guess", "Ramp Guessing", "Enable ramp-guessing");
331 
332  oc.doRegister("ramps.max-ramp-speed", new Option_Float(-1));
333  oc.addSynonyme("ramps.max-ramp-speed", "ramp-guess.max-ramp-speed", true);
334  oc.addDescription("ramps.max-ramp-speed", "Ramp Guessing", "Treat edges with speed > FLOAT as no ramps");
335 
336  oc.doRegister("ramps.min-highway-speed", new Option_Float((SUMOReal)(79 / 3.6)));
337  oc.addSynonyme("ramps.min-highway-speed", "ramp-guess.min-highway-speed", true);
338  oc.addDescription("ramps.min-highway-speed", "Ramp Guessing", "Treat edges with speed < FLOAT as no highways");
339 
340  oc.doRegister("ramps.ramp-length", new Option_Float(100));
341  oc.addSynonyme("ramps.ramp-length", "ramp-guess.ramp-length", true);
342  oc.addDescription("ramps.ramp-length", "Ramp Guessing", "Use FLOAT as ramp-length");
343 
344  oc.doRegister("ramps.set", new Option_String());
345  oc.addSynonyme("ramps.set", "ramp-guess.explicite", true);
346  oc.addDescription("ramps.set", "Ramp Guessing", "Tries to handle the given edges as ramps");
347 
348  oc.doRegister("ramps.no-split", new Option_Bool(false));
349  oc.addSynonyme("ramps.no-split", "ramp-guess.no-split", true);
350  oc.addDescription("ramps.no-split", "Ramp Guessing", "Avoids edge splitting");
351  }
352 }
353 
354 
355 bool
358  bool ok = true;
359  //
360  if (!oc.isDefault("tls-guess.joining")) {
361  WRITE_WARNING("'--tls-guess.joining' was joined with '--tls.join'.\n Please use '--tls.join' in future only.");
362  if (!oc.isSet("tls.join")) {
363  oc.set("tls.join", "true");
364  }
365  }
366  if (!SUMOXMLDefinitions::TrafficLightTypes.hasString(oc.getString("tls.default-type"))) {
367  WRITE_ERROR("unsupported value '" + oc.getString("tls.default-type") + "' for option '--tls.default-type'");
368  ok = false;
369  }
370  if (oc.isSet("keep-edges.in-boundary") && oc.isSet("keep-edges.in-geo-boundary")) {
371  WRITE_ERROR("only one of the options 'keep-edges.in-boundary' or 'keep-edges.in-geo-boundary' may be given");
372  ok = false;
373  }
374  return ok;
375 }
376 
377 
378 /****************************************************************************/