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
PCTypeDefHandler.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A handler for loading polygon type maps
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/OptionsCont.h
>
35
#include <
utils/common/MsgHandler.h
>
36
#include <
utils/common/StringTokenizer.h
>
37
#include <
utils/common/UtilExceptions.h
>
38
#include <
utils/xml/SUMOSAXHandler.h
>
39
#include <
utils/xml/SUMOXMLDefinitions.h
>
40
#include <
utils/common/RGBColor.h
>
41
#include "
PCTypeMap.h
"
42
#include "
PCTypeDefHandler.h
"
43
44
#ifdef CHECK_MEMORY_LEAKS
45
#include <
foreign/nvwa/debug_new.h
>
46
#endif // CHECK_MEMORY_LEAKS
47
48
49
// ===========================================================================
50
// method definitions
51
// ===========================================================================
52
PCTypeDefHandler::PCTypeDefHandler
(
OptionsCont
& oc,
PCTypeMap
& con)
53
:
SUMOSAXHandler
(
"Detector-Defintion"
),
54
myOptions(oc), myContainer(con) {}
55
56
57
PCTypeDefHandler::~PCTypeDefHandler
() {}
58
59
60
void
61
PCTypeDefHandler::myStartElement
(
int
element,
62
const
SUMOSAXAttributes
& attrs) {
63
if
(element ==
SUMO_TAG_POLYTYPE
|| element ==
SUMO_TAG_POLYTYPE__DEPRECATED
) {
64
bool
ok =
true
;
65
// get the id, report an error if not given or empty...
66
std::string
id
= attrs.
getStringReporting
(
SUMO_ATTR_ID
, 0, ok);
67
if
(!ok) {
68
return
;
69
}
70
int
layer = attrs.
getOptIntReporting
(
SUMO_ATTR_LAYER
,
id
.c_str(), ok,
myOptions
.
getInt
(
"layer"
));
71
bool
discard = attrs.
getOptBoolReporting
(
SUMO_ATTR_DISCARD
,
id
.c_str(), ok,
false
);
72
bool
allowFill = attrs.
getOptBoolReporting
(
SUMO_ATTR_FILL
,
id
.c_str(), ok,
true
);
73
std::string type = attrs.
getOptStringReporting
(
SUMO_ATTR_NAME
,
id
.c_str(), ok,
myOptions
.
getString
(
"type"
));
74
std::string prefix = attrs.
getOptStringReporting
(
SUMO_ATTR_PREFIX
,
id
.c_str(), ok,
myOptions
.
getString
(
"prefix"
));
75
std::string color = attrs.
getOptStringReporting
(
SUMO_ATTR_COLOR
,
id
.c_str(), ok,
myOptions
.
getString
(
"color"
));
76
// !!! what about error handling?
77
if
(!
myContainer
.
add
(
id
, type, color, prefix, layer, discard, allowFill)) {
78
WRITE_ERROR
(
"Could not add polygon type '"
+
id
+
"' (probably the id is already used)."
);
79
}
80
}
81
}
82
83
84
/****************************************************************************/
85
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
polyconvert
PCTypeDefHandler.cpp
Generated on Mon Mar 24 2014 09:53:14 for SUMO - Simulation of Urban MObility by
1.8.1.2