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-sim.org/
12 // Copyright (C) 2001-2014 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 "city/AGStreet.h"
36 #include "AGActivityTripWriter.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
42 void
44  vtypes();
45 }
46 
47 void
49  routes << " <vType id=\"default\" accel=\"4.0\" decel=\"8.0\" sigma=\"0.0\" length=\"5\" minGap=\"2.5\" maxSpeed=\"90\"/>\n";
50  routes << " <vType id=\"random\" accel=\"4.0\" decel=\"8.0\" sigma=\"0.0\" length=\"5\" minGap=\"2.5\" maxSpeed=\"90\"/>\n";
51  routes << " <vType id=\"bus\" accel=\"2.0\" decel=\"4.0\" sigma=\"0.0\" length=\"10\" minGap=\"3\" maxSpeed=\"70\"/>\n\n";
52 
53  colors["default"] = "1,0,0";
54  colors["bus"] = "0,1,0";
55  colors["random"] = "0,0,1";
56 }
57 
58 void
60  std::list<AGPosition>::iterator it;
61  int time = (trip.getDay() - 1) * 86400 + trip.getTime();
62 
63  //the vehicle:
64  routes << " <vehicle"
65  << " id=\"" << trip.getVehicleName()
66  << "\" type=\"" << trip.getType()
67  << "\" depart=\"" << time
68  << "\" departPos=\"" << trip.getDep().getPosition()
69  << "\" arrivalPos=\"" << trip.getArr().getPosition()
70  << "\" departSpeed=\"" << 0
71  << "\" arrivalSpeed=\"" << 0
72  << "\" color=\"" << colors[trip.getType()]
73  << "\">\n";
74 
75  //the route
76  routes << " <route edges=\"" << trip.getDep().getStreet().getName();
77  for (it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) {
78  routes << " " << it->getStreet().getName();
79  }
80  routes << " " << trip.getArr().getStreet().getName();
81  routes << "\"/>\n";
82 
83  routes << " </vehicle>\n";
84 }
85 
86 
87 /****************************************************************************/
AGPosition getDep() const
Definition: AGTrip.cpp:105
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
Definition: AGPosition.cpp:108
std::list< AGPosition > * getPassed()
Definition: AGTrip.cpp:90
std::map< std::string, std::string > colors
SUMOReal getPosition() const
Provides the relative position of this AGPosition on the street.
Definition: AGPosition.cpp:114
int getTime() const
Definition: AGTrip.cpp:115
const std::string & getName() const
Provides the id of this edge.
Definition: AGStreet.cpp:64
const std::string & getVehicleName() const
Definition: AGTrip.cpp:159
AGPosition getArr() const
Definition: AGTrip.cpp:110
int getDay() const
Definition: AGTrip.cpp:184
Definition: AGTrip.h:48
const std::string & getType() const
Definition: AGTrip.cpp:95