SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
MSFCDExport.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// Realises dumping Floating Car Data (FCD) Data
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13
// Copyright (C) 2012-2014 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <
utils/iodevices/OutputDevice.h
>
35
#include <
utils/options/OptionsCont.h
>
36
#include <
utils/geom/GeoConvHelper.h
>
37
#include <
microsim/MSEdgeControl.h
>
38
#include <
microsim/MSEdge.h
>
39
#include <
microsim/MSLane.h
>
40
#include <
microsim/MSGlobals.h
>
41
#include "
MSFCDExport.h
"
42
#include <
microsim/MSNet.h
>
43
#include <
microsim/MSVehicle.h
>
44
#include <
microsim/MSPerson.h
>
45
46
#ifdef HAVE_MESOSIM
47
#include <mesosim/MELoop.h>
48
#include <mesosim/MESegment.h>
49
#endif
50
51
#ifdef CHECK_MEMORY_LEAKS
52
#include <
foreign/nvwa/debug_new.h
>
53
#endif // CHECK_MEMORY_LEAKS
54
55
56
// ===========================================================================
57
// method definitions
58
// ===========================================================================
59
void
60
MSFCDExport::write
(
OutputDevice
& of,
SUMOTime
timestep) {
61
const
bool
useGeo =
OptionsCont::getOptions
().
getBool
(
"fcd-output.geo"
);
62
const
bool
signals =
OptionsCont::getOptions
().
getBool
(
"fcd-output.signals"
);
63
MSVehicleControl
& vc =
MSNet::getInstance
()->
getVehicleControl
();
64
MSVehicleControl::constVehIt
it = vc.
loadedVehBegin
();
65
MSVehicleControl::constVehIt
end = vc.
loadedVehEnd
();
66
67
of.
openTag
(
"timestep"
).
writeAttr
(
SUMO_ATTR_TIME
,
time2string
(timestep));
68
for
(; it != end; ++it) {
69
const
MSVehicle
* veh =
static_cast<
const
MSVehicle
*
>
((*it).second);
70
if
(veh->
isOnRoad
()) {
71
Position
pos = veh->
getPosition
();
72
MSLane
* lane = veh->
getLane
();
73
if
(useGeo) {
74
of.
setPrecision
(
GEO_OUTPUT_ACCURACY
);
75
GeoConvHelper::getFinal
().
cartesian2geo
(pos);
76
}
77
of.
openTag
(
SUMO_TAG_VEHICLE
);
78
of.
writeAttr
(
SUMO_ATTR_ID
, veh->
getID
());
79
of.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
80
of.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
81
of.
writeAttr
(
SUMO_ATTR_ANGLE
, veh->
getAngle
());
82
of.
writeAttr
(
SUMO_ATTR_TYPE
, veh->
getVehicleType
().
getID
());
83
of.
writeAttr
(
SUMO_ATTR_SPEED
, veh->
getSpeed
());
84
of.
writeAttr
(
SUMO_ATTR_POSITION
, veh->
getPositionOnLane
());
85
of.
writeAttr
(
SUMO_ATTR_LANE
, lane->
getID
());
86
of.
writeAttr
(
SUMO_ATTR_SLOPE
, lane->
getShape
().
slopeDegreeAtOffset
(veh->
getPositionOnLane
()));
87
if
(signals) {
88
of.
writeAttr
(
"signals"
,
toString
(veh->
getSignals
()));
89
}
90
of.
closeTag
();
91
}
92
}
93
// write persons
94
MSEdgeControl
& ec =
MSNet::getInstance
()->
getEdgeControl
();
95
const
std::vector<MSEdge*>& edges = ec.
getEdges
();
96
for
(std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) {
97
const
std::vector<MSPerson*>& persons = (*e)->getSortedPersons(timestep);
98
for
(std::vector<MSPerson*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
99
MSPerson
* p = *it_p;
100
Position
pos = p->
getPosition
();
101
if
(useGeo) {
102
of.
setPrecision
(
GEO_OUTPUT_ACCURACY
);
103
GeoConvHelper::getFinal
().
cartesian2geo
(pos);
104
}
105
of.
openTag
(
SUMO_TAG_PERSON
);
106
of.
writeAttr
(
SUMO_ATTR_ID
, p->
getID
());
107
of.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
108
of.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
109
of.
writeAttr
(
SUMO_ATTR_ANGLE
, p->
getAngle
());
110
of.
writeAttr
(
SUMO_ATTR_SPEED
, p->
getSpeed
());
111
of.
writeAttr
(
SUMO_ATTR_POSITION
, p->
getEdgePos
());
112
of.
writeAttr
(
SUMO_ATTR_EDGE
, (*e)->getID());
113
of.
writeAttr
(
SUMO_ATTR_SLOPE
, (*e)->getLanes()[0]->getShape().slopeDegreeAtOffset(p->
getEdgePos
()));
114
of.
closeTag
();
115
}
116
}
117
of.
closeTag
();
118
}
119
120
/****************************************************************************/
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
output
MSFCDExport.cpp
Generated on Thu Nov 20 2014 19:49:55 for SUMO - Simulation of Urban MObility by
1.8.1.2