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
/****************************************************************************/
7
// A class representing a street sign
8
/****************************************************************************/
9
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11
/****************************************************************************/
12
//
13
// This file is part of SUMO.
14
// SUMO is free software: you can redistribute it and/or modify
15
// it under the terms of the GNU General Public License as published by
16
// the Free Software Foundation, either version 3 of the License, or
17
// (at your option) any later version.
18
//
19
/****************************************************************************/
20
21
22
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <cassert>
32
#include <
utils/common/ToString.h
>
33
#include <
utils/iodevices/OutputDevice.h
>
34
#include "
NBEdge.h
"
35
#include "
NBSign.h
"
36
37
#ifdef CHECK_MEMORY_LEAKS
38
#include <
foreign/nvwa/debug_new.h
>
39
#endif // CHECK_MEMORY_LEAKS
40
41
42
// ===========================================================================
43
// static members
44
// ===========================================================================
45
StringBijection<NBSign::SignType>::Entry
signTypeStringsInitializaer
[] = {
46
{
"speed limit"
,
NBSign::SIGN_TYPE_SPEED
},
47
{
"yield"
,
NBSign::SIGN_TYPE_YIELD
},
48
{
"stop"
,
NBSign::SIGN_TYPE_STOP
},
49
{
"allway_stop"
,
NBSign::SIGN_TYPE_ALLWAY_STOP
},
50
{
"on ramp"
,
NBSign::SIGN_TYPE_ON_RAMP
},
51
{
"priority"
,
NBSign::SIGN_TYPE_PRIORITY
},
52
{
"right before left"
,
NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT
},
53
{
"roundabout"
,
NBSign::SIGN_TYPE_ROUNDABOUT
},
54
{
"rail crossing"
,
NBSign::SIGN_TYPE_RAIL_CROSSING
},
55
{
"slope"
,
NBSign::SIGN_TYPE_SLOPE
},
56
{
"city limits"
,
NBSign::SIGN_TYPE_CITY
},
57
{
"info"
,
NBSign::SIGN_TYPE_INFO
},
58
};
59
60
StringBijection<NBSign::SignType>
NBSign::SignTypeStrings
(
61
signTypeStringsInitializaer,
NBSign::SIGN_TYPE_INFO
);
62
63
64
StringBijection<NBSign::SignType>::Entry
SignTypeColorsInitializaer
[] = {
65
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_SPEED
},
66
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_YIELD
},
67
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_STOP
},
68
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_ALLWAY_STOP
},
69
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_ON_RAMP
},
70
{
"1.0,1.0,0.0"
,
NBSign::SIGN_TYPE_PRIORITY
},
71
{
"1.0,0.6,0.0"
,
NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT
},
72
{
"0.0,0.0,1.0"
,
NBSign::SIGN_TYPE_ROUNDABOUT
},
73
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_RAIL_CROSSING
},
74
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_SLOPE
},
75
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_CITY
},
76
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_INFO
},
77
};
78
79
StringBijection<NBSign::SignType>
NBSign::SignTypeColors
(
80
SignTypeColorsInitializaer,
NBSign::SIGN_TYPE_INFO
);
81
82
// ===========================================================================
83
// member method definitions
84
// ===========================================================================
85
86
NBSign::NBSign
(
SignType
type,
SUMOReal
offset,
const
std::string label) :
87
myType(type),
88
myOffset(offset),
89
myLabel(label)
90
{ }
91
92
93
NBSign::~NBSign
() {}
94
95
96
void
97
NBSign::writeAsPOI
(
OutputDevice
& into,
const
NBEdge
* edge)
const
{
98
PositionVector
shp = edge->
getLanes
()[0].shape;
99
try
{
100
shp.
move2side
(3);
101
}
catch
(
InvalidArgument
&) {
102
// we do not write anything, maybe we should
103
}
104
Position
pos = shp.
positionAtOffset
(
myOffset
);
105
into.
openTag
(
SUMO_TAG_POI
);
106
into.
writeAttr
(
SUMO_ATTR_ID
, edge->
getID
() +
"."
+
toString
(
myOffset
));
107
into.
writeAttr
(
SUMO_ATTR_TYPE
,
SignTypeStrings
.
getString
(
myType
));
108
into.
writeAttr
(
SUMO_ATTR_COLOR
,
SignTypeColors
.
getString
(
myType
));
109
into.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
110
into.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
111
into.
writeAttr
(
SUMO_ATTR_ANGLE
, 0);
// XXX use road angle?
112
// @todo add image resources and default images for all signs
113
//into.writeAttr(SUMO_ATTR_IMGFILE, p->getImgFile());
114
//into.writeAttr(SUMO_ATTR_WIDTH, p->getWidth());
115
//into.writeAttr(SUMO_ATTR_HEIGHT, p->getHeight());
116
into.
closeTag
();
117
}
118
119
120
/****************************************************************************/
121
build
buildd
sumo-0.18~dfsg
src
netbuild
NBSign.cpp
Generated on Wed Oct 23 2013 01:15:10 for SUMO - Simulation of Urban MObility by
1.8.4