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.sourceforge.net/
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
{
"on ramp"
,
NBSign::SIGN_TYPE_ON_RAMP
},
49
{
"priority"
,
NBSign::SIGN_TYPE_PRIORITY
},
50
{
"right before left"
,
NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT
},
51
{
"roundabout"
,
NBSign::SIGN_TYPE_ROUNDABOUT
},
52
{
"rail crossing"
,
NBSign::SIGN_TYPE_RAIL_CROSSING
},
53
{
"slope"
,
NBSign::SIGN_TYPE_SLOPE
},
54
{
"city limits"
,
NBSign::SIGN_TYPE_CITY
},
55
{
"info"
,
NBSign::SIGN_TYPE_INFO
},
56
};
57
58
StringBijection<NBSign::SignType>
NBSign::SignTypeStrings
(
59
signTypeStringsInitializaer,
NBSign::SIGN_TYPE_INFO
);
60
61
62
StringBijection<NBSign::SignType>::Entry
SignTypeColorsInitializaer
[] = {
63
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_SPEED
},
64
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_YIELD
},
65
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_ON_RAMP
},
66
{
"1.0,1.0,0.0"
,
NBSign::SIGN_TYPE_PRIORITY
},
67
{
"1.0,0.6,0.0"
,
NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT
},
68
{
"0.0,0.0,1.0"
,
NBSign::SIGN_TYPE_ROUNDABOUT
},
69
{
"1.0,0.0,0.0"
,
NBSign::SIGN_TYPE_RAIL_CROSSING
},
70
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_SLOPE
},
71
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_CITY
},
72
{
"0.5,0.5,0.5"
,
NBSign::SIGN_TYPE_INFO
},
73
};
74
75
StringBijection<NBSign::SignType>
NBSign::SignTypeColors
(
76
SignTypeColorsInitializaer,
NBSign::SIGN_TYPE_INFO
);
77
78
// ===========================================================================
79
// member method definitions
80
// ===========================================================================
81
82
NBSign::NBSign
(
SignType
type,
SUMOReal
offset,
const
std::string label) :
83
myType(type),
84
myOffset(offset),
85
myLabel(label)
86
{ }
87
88
89
NBSign::~NBSign
() {}
90
91
92
void
93
NBSign::writeAsPOI
(
OutputDevice
& into,
const
NBEdge
* edge)
const
{
94
PositionVector
shp = edge->
getLanes
()[0].shape;
95
try
{
96
shp.
move2side
(3);
97
}
catch
(
InvalidArgument
&) {
98
// we do not write anything, maybe we should
99
}
100
Position
pos = shp.
positionAtOffset
(
myOffset
);
101
into.
openTag
(
SUMO_TAG_POI
);
102
into.
writeAttr
(
SUMO_ATTR_ID
, edge->
getID
() +
"."
+
toString
(
myOffset
));
103
into.
writeAttr
(
SUMO_ATTR_TYPE
,
SignTypeStrings
.
getString
(
myType
));
104
into.
writeAttr
(
SUMO_ATTR_COLOR
,
SignTypeColors
.
getString
(
myType
));
105
into.
writeAttr
(
SUMO_ATTR_X
, pos.
x
());
106
into.
writeAttr
(
SUMO_ATTR_Y
, pos.
y
());
107
into.
writeAttr
(
SUMO_ATTR_ANGLE
, 0);
// XXX use road angle?
108
// @todo add image resources and default images for all signs
109
//into.writeAttr(SUMO_ATTR_IMGFILE, p->getImgFile());
110
//into.writeAttr(SUMO_ATTR_WIDTH, p->getWidth());
111
//into.writeAttr(SUMO_ATTR_HEIGHT, p->getHeight());
112
into.
closeTag
();
113
}
114
115
116
/****************************************************************************/
117
home
gladk
tmp
05
sumo-0.17.1~dfsg
src
netbuild
NBSign.cpp
Generated on Sun Jun 16 2013 07:07:54 for SUMO - Simulation of Urban MObility by
1.8.1.2