Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBSign.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2012-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// A class representing a street sign
21/****************************************************************************/
22#include <config.h>
23
24#include <cassert>
28#include "NBEdge.h"
29#include "NBSign.h"
30
31
32// ===========================================================================
33// static members
34// ===========================================================================
36 {"speed limit", NBSign::SIGN_TYPE_SPEED},
37 {"yield", NBSign::SIGN_TYPE_YIELD},
38 {"stop", NBSign::SIGN_TYPE_STOP},
39 {"allway_stop", NBSign::SIGN_TYPE_ALLWAY_STOP},
40 {"on ramp", NBSign::SIGN_TYPE_ON_RAMP},
41 {"priority", NBSign::SIGN_TYPE_PRIORITY},
42 {"right before left", NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT},
43 {"left before right", NBSign::SIGN_TYPE_LEFT_BEFORE_RIGHT},
44 {"roundabout", NBSign::SIGN_TYPE_ROUNDABOUT},
45 {"rail crossing", NBSign::SIGN_TYPE_RAIL_CROSSING},
46 {"slope", NBSign::SIGN_TYPE_SLOPE},
47 {"city limits", NBSign::SIGN_TYPE_CITY},
48 {"info", NBSign::SIGN_TYPE_INFO},
49};
50
53
54
55// ===========================================================================
56// member method definitions
57// ===========================================================================
58
59NBSign::NBSign(SignType type, double offset, const std::string label) :
60 myType(type),
61 myOffset(offset),
62 myLabel(label) {
63}
64
65
67
68
69void
70NBSign::writeAsPOI(OutputDevice& into, const NBEdge* edge) const {
71 PositionVector shp = edge->getLanes()[0].shape;
72 try {
73 shp.move2side(3);
74 } catch (InvalidArgument&) {
75 // we do not write anything, maybe we should
76 }
79 into.writeAttr(SUMO_ATTR_ID, edge->getID() + "." + toString(myOffset));
81 switch (myType) {
82 case SIGN_TYPE_SPEED:
83 case SIGN_TYPE_SLOPE:
84 case SIGN_TYPE_CITY:
85 case SIGN_TYPE_INFO:
87 break;
88 case SIGN_TYPE_YIELD:
89 case SIGN_TYPE_STOP:
94 break;
97 break;
100 into.writeAttr(SUMO_ATTR_COLOR, RGBColor(255, 153, 0, 255));
101 break;
104 break;
105 }
106 into.writeAttr(SUMO_ATTR_X, pos.x());
107 into.writeAttr(SUMO_ATTR_Y, pos.y());
108 into.writeAttr(SUMO_ATTR_ANGLE, 0); // XXX use road angle?
109 // @todo add image resources and default images for all signs
110 //into.writeAttr(SUMO_ATTR_IMGFILE, p->getImgFile());
111 //into.writeAttr(SUMO_ATTR_WIDTH, p->getWidth());
112 //into.writeAttr(SUMO_ATTR_HEIGHT, p->getHeight());
113 into.closeTag();
114}
115
116
117/****************************************************************************/
static StringBijection< NBSign::SignType >::Entry signTypeStringsInitializer[]
Definition NBSign.cpp:35
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_ATTR_Y
@ SUMO_ATTR_X
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
The representation of a single edge during network building.
Definition NBEdge.h:92
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition NBEdge.h:726
const std::string & getID() const
Definition NBEdge.h:1524
void writeAsPOI(OutputDevice &into, const NBEdge *edge) const
write into device as POI positioned relative to the given edge
Definition NBSign.cpp:70
SignType myType
the type of the sign
Definition NBSign.h:78
double myOffset
The offset of the sign from the start of its edge.
Definition NBSign.h:81
NBSign(SignType type, double offset, const std::string label="")
Constructor with id, and position.
Definition NBSign.cpp:59
static StringBijection< SignType > SignTypeStrings
Definition NBSign.h:86
~NBSign()
Destructor.
Definition NBSign.cpp:66
SignType
Definition NBSign.h:44
@ SIGN_TYPE_CITY
Definition NBSign.h:56
@ SIGN_TYPE_RAIL_CROSSING
Definition NBSign.h:54
@ SIGN_TYPE_SLOPE
Definition NBSign.h:55
@ SIGN_TYPE_INFO
Definition NBSign.h:57
@ SIGN_TYPE_SPEED
Definition NBSign.h:45
@ SIGN_TYPE_ALLWAY_STOP
Definition NBSign.h:48
@ SIGN_TYPE_YIELD
Definition NBSign.h:46
@ SIGN_TYPE_STOP
Definition NBSign.h:47
@ SIGN_TYPE_ROUNDABOUT
Definition NBSign.h:53
@ SIGN_TYPE_ON_RAMP
Definition NBSign.h:49
@ SIGN_TYPE_PRIORITY
Definition NBSign.h:50
@ SIGN_TYPE_RIGHT_BEFORE_LEFT
Definition NBSign.h:51
@ SIGN_TYPE_LEFT_BEFORE_RIGHT
Definition NBSign.h:52
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
static const RGBColor BLUE
Definition RGBColor.h:187
static const RGBColor GREY
Definition RGBColor.h:194
static const RGBColor YELLOW
Definition RGBColor.h:188
static const RGBColor RED
named colors
Definition RGBColor.h:185
const std::string & getString(const T key) const