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
NWFrame.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// Sets and checks options for netwrite
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#include <string>
34
#include <
utils/options/Option.h
>
35
#include <
utils/options/OptionsCont.h
>
36
#include <
utils/common/MsgHandler.h
>
37
#include <
utils/common/SystemFrame.h
>
38
#include <
utils/iodevices/OutputDevice.h
>
39
#include <
netbuild/NBNetBuilder.h
>
40
#include "
NWFrame.h
"
41
#include "
NWWriter_SUMO.h
"
42
#include "
NWWriter_MATSim.h
"
43
#include "
NWWriter_XML.h
"
44
#include "
NWWriter_OpenDrive.h
"
45
#include "
NWWriter_DlrNavteq.h
"
46
47
#ifdef CHECK_MEMORY_LEAKS
48
#include <
foreign/nvwa/debug_new.h
>
49
#endif // CHECK_MEMORY_LEAKS
50
51
// ===========================================================================
52
// static members
53
// ===========================================================================
54
const
std::string
NWFrame::MAJOR_VERSION
=
"version=\"0.13\""
;
55
56
57
// ===========================================================================
58
// method definitions
59
// ===========================================================================
60
void
61
NWFrame::fillOptions
(
bool
forNetgen) {
62
OptionsCont
& oc =
OptionsCont::getOptions
();
63
// register options
64
oc.
doRegister
(
"output-file"
,
'o'
,
new
Option_FileName
());
65
oc.
addSynonyme
(
"output-file"
,
"sumo-output"
);
66
oc.
addSynonyme
(
"output-file"
,
"output"
);
67
oc.
addDescription
(
"output-file"
,
"Output"
,
"The generated net will be written to FILE"
);
68
69
oc.
doRegister
(
"plain-output-prefix"
,
new
Option_FileName
());
70
oc.
addSynonyme
(
"plain-output-prefix"
,
"plain-output"
);
71
oc.
addSynonyme
(
"plain-output-prefix"
,
"plain"
);
72
oc.
addDescription
(
"plain-output-prefix"
,
"Output"
,
"Prefix of files to write plain xml nodes, edges and connections to"
);
73
74
oc.
doRegister
(
"junctions.join-output"
,
new
Option_FileName
());
75
oc.
addDescription
(
"junctions.join-output"
,
"Output"
,
76
"Writes information about joined junctions to FILE (can be loaded as additional node-file to reproduce joins"
);
77
78
#ifdef HAVE_PROJ
79
if
(!forNetgen) {
80
oc.
doRegister
(
"proj.plain-geo"
,
new
Option_Bool
(
false
));
81
oc.
addDescription
(
"proj.plain-geo"
,
"Projection"
,
"Write geo coordinates in plain-xml"
);
82
}
83
#endif // HAVE_PROJ
84
85
oc.
doRegister
(
"map-output"
,
'M'
,
new
Option_FileName
());
86
oc.
addDescription
(
"map-output"
,
"Output"
,
"Writes joined edges information to FILE"
);
87
88
oc.
doRegister
(
"matsim-output"
,
new
Option_FileName
());
89
oc.
addDescription
(
"matsim-output"
,
"Output"
,
"The generated net will be written to FILE using MATsim format."
);
90
91
oc.
doRegister
(
"opendrive-output"
,
new
Option_FileName
());
92
oc.
addDescription
(
"opendrive-output"
,
"Output"
,
"The generated net will be written to FILE using openDRIVE format."
);
93
94
oc.
doRegister
(
"dlr-navteq-output"
,
new
Option_FileName
());
95
oc.
addDescription
(
"dlr-navteq-output"
,
"Output"
,
"The generated net will be written to dlr-navteq files with the given PREFIX."
);
96
97
oc.
doRegister
(
"output.street-names"
,
new
Option_Bool
(
false
));
98
oc.
addDescription
(
"output.street-names"
,
"Output"
,
"Street names will be included in the output (if available)."
);
99
100
oc.
doRegister
(
"output.original-names"
,
new
Option_Bool
(
false
));
101
oc.
addDescription
(
"output.original-names"
,
"Output"
,
"Writes original names, if given, as parameter."
);
102
103
oc.
doRegister
(
"street-sign-output"
,
new
Option_FileName
());
104
oc.
addDescription
(
"street-sign-output"
,
"Output"
,
"Writes street signs as POIs to FILE."
);
105
}
106
107
108
bool
109
NWFrame::checkOptions
() {
110
OptionsCont
& oc =
OptionsCont::getOptions
();
111
bool
ok =
true
;
112
// check whether the output is valid and can be build
113
if
(!oc.
isSet
(
"output-file"
)
114
&& !oc.
isSet
(
"plain-output-prefix"
)
115
&& !oc.
isSet
(
"matsim-output"
)
116
&& !oc.
isSet
(
"opendrive-output"
)
117
&& !oc.
isSet
(
"dlr-navteq-output"
)) {
118
oc.
set
(
"output-file"
,
"net.net.xml"
);
119
}
120
// some outputs need internal lanes
121
if
(oc.
isSet
(
"opendrive-output"
) && oc.
getBool
(
"no-internal-links"
)) {
122
WRITE_ERROR
(
"openDRIVE export needs internal links computation."
);
123
ok =
false
;
124
}
125
return
ok;
126
}
127
128
129
void
130
NWFrame::writeNetwork
(
const
OptionsCont
& oc,
NBNetBuilder
& nb) {
131
NWWriter_SUMO::writeNetwork
(oc, nb);
132
NWWriter_MATSim::writeNetwork
(oc, nb);
133
NWWriter_OpenDrive::writeNetwork
(oc, nb);
134
NWWriter_DlrNavteq::writeNetwork
(oc, nb);
135
NWWriter_XML::writeNetwork
(oc, nb);
136
// save the mapping information when wished
137
if
(oc.
isSet
(
"map-output"
)) {
138
OutputDevice
& mdevice =
OutputDevice::getDevice
(oc.
getString
(
"map-output"
));
139
mdevice << nb.
getJoinedEdgesMap
();
140
mdevice.
close
();
141
}
142
}
143
144
145
void
146
NWFrame::writePositionLong
(
const
Position
& pos,
OutputDevice
& dev) {
147
dev.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
148
dev.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
149
if
(pos.
z
() != 0) {
150
dev.
writeAttr
(
SUMO_ATTR_Z
, pos.
z
());
151
}
152
}
153
154
/****************************************************************************/
155
build
buildd
sumo-0.18~dfsg
src
netwrite
NWFrame.cpp
Generated on Wed Oct 23 2013 01:15:11 for SUMO - Simulation of Urban MObility by
1.8.4