SUMO - Simulation of Urban MObility
AGActivityTripWriter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Class for writing Trip objects in a SUMO-route file.
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 // activitygen module
14 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <utils/common/RGBColor.h>
37 #include "activities/AGTrip.h"
38 #include "city/AGStreet.h"
39 #include "AGActivityTripWriter.h"
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
47  .writeAttr(SUMO_ATTR_ID, "default")
48  .writeAttr(SUMO_ATTR_VCLASS, "passenger")
51  .writeAttr(SUMO_ATTR_ID, "random")
52  .writeAttr(SUMO_ATTR_VCLASS, "passenger")
55  .writeAttr(SUMO_ATTR_ID, "bus")
58  myTripOutput.lf();
59 }
60 
61 
62 void
64  int time = (trip.getDay() - 1) * 86400 + trip.getTime();
65 
68  .writeAttr(SUMO_ATTR_TYPE, trip.getType())
69  .writeAttr(SUMO_ATTR_DEPART, time)
71  .writeAttr(SUMO_ATTR_ARRIVALPOS, trip.getArr().getPosition())
72  .writeAttr(SUMO_ATTR_ARRIVALSPEED, 0.)
74 
75  if (!trip.getPassed()->empty()) {
76  std::ostringstream oss;
77  for (std::list<AGPosition>::const_iterator it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) {
78  if (it != trip.getPassed()->begin()) {
79  oss << " ";
80  }
81  oss << it->getStreet().getID();
82  }
84  }
87 }
88 
89 
90 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
static const RGBColor BLUE
Definition: RGBColor.h:191
AGPosition getDep() const
Definition: AGTrip.cpp:105
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
Definition: AGPosition.cpp:108
SUMOReal getPosition() const
Provides the relative position of this AGPosition on the street.
Definition: AGPosition.cpp:114
const std::string & getID() const
Returns the id.
Definition: Named.h:65
static const RGBColor GREEN
Definition: RGBColor.h:190
const std::list< AGPosition > * getPassed() const
Definition: AGTrip.cpp:90
int getTime() const
Definition: AGTrip.cpp:115
const std::string & getVehicleName() const
Definition: AGTrip.cpp:159
AGPosition getArr() const
Definition: AGTrip.cpp:110
static const RGBColor RED
Definition: RGBColor.h:189
AGActivityTripWriter(OutputDevice &file)
void addTrip(const AGTrip &trip)
int getDay() const
Definition: AGTrip.cpp:184
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
A color information.
Definition: AGTrip.h:48
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:235
const std::string & getType() const
Definition: AGTrip.cpp:95