Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
ROMARouteHandler.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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 myIgnoreTaz(OptionsCont::getOptions().getBool("ignore-taz")),
39 myScale(OptionsCont::getOptions().getFloat("scale")),
40 myNumLoaded(0) {
41 if (OptionsCont::getOptions().isSet("taz-param")) {
43 }
44}
45
46
49
50
51void
81
82
83void
85 if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE) {
87 WRITE_WARNINGF(TL("No origin or no destination given, ignoring '%'!"), myVehicleParameter->id);
88 } else {
90 for (int i = 0; i < quota; i++) {
92 veh.id = i == 0 ? myVehicleParameter->id : myVehicleParameter->id + "." + toString(i);
93 myMatrix.add(veh,
96 }
97 myNumLoaded += 1;
98 }
99 delete myVehicleParameter;
100 }
101}
102
103
104/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
const long long int VEHPARS_TO_TAZ_SET
const long long 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_FROM_JUNCTION
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_TO_JUNCTION
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_KEY
int getScalingQuota(double frac, int loaded)
Returns the number of instances of the current object that shall be emitted given the number of loade...
Definition StdDefs.cpp:61
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
An O/D (origin/destination) matrix.
Definition ODMatrix.h:68
bool add(double vehicleNumber, const std::pair< SUMOTime, SUMOTime > &beginEnd, const std::string &origin, const std::string &destination, const std::string &vehicleType, const bool originIsEdge=false, const bool destinationIsEdge=false, bool noScaling=false)
Builds a single cell from the given values, verifying them.
Definition ODMatrix.cpp:75
A storage for options typed value containers)
Definition OptionsCont.h:89
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.
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.
double myScale
scale for loading vehicles
ODMatrix & myMatrix
The matrix to fill.
SUMOVehicleParameter * myVehicleParameter
The current vehicle parameters.
ROMARouteHandler(ODMatrix &matrix)
standard constructor
virtual ~ROMARouteHandler()
standard destructor
const bool myIgnoreTaz
whether to ignore attributes fromTaz, toTaz
int myNumLoaded
number of parsed vehicles
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
Structure representing possible vehicle parameter.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string id
The vehicle's id.
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, const bool allowInternalRoutes=false)
Parses a vehicle's attributes.