Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
AGActivityTripWriter.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// activitygen module
5// Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6// This program and the accompanying materials are made available under the
7// terms of the Eclipse Public License 2.0 which is available at
8// https://www.eclipse.org/legal/epl-2.0/
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License 2.0 are satisfied: GNU General Public License, version 2
12// or later which is available at
13// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15/****************************************************************************/
22// Class for writing Trip objects in a SUMO-route file.
23/****************************************************************************/
24#include <config.h>
25
28#include "activities/AGTrip.h"
29#include "city/AGStreet.h"
31
32
33// ===========================================================================
34// method definitions
35// ===========================================================================
51
52
53void
55 int time = (trip.getDay() - 1) * 86400 + trip.getTime();
56
59 .writeAttr(SUMO_ATTR_TYPE, trip.getType())
60 .writeAttr(SUMO_ATTR_DEPART, time2string(TIME2STEPS(time)))
61 .writeAttr(SUMO_ATTR_DEPARTPOS, trip.getDep().getPosition())
62 .writeAttr(SUMO_ATTR_ARRIVALPOS, trip.getArr().getPosition())
63 .writeAttr(SUMO_ATTR_ARRIVALSPEED, 0.)
65
66 if (!trip.getPassed()->empty()) {
67 std::ostringstream oss;
68 for (std::list<AGPosition>::const_iterator it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) {
69 if (it != trip.getPassed()->begin()) {
70 oss << " ";
71 }
72 oss << it->getStreet().getID();
73 }
75 }
78}
79
80
81/****************************************************************************/
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
#define TIME2STEPS(x)
Definition SUMOTime.h:57
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_VIA
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
AGActivityTripWriter(OutputDevice &file)
void addTrip(const AGTrip &trip)
double getPosition() const
Provides the relative position of this AGPosition on the street.
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
const std::list< AGPosition > * getPassed() const
Definition AGTrip.cpp:81
AGPosition getDep() const
Definition AGTrip.cpp:96
int getTime() const
Definition AGTrip.cpp:106
const std::string & getType() const
Definition AGTrip.cpp:86
AGPosition getArr() const
Definition AGTrip.cpp:101
int getDay() const
Definition AGTrip.cpp:175
const std::string & getVehicleName() const
Definition AGTrip.cpp:150
const std::string & getID() const
Returns the id.
Definition Named.h:74
Static storage of an output device and its base (abstract) implementation.
void lf()
writes a line feed if applicable
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static const RGBColor BLUE
Definition RGBColor.h:187
static const RGBColor GREEN
Definition RGBColor.h:186
static const RGBColor RED
named colors
Definition RGBColor.h:185