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>
29#include "NBEdge.h"
30#include "NBSign.h"
31
32
33// ===========================================================================
34// static members
35// ===========================================================================
37 {"speed limit", NBSign::SIGN_TYPE_SPEED},
38 {"yield", NBSign::SIGN_TYPE_YIELD},
39 {"stop", NBSign::SIGN_TYPE_STOP},
40 {"allway_stop", NBSign::SIGN_TYPE_ALLWAY_STOP},
41 {"on ramp", NBSign::SIGN_TYPE_ON_RAMP},
42 {"priority", NBSign::SIGN_TYPE_PRIORITY},
43 {"right before left", NBSign::SIGN_TYPE_RIGHT_BEFORE_LEFT},
44 {"left before right", NBSign::SIGN_TYPE_LEFT_BEFORE_RIGHT},
45 {"roundabout", NBSign::SIGN_TYPE_ROUNDABOUT},
46 {"rail crossing", NBSign::SIGN_TYPE_RAIL_CROSSING},
47 {"slope", NBSign::SIGN_TYPE_SLOPE},
48 {"city limits", NBSign::SIGN_TYPE_CITY},
49 {"info", NBSign::SIGN_TYPE_INFO},
50};
51
54
55
56// ===========================================================================
57// member method definitions
58// ===========================================================================
59
60NBSign::NBSign(SignType type, double offset, const std::string label) :
61 myType(type),
62 myOffset(offset),
63 myLabel(label) {
64}
65
66
68
69
70void
71NBSign::writeAsPOI(OutputDevice& into, const NBEdge* edge) const {
72 PositionVector shp = edge->getLanes()[0].shape;
73 try {
74 shp.move2side(3);
75 } catch (InvalidArgument&) {
76 // we do not write anything, maybe we should
77 }
80 into.writeAttr(SUMO_ATTR_ID, edge->getID() + "." + toString(myOffset));
82 switch (myType) {
83 case SIGN_TYPE_SPEED:
84 case SIGN_TYPE_SLOPE:
85 case SIGN_TYPE_CITY:
86 case SIGN_TYPE_INFO:
88 break;
89 case SIGN_TYPE_YIELD:
90 case SIGN_TYPE_STOP:
95 break;
98 break;
101 into.writeAttr(SUMO_ATTR_COLOR, RGBColor(255, 153, 0, 255));
102 break;
105 break;
106 }
107 into.writeAttr(SUMO_ATTR_X, pos.x());
108 into.writeAttr(SUMO_ATTR_Y, pos.y());
110 // @todo add image resources and default images for all signs
111 //into.writeAttr(SUMO_ATTR_IMGFILE, p->getImgFile());
112 //into.writeAttr(SUMO_ATTR_WIDTH, p->getWidth());
113 //into.writeAttr(SUMO_ATTR_HEIGHT, p->getHeight());
114 into.closeTag();
115}
116
117
118/****************************************************************************/
static StringBijection< NBSign::SignType >::Entry signTypeStringsInitializer[]
Definition NBSign.cpp:36
@ 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
static double naviDegree(const double angle)
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:730
const std::string & getID() const
Definition NBEdge.h:1528
void writeAsPOI(OutputDevice &into, const NBEdge *edge) const
write into device as POI positioned relative to the given edge
Definition NBSign.cpp:71
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:60
static StringBijection< SignType > SignTypeStrings
Definition NBSign.h:86
~NBSign()
Destructor.
Definition NBSign.cpp:67
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.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
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