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