SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
12 // Copyright (C) 2001-2013 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  routes << "<?xml version=\"1.0\"?>" << std::endl << std::endl;
45  routes << "<routes>" << std::endl;
46  vtypes();
47 }
48 
49 void
51  routes << " <vType id=\"default\" accel=\"4.0\" decel=\"8.0\" sigma=\"0.0\" length=\"5\" minGap=\"2.5\" maxSpeed=\"90\"/>" << std::endl;
52  routes << " <vType id=\"random\" accel=\"4.0\" decel=\"8.0\" sigma=\"0.0\" length=\"5\" minGap=\"2.5\" maxSpeed=\"90\"/>" << std::endl;
53  routes << " <vType id=\"bus\" accel=\"2.0\" decel=\"4.0\" sigma=\"0.0\" length=\"10\" minGap=\"3\" maxSpeed=\"70\"/>" << std::endl << std::endl;
54 
55  colors["default"] = "1,0,0";
56  colors["bus"] = "0,1,0";
57  colors["random"] = "0,0,1";
58 }
59 
60 void
62  std::list<AGPosition>::iterator it;
63  int time = (trip.getDay() - 1) * 86400 + trip.getTime();
64 
65  //the vehicle:
66  routes << " <vehicle"
67  << " id=\"" << trip.getVehicleName()
68  << "\" type=\"" << trip.getType()
69  << "\" depart=\"" << time
70  << "\" departPos=\"" << trip.getDep().getPosition()
71  << "\" arrivalPos=\"" << trip.getArr().getPosition()
72  << "\" departSpeed=\"" << 0
73  << "\" arrivalSpeed=\"" << 0
74  << "\" color=\"" << colors[trip.getType()]
75  << "\">" << std::endl;
76 
77  //the route
78  routes << " <route edges=\"" << trip.getDep().getStreet().getName();
79  for (it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) {
80  routes << " " << it->getStreet().getName();
81  }
82  routes << " " << trip.getArr().getStreet().getName();
83  routes << "\"/>" << std::endl;
84 
85  routes << " </vehicle>" << std::endl;
86 }
87 
88 void
90  routes << "</routes>" << std::endl;
91  routes.close();
92 }
93 
94 /****************************************************************************/