SUMO - Simulation of Urban MObility
ROJTRFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Sets and checks options for jtr-routing
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 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 <iostream>
34 #include <fstream>
35 #include <ctime>
37 #include <utils/options/Option.h>
40 #include <utils/common/ToString.h>
41 #include "ROJTRFrame.h"
42 #include <router/ROFrame.h>
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
51 void
54  oc.addCallExample("-c <CONFIGURATION>", "run with routing options defined in file");
55 
56  // insert options sub-topics
58  oc.addOptionSubTopic("Input");
59  oc.addOptionSubTopic("Output");
60  oc.addOptionSubTopic("Processing");
61  oc.addOptionSubTopic("Defaults");
62  oc.addOptionSubTopic("Time");
63  SystemFrame::addReportOptions(oc); // fill this subtopic, too
64 
65  ROFrame::fillOptions(oc, false);
66 
67  oc.doRegister("turn-ratio-files", 't', new Option_FileName());
68  oc.addSynonyme("turn-ratio-files", "turns");
69  oc.addDescription("turn-ratio-files", "Input", "Read turning ratios from FILE(s)");
70 
71  oc.doRegister("exit-times", new Option_Bool(false));
72  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
73 
74  oc.doRegister("max-edges-factor", new Option_Float(2.0));
75  oc.addDescription("max-edges-factor", "Processing", "Routes are cut off when the route edges to net edges ratio is larger than FLOAT");
76 
77  oc.doRegister("turn-defaults", 'T', new Option_String("30,50,20"));
78  oc.addDescription("turn-defaults", "Processing", "Use STR as default turn definition");
79 
80  oc.doRegister("sink-edges", new Option_String());
81  oc.addSynonyme("sink-edges", "sinks");
82  oc.addDescription("sink-edges", "Processing", "Use STR as list of sink edges");
83 
84  oc.doRegister("accept-all-destinations", 'A', new Option_Bool(false));
85  oc.addDescription("accept-all-destinations", "Processing", "Whether all edges are allowed as sink edges");
86 
87  oc.doRegister("ignore-vclasses", 'i', new Option_Bool(false));
88  oc.addDescription("ignore-vclasses", "Processing", "Ignore road restrictions based on vehicle class");
89 
90  oc.doRegister("allow-loops", new Option_Bool(false));
91  oc.addDescription("allow-loops", "Processing", "Allow to re-use a road");
92 
93  // add rand options
95 }
96 
97 
98 bool
101  bool ok = ROFrame::checkOptions(oc);
102 
104  std::string error;
105  if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
106  WRITE_ERROR(error);
107  ok = false;
108  }
109  if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
110  WRITE_ERROR(error);
111  ok = false;
112  }
113  if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
114  WRITE_ERROR(error);
115  ok = false;
116  }
117  if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
118  WRITE_ERROR(error);
119  ok = false;
120  }
121  if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
122  WRITE_ERROR(error);
123  ok = false;
124  }
125  if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
126  WRITE_ERROR(error);
127  ok = false;
128  }
129  return ok;
130 }
131 
132 
133 /****************************************************************************/
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:82
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:49
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:72
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:47
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
double departSpeed
(optional) The initial speed of the vehicle
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
static void fillOptions(OptionsCont &oc, bool forDuarouter)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:50
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:188
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double arrivalPos
(optional) The position the vehicle shall arrive on
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
double departPos
(optional) The position the vehicle shall depart from
Structure representing possible vehicle parameter.
static void fillOptions()
Inserts options used by jtrrouter into the OptionsCont-singleton.
Definition: ROJTRFrame.cpp:52
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within jtrrouter...
Definition: ROJTRFrame.cpp:99
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
A storage for options typed value containers)
Definition: OptionsCont.h:99
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.