Eclipse SUMO - Simulation of Urban MObility
ROMARouteHandler.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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Parser and container for routes during their loading
22 /****************************************************************************/
23 #include <config.h>
24 
29 #include <od/ODMatrix.h>
30 #include "ROMARouteHandler.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
37  SUMOSAXHandler(""), myMatrix(matrix) {
38  if (OptionsCont::getOptions().isSet("taz-param")) {
40  }
41 }
42 
43 
45 }
46 
47 
48 void
50  if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE) {
54  }
57  }
58  } else if (element == SUMO_TAG_PARAM && !myTazParamKeys.empty()) {
59  if (attrs.getString(SUMO_ATTR_KEY) == myTazParamKeys[0]) {
62  }
63  if (myTazParamKeys.size() > 1 && attrs.getString(SUMO_ATTR_KEY) == myTazParamKeys[1]) {
66  }
67  }
68 }
69 
70 
71 void
73  if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE) {
74  if (myVehicleParameter->fromTaz == "" || myVehicleParameter->toTaz == "") {
75  WRITE_WARNING("No origin or no destination given, ignoring '" + myVehicleParameter->id + "'!");
76  } else {
80  }
81  delete myVehicleParameter;
82  }
83 }
84 
85 
86 /****************************************************************************/
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
const int VEHPARS_TO_TAZ_SET
const int VEHPARS_FROM_TAZ_SET
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_KEY
An O/D (origin/destination) matrix.
Definition: ODMatrix.h:67
bool add(double vehicleNumber, SUMOTime begin, SUMOTime end, const std::string &origin, const std::string &destination, const std::string &vehicleType, const bool originIsEdge=false, const bool destinationIsEdge=false)
Builds a single cell from the given values, verifying them.
Definition: ODMatrix.cpp:67
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::vector< std::string > myTazParamKeys
The keys for reading taz.
ODMatrix & myMatrix
The matrix to fill.
SUMOVehicleParameter * myVehicleParameter
The current vehicle parameters.
ROMARouteHandler(ODMatrix &matrix)
standard constructor
virtual ~ROMARouteHandler()
standard destructor
Encapsulated SAX-Attributes.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
std::string vtypeid
The vehicle's type id.
std::string id
The vehicle's id.
bool wasSet(int what) const
Returns whether the given parameter was set.
std::string toTaz
The vehicle's destination zone (district)
std::string fromTaz
The vehicle's origin zone (district)
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false)
Parses a vehicle's attributes.