|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Class for writing Trip objects in a SUMO-route file. 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 // activitygen module 00012 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/) 00013 /****************************************************************************/ 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; either version 2 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include "city/AGStreet.h" 00033 #include "AGActivityTripWriter.h" 00034 00035 00036 // =========================================================================== 00037 // method definitions 00038 // =========================================================================== 00039 void 00040 AGActivityTripWriter::initialize() { 00041 routes << "<?xml version=\"1.0\"?>" << std::endl << std::endl; 00042 routes << "<routes>" << std::endl; 00043 vtypes(); 00044 } 00045 00046 void 00047 AGActivityTripWriter::vtypes() { 00048 routes << " <vType id=\"default\" accel=\"4.0\" decel=\"8.0\" sigma=\"0.0\" length=\"5\" maxSpeed=\"90\"/>" << std::endl; 00049 routes << " <vType id=\"random\" accel=\"4.0\" decel=\"8.0\" sigma=\"0.0\" length=\"5\" maxSpeed=\"90\"/>" << std::endl; 00050 routes << " <vType id=\"bus\" accel=\"2.0\" decel=\"4.0\" sigma=\"0.0\" length=\"10\" maxSpeed=\"70\"/>" << std::endl << std::endl; 00051 00052 colors["default"] = "1,0,0"; 00053 colors["bus"] = "0,1,0"; 00054 colors["random"] = "0,0,1"; 00055 } 00056 00057 void 00058 AGActivityTripWriter::addTrip(AGTrip trip) { 00059 std::list<AGPosition>::iterator it; 00060 int time = (trip.getDay()-1)*86400 + trip.getTime(); 00061 00062 //the vehicle: 00063 routes << " <vehicle" 00064 << " id=\"" << trip.getVehicleName() 00065 << "\" type=\"" << trip.getType() 00066 << "\" depart=\"" << time 00067 << "\" departPos=\"" << trip.getDep().getPosition() 00068 << "\" arrivalPos=\"" << trip.getArr().getPosition() 00069 << "\" departSpeed=\"" << 0 00070 << "\" arrivalSpeed=\"" << 0 00071 << "\" color=\"" << colors[trip.getType()] 00072 << "\">" << std::endl; 00073 00074 //the route 00075 routes << " <route edges=\"" << trip.getDep().getStreet().getName(); 00076 for (it=trip.getPassed()->begin() ; it!=trip.getPassed()->end() ; ++it) { 00077 routes << " " << it->getStreet().getName(); 00078 } 00079 routes << " " << trip.getArr().getStreet().getName(); 00080 routes << "\"/>" << std::endl; 00081 00082 routes << " </vehicle>" << std::endl; 00083 } 00084 00085 void 00086 AGActivityTripWriter::writeOutputFile() { 00087 routes << "</routes>" << std::endl; 00088 routes.close(); 00089 } 00090 00091 /****************************************************************************/