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.sourceforge.net/
12
// Copyright (C) 2001-2012 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
46
#ifdef CHECK_MEMORY_LEAKS
47
#include <
foreign/nvwa/debug_new.h
>
48
#endif // CHECK_MEMORY_LEAKS
49
50
// ===========================================================================
51
// static members
52
// ===========================================================================
53
const
std::string
NWFrame::MAJOR_VERSION
=
"version=\"0.13\""
;
54
55
56
// ===========================================================================
57
// method definitions
58
// ===========================================================================
59
void
60
NWFrame::fillOptions
(
bool
forNetgen) {
61
OptionsCont
& oc =
OptionsCont::getOptions
();
62
// register options
63
oc.
doRegister
(
"output-file"
,
'o'
,
new
Option_FileName
());
64
oc.
addSynonyme
(
"output-file"
,
"sumo-output"
);
65
oc.
addSynonyme
(
"output-file"
,
"output"
);
66
oc.
addDescription
(
"output-file"
,
"Output"
,
"The generated net will be written to FILE"
);
67
68
oc.
doRegister
(
"plain-output-prefix"
,
new
Option_FileName
());
69
oc.
addSynonyme
(
"plain-output-prefix"
,
"plain-output"
);
70
oc.
addSynonyme
(
"plain-output-prefix"
,
"plain"
);
71
oc.
addDescription
(
"plain-output-prefix"
,
"Output"
,
"Prefix of files to write plain xml nodes, edges and connections to"
);
72
73
oc.
doRegister
(
"junctions.join-output"
,
new
Option_FileName
());
74
oc.
addDescription
(
"junctions.join-output"
,
"Output"
,
75
"Writes information about joined junctions to FILE (can be loaded as additional node-file to reproduce joins"
);
76
77
#ifdef HAVE_PROJ
78
if
(!forNetgen) {
79
oc.
doRegister
(
"proj.plain-geo"
,
new
Option_Bool
(
false
));
80
oc.
addDescription
(
"proj.plain-geo"
,
"Projection"
,
"Write geo coordinates in plain-xml"
);
81
}
82
#endif // HAVE_PROJ
83
84
oc.
doRegister
(
"map-output"
,
'M'
,
new
Option_FileName
());
85
oc.
addDescription
(
"map-output"
,
"Output"
,
"Writes joined edges information to FILE"
);
86
87
oc.
doRegister
(
"matsim-output"
,
new
Option_FileName
());
88
oc.
addDescription
(
"matsim-output"
,
"Output"
,
"The generated net will be written to FILE using MATsim format."
);
89
90
oc.
doRegister
(
"opendrive-output"
,
new
Option_FileName
());
91
oc.
addDescription
(
"opendrive-output"
,
"Output"
,
"The generated net will be written to FILE using openDRIVE format."
);
92
93
oc.
doRegister
(
"output.street-names"
,
new
Option_Bool
(
false
));
94
oc.
addDescription
(
"output.street-names"
,
"Output"
,
"Street names will be included in the output (if available)."
);
95
}
96
97
98
bool
99
NWFrame::checkOptions
() {
100
OptionsCont
& oc =
OptionsCont::getOptions
();
101
bool
ok =
true
;
102
// check whether the output is valid and can be build
103
if
(!oc.
isSet
(
"output-file"
)&&!oc.
isSet
(
"plain-output-prefix"
)&&!oc.
isSet
(
"matsim-output"
)&&!oc.
isSet
(
"opendrive-output"
)) {
104
oc.
set
(
"output-file"
,
"net.net.xml"
);
105
}
106
// some outputs need internal lanes
107
if
(oc.
isSet
(
"opendrive-output"
)&&oc.
getBool
(
"no-internal-links"
)) {
108
WRITE_ERROR
(
"openDRIVE export needs internal links computation."
);
109
ok =
false
;
110
}
111
return
ok;
112
}
113
114
115
void
116
NWFrame::writeNetwork
(
const
OptionsCont
& oc,
NBNetBuilder
& nb) {
117
NWWriter_SUMO::writeNetwork
(oc, nb);
118
NWWriter_MATSim::writeNetwork
(oc, nb);
119
NWWriter_OpenDrive::writeNetwork
(oc, nb);
120
NWWriter_XML::writeNetwork
(oc, nb);
121
// save the mapping information when wished
122
if
(oc.
isSet
(
"map-output"
)) {
123
OutputDevice
& mdevice =
OutputDevice::getDevice
(oc.
getString
(
"map-output"
));
124
mdevice << nb.
getJoinedEdgesMap
();
125
mdevice.
close
();
126
}
127
}
128
129
130
void
131
NWFrame::writePositionLong
(
const
Position
& pos,
OutputDevice
& dev) {
132
dev.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
133
dev.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
134
if
(pos.
z
() != 0) {
135
dev.
writeAttr
(
SUMO_ATTR_Z
, pos.
z
());
136
}
137
}
138
139
/****************************************************************************/
140
tmp
buildd
sumo-0.15.0~dfsg
src
netwrite
NWFrame.cpp
Generated on Sun May 27 2012 14:52:09 for SUMO - Simulation of Urban MObility by
1.8.1