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
NBSign.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A class representing a street sign
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2012-2014 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 <cassert>
34
#include <
utils/common/RGBColor.h
>
35
#include <
utils/common/ToString.h
>
36
#include <
utils/iodevices/OutputDevice.h
>
37
#include "
NBEdge.h
"
38
#include "
NBSign.h
"
39
40
#ifdef CHECK_MEMORY_LEAKS
41
#include <
foreign/nvwa/debug_new.h
>
42
#endif // CHECK_MEMORY_LEAKS
43
44
45
// ===========================================================================
46
// static members
47
// ===========================================================================
48
StringBijection<NBSign::SignType>::Entry
signTypeStringsInitializer
[] = {
49
{
"speed limit"
,
NBSign::SIGN_TYPE_SPEED
},
50
{
"yield"
,
NBSign::SIGN_TYPE_YIELD
},
51
{
"stop"
,
NBSign::SIGN_TYPE_STOP
},
52
{
"allway_stop"
,
NBSign::SIGN_TYPE_ALLWAY_STOP
},
53
{
"on ramp"
,
NBSign::SIGN_TYPE_ON_RAMP
},
54
{
"priority"
,
NBSign::SIGN_TYPE_PRIORITY
},
55
{
"right before left"
,
NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT
},
56
{
"roundabout"
,
NBSign::SIGN_TYPE_ROUNDABOUT
},
57
{
"rail crossing"
,
NBSign::SIGN_TYPE_RAIL_CROSSING
},
58
{
"slope"
,
NBSign::SIGN_TYPE_SLOPE
},
59
{
"city limits"
,
NBSign::SIGN_TYPE_CITY
},
60
{
"info"
,
NBSign::SIGN_TYPE_INFO
},
61
};
62
63
StringBijection<NBSign::SignType>
NBSign::SignTypeStrings
(
64
signTypeStringsInitializer,
NBSign::SIGN_TYPE_INFO
);
65
66
67
// ===========================================================================
68
// member method definitions
69
// ===========================================================================
70
71
NBSign::NBSign
(
SignType
type,
SUMOReal
offset,
const
std::string label) :
72
myType(type),
73
myOffset(offset),
74
myLabel(label)
75
{ }
76
77
78
NBSign::~NBSign
() {}
79
80
81
void
82
NBSign::writeAsPOI
(
OutputDevice
& into,
const
NBEdge
* edge)
const
{
83
PositionVector
shp = edge->
getLanes
()[0].shape;
84
try
{
85
shp.
move2side
(3);
86
}
catch
(
InvalidArgument
&) {
87
// we do not write anything, maybe we should
88
}
89
Position
pos = shp.
positionAtOffset
(
myOffset
);
90
into.
openTag
(
SUMO_TAG_POI
);
91
into.
writeAttr
(
SUMO_ATTR_ID
, edge->
getID
() +
"."
+
toString
(
myOffset
));
92
into.
writeAttr
(
SUMO_ATTR_TYPE
,
SignTypeStrings
.
getString
(
myType
));
93
switch
(
myType
) {
94
case
SIGN_TYPE_SPEED
:
95
case
SIGN_TYPE_SLOPE
:
96
case
SIGN_TYPE_CITY
:
97
case
SIGN_TYPE_INFO
:
98
into.
writeAttr
(
SUMO_ATTR_COLOR
,
RGBColor::GREY
);
99
break
;
100
case
SIGN_TYPE_YIELD
:
101
case
SIGN_TYPE_STOP
:
102
case
SIGN_TYPE_ALLWAY_STOP
:
103
case
SIGN_TYPE_ON_RAMP
:
104
case
SIGN_TYPE_RAIL_CROSSING
:
105
into.
writeAttr
(
SUMO_ATTR_COLOR
,
RGBColor::RED
);
106
break
;
107
case
SIGN_TYPE_PRIORITY
:
108
into.
writeAttr
(
SUMO_ATTR_COLOR
,
RGBColor::YELLOW
);
109
break
;
110
case
SIGN_TYPE_RIGHT_BEFORE_LEFT
:
111
into.
writeAttr
(
SUMO_ATTR_COLOR
,
RGBColor
(255, 153, 0, 255));
112
break
;
113
case
SIGN_TYPE_ROUNDABOUT
:
114
into.
writeAttr
(
SUMO_ATTR_COLOR
,
RGBColor::BLUE
);
115
break
;
116
}
117
into.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
118
into.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
119
into.
writeAttr
(
SUMO_ATTR_ANGLE
, 0);
// XXX use road angle?
120
// @todo add image resources and default images for all signs
121
//into.writeAttr(SUMO_ATTR_IMGFILE, p->getImgFile());
122
//into.writeAttr(SUMO_ATTR_WIDTH, p->getWidth());
123
//into.writeAttr(SUMO_ATTR_HEIGHT, p->getHeight());
124
into.
closeTag
();
125
}
126
127
128
/****************************************************************************/
129
tmp
buildd
sumo-0.21.0+dfsg
src
netbuild
NBSign.cpp
Generated on Thu Nov 20 2014 19:49:56 for SUMO - Simulation of Urban MObility by
1.8.1.2