 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
38 GNEDetector(
"", net,
GLO_E2DETECTOR, tag, 0, 0, {},
"", {},
"",
false,
Parameterised::Map()),
39 myEndPositionOverLane(0),
49 const std::string& trafficLight,
const std::string& filename,
const std::vector<std::string>& vehicleTypes,
const std::string& name,
50 SUMOTime timeThreshold,
double speedThreshold,
double jamThreshold,
bool friendlyPos,
54 }, filename, vehicleTypes, name, friendlyPos, parameters),
55 myEndPositionOverLane(pos + length),
56 myTimeThreshold(timeThreshold),
57 mySpeedThreshold(speedThreshold),
58 myJamThreshold(jamThreshold),
59 myTrafficLight(trafficLight) {
61 updateCenteringBoundary(
false);
66 const std::string& trafficLight,
const std::string& filename,
const std::vector<std::string>& vehicleTypes,
const std::string& name,
SUMOTime timeThreshold,
67 double speedThreshold,
double jamThreshold,
bool friendlyPos,
const Parameterised::Map& parameters) :
68 GNEDetector(id, net,
GLO_E2DETECTOR,
GNE_TAG_E2DETECTOR_MULTILANE, pos, freq, lanes, filename, vehicleTypes, name, friendlyPos, parameters),
69 myEndPositionOverLane(endPos),
70 myTimeThreshold(timeThreshold),
71 mySpeedThreshold(speedThreshold),
72 myJamThreshold(jamThreshold),
73 myTrafficLight(trafficLight) {
161 std::string errorFirstLanePosition, separator, errorLastLanePosition;
173 return "lanes aren't consecutives";
177 return "lanes aren't connected";
195 if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
199 return errorFirstLanePosition + separator + errorLastLanePosition;
217 bool foundConnection =
true;
222 foundConnection =
false;
224 for (
const auto& connection :
getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
226 foundConnection =
true;
230 if (!foundConnection) {
245 newPositionOverLane,
getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
246 newEndPositionOverLane,
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
317 E2Exaggeration,
true,
true);
321 E2Exaggeration,
true,
true);
354 geometryDepartPos, geometryEndPos,
358 geometryDepartPos, -1,
374 glTranslated(0, 0,
getType() + offsetFront);
406 glTranslated(pos.
x(), pos.
y(),
getType() + offsetFront + 0.1);
410 glTranslated(-1, 0, 0);
412 glScaled(E2DetectorWidth, E2DetectorWidth, 1);
449 glTranslated(0, 0,
getType() + offsetFront);
486 E2DetectorWidth, 1,
false,
false);
493 E2DetectorWidth, 1,
false,
false);
597 if (value ==
getID()) {
609 return canParse<std::vector<GNELane*> >(
myNet, value,
false);
614 }
else if (
canParse<std::vector<GNELane*> >(
myNet, value,
false)) {
621 return canParse<double>(value);
623 return canParse<double>(value);
628 return (canParse<double>(value) && (parse<double>(value) >= 0));
634 return (canParse<double>(value) && (parse<double>(value) >= 0));
646 return canParse<SUMOTime>(value);
648 return (canParse<double>(value) && (parse<double>(value) >= 0));
650 return (canParse<double>(value) && (parse<double>(value) >= 0));
652 return canParse<bool>(value);
654 return canParse<bool>(value);
730 if (parse<bool>(value)) {
794 const double laneLength =
getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
799 fixedPos += laneLength;
816 const double laneLength =
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
821 fixedPos += laneLength;
827 }
else if (fixedPos >
getParentLanes().back()->getLaneShapeLength()) {
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
static void drawRightGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false)
draw right geometry point
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
#define SUMOTime_MAX_PERIOD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAdditionalValid() const
check if current additional is valid to be writed into XML
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
bool showAdditionals() const
check if additionals has to be drawn
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
Static storage of an output device and its base (abstract) implementation.
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
std::string getAttribute(SumoXMLAttr key) const
static const RGBColor BLACK
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static const Position INVALID
used to indicate that a position is valid
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static void drawContourGeometry(const GUIGeometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
A NBNetBuilder extended by visualisation and editing capabilities.
void computePathElement()
compute pathElement
void shiftLaneIndex()
shift lane index
static void drawLeftGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false)
draw left geometry point
const PositionVector & getShape() const
The shape of the additional element.
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
bool isLabelSegment() const
check if segment is label segment
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
void fixAdditionalProblem()
fix additional problem
std::map< std::string, std::string > Map
parameters map
static const RGBColor connectionColor
connection color
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
SUMOTime myPeriod
The aggregation period the values the detector collects shall be summed up.
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
double myPositionOverLane
position of detector over Lane
static void pushName(unsigned int name)
push Name
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
bool myFriendlyPosition
Flag for friendly position.
static void drawDottedContourShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem, const double lineWidth=-1)
draw dotted contour for the given shape (used by additionals)
SumoXMLTag
Numbers representing SUMO-XML - element names.
static const double detectorDetails
details for detectors
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
std::vector< std::string > myVehicleTypes
attribute vehicle types
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static void pushMatrix()
push matrix
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
GNENet * myNet
pointer to net
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
friend class GNEChange_Attribute
declare friend class
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static const double E2Width
E2 detector widths.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
void updateGeometry(const PositionVector &shape)
update entire geometry
GUIVisualizationTextSettings addName
@ GNE_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (placed here due create Additional Frame)
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
GUIVisualizationDetailSettings detailSettings
detail settings
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
const PositionVector & getLaneShape() const
get elements shape
void updateGeometry()
update pre-computed geometry information
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
double newFirstPos
new first position
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
void drawDetectorLogo(const GUIVisualizationSettings &s, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw detector Logo
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
GUIGlID getGlID() const
Returns the numerical id of the object.
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
void setParametersStr(const std::string ¶msString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
A point in 2D or 3D with translation and scaling methods.
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object (lane)
double x() const
Returns the x-position.
std::string time2string(SUMOTime t)
convert SUMOTime to string
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
GNEUndoList * getUndoList() const
get the undoList object
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
std::string myAdditionalName
name of additional
static const RGBColor RED
named colors
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
bool isFirstSegment() const
check if segment is the first path's segment
bool showConnections() const
check if select show connections checkbox is enabled
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
bool isLastSegment() const
check if segment is the last path's segment
double length2D() const
Returns the length.
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
void calculateConsecutivePathLanes(PathElement *pathElement, const std::vector< GNELane * > lanes)
calculate consecutive path lanes
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
GNEViewNet * getViewNet() const
get view net
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
GUIVisualizationColorSettings colorSettings
color settings
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
static void rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
double y() const
Returns the y-position.
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
double newSecondPos
new second position
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
GNEDetectorE2(SumoXMLTag tag, GNENet *net)
default Constructor
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
const GUIGeometry & getLaneGeometry() const
std::string myFilename
The path to the output file.
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
std::string getAdditionalProblem() const
return a string with the current additional problem
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
@ SUMO_ATTR_JAM_DIST_THRESHOLD
static void popMatrix()
pop matrix
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GUIVisualizationSizeSettings addSize
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
double getAttributeDouble(SumoXMLAttr key) const
@ GNE_ATTR_SELECTED
element is selected
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
const std::string & getTagStr() const
get tag assigned to this object in string format
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
Stores the information about how to visualize structures.
~GNEDetectorE2()
Destructor.
GNEPathManager * getPathManager()
get path manager
A structure which describes a connection between edges or lanes.
const GNEMoveOperation::OperationType operationType
move operation
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
static void popName()
pop Name
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
static const RGBColor E2Color
color for E2 detectors
@ SUMO_TAG_E2DETECTOR
an e2 detector
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given tolane
@ GLO_E2DETECTOR
a E2 detector
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values