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-2017 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 /****************************************************************************/
7 //
8 // This program and the accompanying materials
9 // are made available under the terms of the Eclipse Public License v2.0
10 // which accompanies this distribution, and is available at
11 // http://www.eclipse.org/legal/epl-v20.html
12 //
13 /****************************************************************************/
21 // Class for writing Trip objects in a SUMO-route file.
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <utils/common/RGBColor.h>
36 #include "activities/AGTrip.h"
37 #include "city/AGStreet.h"
38 #include "AGActivityTripWriter.h"
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
46  .writeAttr(SUMO_ATTR_ID, "default")
47  .writeAttr(SUMO_ATTR_VCLASS, "passenger")
50  .writeAttr(SUMO_ATTR_ID, "random")
51  .writeAttr(SUMO_ATTR_VCLASS, "passenger")
54  .writeAttr(SUMO_ATTR_ID, "bus")
57  myTripOutput.lf();
58 }
59 
60 
61 void
63  int time = (trip.getDay() - 1) * 86400 + trip.getTime();
64 
67  .writeAttr(SUMO_ATTR_TYPE, trip.getType())
68  .writeAttr(SUMO_ATTR_DEPART, time)
70  .writeAttr(SUMO_ATTR_ARRIVALPOS, trip.getArr().getPosition())
71  .writeAttr(SUMO_ATTR_ARRIVALSPEED, 0.)
73 
74  if (!trip.getPassed()->empty()) {
75  std::ostringstream oss;
76  for (std::list<AGPosition>::const_iterator it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) {
77  if (it != trip.getPassed()->begin()) {
78  oss << " ";
79  }
80  oss << it->getStreet().getID();
81  }
83  }
86 }
87 
88 
89 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:260
static const RGBColor BLUE
Definition: RGBColor.h:180
description of a vehicle type
const std::list< AGPosition > * getPassed() const
Definition: AGTrip.cpp:89
const std::string & getID() const
Returns the id.
Definition: Named.h:65
AGPosition getArr() const
Definition: AGTrip.cpp:109
static const RGBColor GREEN
Definition: RGBColor.h:179
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
Definition: AGPosition.cpp:107
int getTime() const
Definition: AGTrip.cpp:114
int getDay() const
Definition: AGTrip.cpp:183
const std::string & getVehicleName() const
Definition: AGTrip.cpp:158
static const RGBColor RED
named colors
Definition: RGBColor.h:178
AGActivityTripWriter(OutputDevice &file)
void addTrip(const AGTrip &trip)
AGPosition getDep() const
Definition: AGTrip.cpp:104
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
a single trip definition (used by router)
const std::string & getType() const
Definition: AGTrip.cpp:94
double getPosition() const
Provides the relative position of this AGPosition on the street.
Definition: AGPosition.cpp:113
A color information.
Definition: AGTrip.h:47
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:238