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
netconvert_main.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// Main for NETCONVERT
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
#ifdef HAVE_VERSION_H
34
#include <version.h>
35
#endif
36
37
#include <iostream>
38
#include <string>
39
#include <
netimport/NIFrame.h
>
40
#include <
netimport/NILoader.h
>
41
#include <
netbuild/NBFrame.h
>
42
#include <
netbuild/NBNetBuilder.h
>
43
#include <
netbuild/NBDistribution.h
>
44
#include <
netwrite/NWFrame.h
>
45
#include <
utils/options/OptionsIO.h
>
46
#include <
utils/options/OptionsCont.h
>
47
#include <
utils/common/UtilExceptions.h
>
48
#include <
utils/common/RandHelper.h
>
49
#include <
utils/common/SystemFrame.h
>
50
#include <
utils/common/MsgHandler.h
>
51
#include <
utils/xml/XMLSubSys.h
>
52
#include <
utils/iodevices/OutputDevice.h
>
53
#include <
utils/geom/GeoConvHelper.h
>
54
55
#ifdef CHECK_MEMORY_LEAKS
56
#include <
foreign/nvwa/debug_new.h
>
57
#endif // CHECK_MEMORY_LEAKS
58
59
60
// ===========================================================================
61
// method definitions
62
// ===========================================================================
63
void
64
fillOptions
() {
65
OptionsCont
& oc =
OptionsCont::getOptions
();
66
oc.
addCallExample
(
"-c <CONFIGURATION>"
,
"generate net with options read from file"
);
67
oc.
addCallExample
(
"-n ./nodes.xml -e ./edges.xml -v -t ./owntypes.xml"
,
68
"generate net with given nodes, edges, and edge types doing verbose output"
);
69
70
// insert options sub-topics
71
SystemFrame::addConfigurationOptions
(oc);
// this subtopic is filled here, too
72
oc.
addOptionSubTopic
(
"Input"
);
73
oc.
addOptionSubTopic
(
"Output"
);
74
GeoConvHelper::addProjectionOptions
(oc);
75
oc.
addOptionSubTopic
(
"TLS Building"
);
76
oc.
addOptionSubTopic
(
"Ramp Guessing"
);
77
oc.
addOptionSubTopic
(
"Edge Removal"
);
78
oc.
addOptionSubTopic
(
"Unregulated Nodes"
);
79
oc.
addOptionSubTopic
(
"Processing"
);
80
oc.
addOptionSubTopic
(
"Building Defaults"
);
81
SystemFrame::addReportOptions
(oc);
// this subtopic is filled here, too
82
83
NIFrame::fillOptions
();
84
NBFrame::fillOptions
(
false
);
85
NWFrame::fillOptions
(
false
);
86
RandHelper::insertRandOptions
();
87
}
88
89
90
bool
91
checkOptions
() {
92
bool
ok =
NIFrame::checkOptions
();
93
ok &=
NBFrame::checkOptions
();
94
ok &=
NWFrame::checkOptions
();
95
return
ok;
96
}
97
98
99
/* -------------------------------------------------------------------------
100
* main
101
* ----------------------------------------------------------------------- */
102
int
103
main
(
int
argc,
char
** argv) {
104
OptionsCont
& oc =
OptionsCont::getOptions
();
105
// give some application descriptions
106
oc.
setApplicationDescription
(
"Road network importer / builder for the road traffic simulation SUMO."
);
107
oc.
setApplicationName
(
"netconvert"
,
"SUMO netconvert Version "
+ (std::string)
VERSION_STRING
);
108
int
ret = 0;
109
try
{
110
XMLSubSys::init
(
false
);
111
fillOptions
();
112
OptionsIO::getOptions
(
true
, argc, argv);
113
if
(oc.
processMetaOptions
(argc < 2)) {
114
OutputDevice::closeAll
();
115
SystemFrame::close
();
116
return
0;
117
}
118
MsgHandler::initOutputOptions
();
119
if
(!
checkOptions
()) {
120
throw
ProcessError
();
121
}
122
RandHelper::initRandGlobal
();
123
NBNetBuilder
nb;
124
nb.
applyOptions
(oc);
125
// load data
126
NILoader
nl(nb);
127
nl.
load
(oc);
128
if
(oc.
getBool
(
"ignore-errors"
)) {
129
MsgHandler::getErrorInstance
()->
clear
();
130
}
131
// check whether any errors occured
132
if
(
MsgHandler::getErrorInstance
()->wasInformed()) {
133
throw
ProcessError
();
134
}
135
nb.
compute
(oc);
136
NWFrame::writeNetwork
(oc, nb);
137
}
catch
(
ProcessError
& e) {
138
if
(std::string(e.what()) != std::string(
"Process Error"
) && std::string(e.what()) != std::string(
""
)) {
139
WRITE_ERROR
(e.what());
140
}
141
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on error)."
,
false
);
142
ret = 1;
143
#ifndef _DEBUG
144
}
catch
(...) {
145
MsgHandler::getErrorInstance
()->
inform
(
"Quitting (on unknown error)."
,
false
);
146
ret = 1;
147
#endif
148
}
149
NBDistribution::clear
();
150
OutputDevice::closeAll
();
151
SystemFrame::close
();
152
// report about ending
153
if
(ret == 0) {
154
std::cout <<
"Success."
<< std::endl;
155
}
156
return
ret;
157
}
158
159
160
161
/****************************************************************************/
162
tmp
buildd
sumo-0.15.0~dfsg
src
netconvert_main.cpp
Generated on Sun May 27 2012 14:52:08 for SUMO - Simulation of Urban MObility by
1.8.1