SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSFCDExport.cpp
Go to the documentation of this file.
1 /****************************************************************************/
5 // Realises dumping Floating Car Data (FCD) Data
6 /****************************************************************************/
7 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
8 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
9 /****************************************************************************/
10 //
11 // This file is part of SUMO.
12 // SUMO is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
32 #include <microsim/MSEdgeControl.h>
33 #include <microsim/MSEdge.h>
34 #include <microsim/MSLane.h>
35 #include <microsim/MSGlobals.h>
36 #include "MSFCDExport.h"
37 #include <microsim/MSNet.h>
38 #include <microsim/MSVehicle.h>
39 
40 #ifdef HAVE_MESOSIM
41 #include <mesosim/MELoop.h>
42 #include <mesosim/MESegment.h>
43 #endif
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 void
55  const bool useGeo = OptionsCont::getOptions().getBool("fcd-output.geo");
56  const bool signals = OptionsCont::getOptions().getBool("fcd-output.signals");
60 
61  of.openTag("timestep").writeAttr(SUMO_ATTR_TIME, time2string(timestep));
62  for (; it != end; ++it) {
63  const MSVehicle* veh = static_cast<const MSVehicle*>((*it).second);
64  if (veh->isOnRoad()) {
65  Position pos = veh->getPosition();
66  MSLane* lane = veh->getLane();
67  if (useGeo) {
70  }
71  of.openTag("vehicle");
72  of.writeAttr(SUMO_ATTR_ID, veh->getID());
73  of.writeAttr(SUMO_ATTR_X, pos.x());
74  of.writeAttr(SUMO_ATTR_Y, pos.y());
79  of.writeAttr(SUMO_ATTR_LANE, lane->getID());
81  if (signals) {
82  of.writeAttr("signals", toString(veh->getSignals()));
83  }
84  of.closeTag();
85  }
86  }
87  of.closeTag();
88 }
89 
90 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
#define GEO_OUTPUT_ACCURACY
Definition: config.h:16
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:150
Position getPosition(SUMOReal offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:484
SUMOReal getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:284
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
SUMOReal slopeDegreeAtOffset(SUMOReal pos) const
Returns the slope at the given length.
const std::string & getID() const
Returns the id.
Definition: Named.h:60
void setPrecision(unsigned int precision=OUTPUT_ACCURACY)
Sets the precison or resets it to default.
static void write(OutputDevice &of, SUMOTime timestep)
Writes the posion and the angle of each vehcile into the given device.
Definition: MSFCDExport.cpp:54
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:248
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:51
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:94
const std::string & getID() const
Returns the name of the vehicle type.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:292
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:318
int getSignals() const
Returns the signals.
Definition: MSVehicle.h:739
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
The class responsible for building and deletion of vehicles.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:331
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:323
Representation of a lane in the micro simulation.
Definition: MSLane.h:73
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOReal getAngle() const
Returns the vehicle&#39;s direction in degrees.
Definition: MSVehicle.cpp:504
const std::string & getID() const
Returns the name of the vehicle.