SUMO - Simulation of Urban MObility
ROJTRFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Sets and checks options for jtr-routing
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
33 #include <fstream>
34 #include <ctime>
36 #include <utils/options/Option.h>
39 #include <utils/common/ToString.h>
40 #include "ROJTRFrame.h"
41 #include <router/ROFrame.h>
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 void
53  oc.addCallExample("-c <CONFIGURATION>", "run with routing options defined in file");
54 
55  // insert options sub-topics
57  oc.addOptionSubTopic("Input");
58  oc.addOptionSubTopic("Output");
59  oc.addOptionSubTopic("Processing");
60  oc.addOptionSubTopic("Defaults");
61  oc.addOptionSubTopic("Time");
62  SystemFrame::addReportOptions(oc); // fill this subtopic, too
63 
65 
66  oc.doRegister("turn-ratio-files", 't', new Option_FileName());
67  oc.addSynonyme("turn-ratio-files", "turns");
68  oc.addDescription("turn-ratio-files", "Input", "Read turning ratios from FILE(s)");
69 
70  oc.doRegister("exit-times", new Option_Bool(false));
71  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
72 
73  oc.doRegister("max-edges-factor", new Option_Float(2.0));
74  oc.addDescription("max-edges-factor", "Processing", "Routes are cut off when the route edges to net edges ratio is larger than FLOAT");
75 
76  oc.doRegister("turn-defaults", 'T', new Option_String("30,50,20"));
77  oc.addDescription("turn-defaults", "Processing", "Use STR as default turn definition");
78 
79  oc.doRegister("sink-edges", new Option_String());
80  oc.addSynonyme("sink-edges", "sinks");
81  oc.addDescription("sink-edges", "Processing", "Use STR as list of sink edges");
82 
83  oc.doRegister("accept-all-destinations", 'A', new Option_Bool(false));
84  oc.addDescription("accept-all-destinations", "Processing", "Whether all edges are allowed as sink edges");
85 
86  oc.doRegister("ignore-vclasses", 'i', new Option_Bool(false));
87  oc.addDescription("ignore-vclasses", "Processing", "Ignore road restrictions based on vehicle class");
88 
89  oc.doRegister("allow-loops", new Option_Bool(false));
90  oc.addDescription("allow-loops", "Processing", "Allow to re-use a road");
91 
92  // add rand options
94 }
95 
96 
97 bool
100  bool ok = ROFrame::checkOptions(oc);
101 
103  std::string error;
104  if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
105  WRITE_ERROR(error);
106  ok = false;
107  }
108  if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
109  WRITE_ERROR(error);
110  ok = false;
111  }
112  if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
113  WRITE_ERROR(error);
114  ok = false;
115  }
116  if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
117  WRITE_ERROR(error);
118  ok = false;
119  }
120  if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
121  WRITE_ERROR(error);
122  ok = false;
123  }
124  if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
125  WRITE_ERROR(error);
126  ok = false;
127  }
128  return ok;
129 }
130 
131 
132 /****************************************************************************/
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:81
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:47
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:71
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:49
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:46
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
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.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:167
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:205
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:51
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within jtrrouter...
Definition: ROJTRFrame.cpp:98
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:98
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.