Eclipse SUMO - Simulation of Urban MObility
AGActivityTripWriter.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-2019 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
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 // SPDX-License-Identifier: EPL-2.0
11 /****************************************************************************/
19 // Class for writing Trip objects in a SUMO-route file.
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <utils/common/RGBColor.h>
30 #include "activities/AGTrip.h"
31 #include "city/AGStreet.h"
32 #include "AGActivityTripWriter.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
40  .writeAttr(SUMO_ATTR_ID, "default")
41  .writeAttr(SUMO_ATTR_VCLASS, "passenger")
44  .writeAttr(SUMO_ATTR_ID, "random")
45  .writeAttr(SUMO_ATTR_VCLASS, "passenger")
48  .writeAttr(SUMO_ATTR_ID, "bus")
51  myTripOutput.lf();
52 }
53 
54 
55 void
57  int time = (trip.getDay() - 1) * 86400 + trip.getTime();
58 
61  .writeAttr(SUMO_ATTR_TYPE, trip.getType())
62  .writeAttr(SUMO_ATTR_DEPART, time2string(TIME2STEPS(time)))
63  .writeAttr(SUMO_ATTR_DEPARTPOS, trip.getDep().getPosition())
64  .writeAttr(SUMO_ATTR_ARRIVALPOS, trip.getArr().getPosition())
65  .writeAttr(SUMO_ATTR_ARRIVALSPEED, 0.)
67 
68  if (!trip.getPassed()->empty()) {
69  std::ostringstream oss;
70  for (std::list<AGPosition>::const_iterator it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) {
71  if (it != trip.getPassed()->begin()) {
72  oss << " ";
73  }
74  oss << it->getStreet().getID();
75  }
77  }
80 }
81 
82 
83 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
static const RGBColor BLUE
Definition: RGBColor.h:192
description of a vehicle type
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
const std::list< AGPosition > * getPassed() const
Definition: AGTrip.cpp:83
const std::string & getID() const
Returns the id.
Definition: Named.h:77
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
AGPosition getArr() const
Definition: AGTrip.cpp:103
static const RGBColor GREEN
Definition: RGBColor.h:191
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
Definition: AGPosition.cpp:101
int getTime() const
Definition: AGTrip.cpp:108
int getDay() const
Definition: AGTrip.cpp:177
const std::string & getVehicleName() const
Definition: AGTrip.cpp:152
static const RGBColor RED
named colors
Definition: RGBColor.h:190
AGActivityTripWriter(OutputDevice &file)
void addTrip(const AGTrip &trip)
AGPosition getDep() const
Definition: AGTrip.cpp:98
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
a single trip definition (used by router)
const std::string & getType() const
Definition: AGTrip.cpp:88
double getPosition() const
Provides the relative position of this AGPosition on the street.
Definition: AGPosition.cpp:107
A color information.
Definition: AGTrip.h:41
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:234