38 GNEDetector(
"", net,
GLO_E2DETECTOR, tag, 0, 0, {},
"", {},
"",
false, std::map<std::string, std::string>()),
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,
51 const std::map<std::string, std::string>& parameters) :
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 std::map<std::string, std::string>& 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) {
158 std::string errorFirstLanePosition, separator, errorLastLanePosition;
173 return "lanes aren't consecutives";
191 if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
195 return errorFirstLanePosition + separator + errorLastLanePosition;
213 bool foundConnection =
true;
218 foundConnection =
false;
220 for (
const auto& connection :
getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
222 foundConnection =
true;
226 if (!foundConnection) {
241 newPositionOverLane,
getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
242 newEndPositionOverLane,
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
313 E2Exaggeration,
true,
true);
317 E2Exaggeration,
true,
true);
433 return canParse<std::vector<GNELane*> >(
myNet, value,
false);
438 }
else if (
canParse<std::vector<GNELane*> >(
myNet, value,
false)) {
445 return canParse<double>(value);
447 return canParse<double>(value);
449 return value.empty() || (canParse<double>(value) && (parse<double>(value) >= 0));
454 return (canParse<double>(value) && (parse<double>(value) >= 0));
466 return canParse<SUMOTime>(value);
468 return (canParse<double>(value) && (parse<double>(value) >= 0));
470 return (canParse<double>(value) && (parse<double>(value) >= 0));
472 return canParse<bool>(value);
474 return canParse<bool>(value);
552 if (parse<bool>(value)) {
627 bool connectionFound =
false;
629 for (
auto j :
getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
631 connectionFound =
true;
635 if (!connectionFound) {
649 const double laneLength =
getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
654 fixedPos += laneLength;
660 }
else if (fixedPos > (
getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
661 return (
getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
671 const double laneLength =
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
676 fixedPos += laneLength;
680 if (fixedPos < POSITION_EPS) {
682 }
else if (fixedPos >
getParentLanes().back()->getLaneShapeLength()) {
@ GLO_E2DETECTOR
a E2 detector
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ GNE_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (placed here due create Additional Frame)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void pushName(unsigned int name)
push Name
static void popMatrix()
pop matrix
static void popName()
pop Name
static void pushMatrix()
push matrix
static void fixE2MultiLanePosition(double &pos, const double fromLaneLength, double &to, const double TolaneLength)
fix the given positions over lane
static void fixE2SingleLanePosition(double &pos, double &length, const double laneLength)
fix the given positions over lane
static void drawRightGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw right geometry point
const std::string & getID() const
get ID
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void shiftLaneIndex()
shift lane index
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
std::string myAdditionalName
name of additional
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
void computePathElement()
compute pathElement
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
static void drawLeftGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw left geometry point
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
GNENet * myNet
pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
void updateGeometry()
update pre-computed geometry information
std::string getAttribute(SumoXMLAttr key) const
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool isAdditionalValid() const
check if current additional is valid to be writed into XML
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
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
writte additional element into a xml file
bool areLaneConsecutives() const
check if lanes are consecutives
void fixAdditionalProblem()
fix additional problem
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool isAttributeEnabled(SumoXMLAttr key) const
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
double getAttributeDouble(SumoXMLAttr key) const
~GNEDetectorE2()
Destructor.
GNEDetectorE2(SumoXMLTag tag, GNENet *net)
default Constructor
std::string getAdditionalProblem() const
return a string with the current additional problem
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string myFilename
The path to the output file.
double myPositionOverLane
position of detector over Lane
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
bool myFriendlyPosition
Flag for friendly position.
void drawDetectorLogo(const GUIVisualizationSettings &s, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw detector Logo
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
std::vector< std::string > myVehicleTypes
attribute vehicle types
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
double newSecondPos
new second position
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
A NBNetBuilder extended by visualisation and editing capabilities.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
GNEViewNet * getViewNet() const
get view net
const std::string & getID() const
get ID
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
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 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...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEUndoList * getUndoList() const
get the undoList object
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
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)
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationDetailSettings detailSettings
detail settings
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
GUIVisualizationColorSettings colorSettings
color settings
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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|....
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"
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
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".
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor BLACK
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
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)
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
bool showAdditionals() const
check if additionals has to be drawn
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
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double detectorDetails
details for detectors
static const RGBColor E2Color
color for E2 detectors
static const double E2Width
E2 detector widths.
A structure which describes a connection between edges or lanes.