57 #ifdef CHECK_MEMORY_LEAKS 70 rerouterIntervalToInsertValues(NULL),
157 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
158 const std::string edgeId = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_EDGE, abort);
167 WRITE_WARNING(
"The edge '" + edgeId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
181 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
182 std::string edgeId = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_EDGE, abort);
184 std::string file = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_FILE, abort);
185 int begin = getParsedAttribute<int>(attrs, 0, tag,
SUMO_ATTR_BEGIN, abort);
192 WRITE_WARNING(
"The edge '" + edgeId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
206 std::string flowId = attrs.
get<std::string>(
SUMO_ATTR_ID, 0, ok,
false);
212 std::string type = attrs.
get<std::string>(
SUMO_ATTR_TYPE, flowId.c_str(), ok,
false);
218 std::string route = attrs.
get<std::string>(
SUMO_ATTR_ROUTE, flowId.c_str(), ok,
false);
248 if (calibratorToInsertFlow == NULL) {
279 if (variableSpeedSignToInsertStep == NULL) {
281 }
else if (!variableSpeedSignToInsertStep->
insertStep(time, speed)) {
292 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
293 std::string file = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_FILE, abort);
294 std::string listOfLanes = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANES, abort);
300 std::vector<std::string> lanesID;
304 std::map<SUMOReal, SUMOReal> VSSValues;
306 std::vector<GNELane*> lanes;
307 for (
int i = 0; i < (int)lanesID.size(); i++) {
310 lanes.push_back(lane);
327 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
328 std::string edgesAttribute = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_EDGES, abort);
329 std::string file = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_FILE, abort);
331 bool off = getParsedAttribute<bool>(attrs,
id.c_str(), tag,
SUMO_ATTR_OFF, abort);
337 std::vector<std::string> edgesID;
343 std::vector<GNEEdge*> edges;
344 for (
int i = 0; i < (int)edgesID.size(); i++) {
347 edges.push_back(edge);
364 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
365 std::string laneId = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANE, abort);
368 std::string linesAttribute = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LINES, abort,
false);
372 std::vector<std::string> lines;
378 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
393 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
394 std::string laneId = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANE, abort);
397 std::string linesAttribute = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LINES, abort,
false);
401 std::vector<std::string> lines;
407 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
422 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
423 std::string laneId = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANE, abort);
436 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
451 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
452 std::string laneId = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANE, abort);
453 std::string outfile = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_OUTPUT, abort);
463 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
464 }
else if (
buildCalibrator(
myViewNet,
id, edge, position, outfile, freq, std::vector<GNECalibrator::GNECalibratorFlow*>())) {
475 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
476 std::string laneId = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANE, abort);
479 std::string file = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_FILE, abort);
487 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
501 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
502 std::string laneId = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_LANE, abort);
505 std::string file = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_FILE, abort);
510 bool cont = getParsedAttribute<bool>(attrs,
id.c_str(), tag,
SUMO_ATTR_CONT, abort);
517 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(tag) +
" '" +
id +
"' is not known.");
520 }
else if (
buildDetectorE2(
myViewNet,
id, lane, position, length, frequency, file, cont, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold)) {
531 std::string
id = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_ID, abort);
533 std::string file = getParsedAttribute<std::string>(attrs,
id.c_str(), tag,
SUMO_ATTR_FILE, abort);
556 std::string laneId = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_LANE, abort);
578 std::string laneId = getParsedAttribute<std::string>(attrs, 0, tag,
SUMO_ATTR_LANE, abort);
606 std::vector<std::string> lines;
610 return buildBusStop(viewNet,
id, lane, startPos, endPos, lines);
621 std::vector<std::string> lines;
642 return buildChargingStation(viewNet,
id, lane, startPos, endPos, chargingPower, efficiency, chargeInTransit, chargeDelay);
657 return buildDetectorE1(viewNet,
id, lane, pos, freq, filename, splitByType);
670 bool cont = GNEAttributeCarrier::parse<bool>(values[
SUMO_ATTR_CONT]);
676 return buildDetectorE2(viewNet,
id, lane, pos, lenght, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold);
691 if (pos.size() == 1) {
692 return buildDetectorE3(viewNet,
id, pos[0], freq, filename, timeThreshold, speedThreshold);
727 std::vector<std::string> laneIds;
730 std::map<SUMOReal, SUMOReal> VSSValues;
732 std::vector<GNELane*> lanes;
733 for (
int i = 0; i < (int)laneIds.size(); i++) {
737 if (pos.size() == 1) {
753 std::vector<GNECalibrator::GNECalibratorFlow*> flowValues;
756 return buildCalibrator(viewNet,
id, edge, pos, outfile, freq, flowValues);
767 std::vector<std::string> edgeIds;
770 bool off = GNEAttributeCarrier::parse<bool>(values[
SUMO_ATTR_OFF]);
774 std::vector<GNEEdge*> edges;
775 for (
int i = 0; i < (int)edgeIds.size(); i++) {
779 if (pos.size() == 1) {
780 return buildRerouter(viewNet,
id, pos[0], edges, prob, file, off);
883 GNEDetectorE2* detectorE2 =
new GNEDetectorE2(
id, lane, viewNet, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold);
915 }
else if (E3Parent == NULL) {
941 }
else if (E3Parent == NULL) {
1070 WRITE_WARNING(
"The position of " + tt +
" '" + tid +
"' lies beyond the lane's '" + lane.
getID() +
"' length.");
1079 if (minLength > laneLength) {
1083 startPos += laneLength;
1086 endPos += laneLength;
1088 if (endPos < minLength || endPos > laneLength) {
1092 if (endPos < minLength) {
1095 if (endPos > laneLength) {
1096 endPos = laneLength;
1099 if (startPos < 0 || startPos > endPos - minLength) {
1106 if (startPos > endPos - minLength) {
1107 startPos = endPos - minLength;
1114 template <
typename T> T
1117 std::string parsedAttribute =
"0";
1121 std::string additionalOfWarningMessage;
1123 additionalOfWarningMessage =
toString(tag) +
" with ID '" +
toString(objectid) +
"'";
1125 additionalOfWarningMessage =
toString(tag);
1130 parsedAttribute = attrs.
get<std::string>(attribute, objectid, ok,
false);
1132 if (ok && !GNEAttributeCarrier::canParse<T>(parsedAttribute)) {
1135 std::string errorFormat;
1138 if (GNEAttributeCarrier::canParse<int>(parsedAttribute)) {
1140 int parsedIntAttribute = GNEAttributeCarrier::parse<int>(parsedAttribute);
1142 errorFormat =
"Cannot be negative; ";
1146 errorFormat =
"Cannot be parsed to int; ";
1152 if (GNEAttributeCarrier::canParse<SUMOReal>(parsedAttribute)) {
1154 SUMOReal parsedSumoRealAttribute = GNEAttributeCarrier::parse<SUMOReal>(parsedAttribute);
1156 errorFormat =
"Cannot be negative; ";
1160 errorFormat =
"Cannot be parsed to float; ";
1166 if (GNEAttributeCarrier::canParse<SUMOReal>(parsedAttribute)) {
1168 SUMOReal parsedSumoRealAttribute = GNEAttributeCarrier::parse<SUMOReal>(parsedAttribute);
1169 if (parsedSumoRealAttribute < 0) {
1170 errorFormat =
"Time cannot be negative; ";
1174 errorFormat =
"Cannot be parsed to time; ";
1182 parsedAttribute =
toString(GNEAttributeCarrier::getDefaultValue<T>(tag, attribute));
1186 additionalOfWarningMessage +
" is invalid; " + errorFormat +
"Default value '" +
toString(parsedAttribute) +
"' will be used.");
1190 additionalOfWarningMessage +
" is invalid; " + errorFormat +
"Additional cannot be created");
1192 parsedAttribute =
"0";
1199 parsedAttribute =
toString(GNEAttributeCarrier::getDefaultValue<T>(tag, attribute));
1203 additionalOfWarningMessage +
" is missing; Default value '" +
toString(parsedAttribute) +
"' will be used.");
1207 additionalOfWarningMessage +
" is missing; Additional cannot be created");
1213 return GNEAttributeCarrier::parse<T>(parsedAttribute);
bool insertStep(const SUMOReal time, const SUMOReal speed)
insert a new step in variable speed signal
void parseVariableSpeedSignStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses step values of VariableSpeedSigns.
bool setDepartSpeed(std::string departSpeed)
set depart speed
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool setPersonNumber(int personNumber)
set number of persons
void parseCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
static bool isFloat(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical of type float
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
alternative tag for e1 detector
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
static std::string getAttributeType(SumoXMLTag tag, SumoXMLAttr attr)
get type of attribute
void parseAndBuildDetectorE1(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a induction loop detector (E1)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
begin/end of the description of a single lane
a flow definition (used by router)
static bool buildDetectorEntry(GNEViewNet *viewNet, GNEDetectorE3 *E3Parent, GNELane *lane, SUMOReal pos)
Builds a entry detector (E3)
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
static bool buildVaporizer(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal startTime, SUMOReal end)
Builds a vaporizer (lane speed trigger)
Allow/disallow charge in transit in Charging Stations.
GNEAdditionalHandler(const std::string &file, GNEViewNet *viewNet)
Constructor.
bool setArrivalSpeed(std::string arrivalSpeed)
set arrival speed
weights: time range begin
static bool buildAdditional(GNEViewNet *viewNet, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Build additionals.
static bool isPositive(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is only Positive (i.e. cannot take negative values)
bool setVehsPerHour(SUMOReal vehsPerHour)
set vehicles per hour
void parseAndBuildDetectorExit(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Exit detector.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
bool setPeriod(SUMOReal period)
set period of vehicles
static bool buildRouteProbe(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal freq, const std::string &file, SUMOReal begin)
builds a Route probe
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static bool buildChargingStation(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, SUMOReal chargeDelay)
Builds a charging Station.
bool setNumber(int number)
set number of vehicles
SAX-handler base for SUMO-files.
bool setBegin(SUMOReal begin)
set begin step
static bool buildDetectorE3(GNEViewNet *viewNet, const std::string &id, Position pos, SUMOReal freq, const std::string &filename, const SUMOReal timeThreshold, SUMOReal speedThreshold)
Builds a multi entry exit detector (E3)
#define WRITE_WARNING(msg)
void parseAndBuildVariableSpeedSign(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Variable Speed Signal (lane speed trigger)
void parseAndBuildDetectorE2(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a lane area detector (E2)
bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check if the position of an stoppingPlace over a lane is valid
bool setArrivalLane(std::string arrivalLane)
set arrival lane
GNEUndoList * getUndoList() const
get the undoList object
static bool buildContainerStop(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, const std::vector< std::string > &lines)
Builds a container stop.
static bool isInt(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical or type int
static bool buildVariableSpeedSign(GNEViewNet *viewNet, const std::string &id, Position pos, const std::vector< GNELane * > &destLanes, const std::string &file, const std::map< SUMOReal, SUMOReal > &VSSValues)
Builds a VariableSpeedSign (lane speed trigger)
static bool buildDetectorE1(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, SUMOReal freq, const std::string &filename, bool splitByType)
Builds a induction loop detector (E1)
bool getFriendlyPosition(const SUMOSAXAttributes &attrs, const char *objectid)
get special attribute friendly position, used in stopping places
static bool buildDetectorExit(GNEViewNet *viewNet, GNEDetectorE3 *E3Parent, GNELane *lane, SUMOReal pos)
Builds a exit detector (E3)
static bool isTime(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is time
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
~GNEAdditionalHandler()
Destructor.
bool setEnd(SUMOReal end)
set end step
const std::string & getFileName() const
returns the current file name
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool buildBusStop(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, const std::vector< std::string > &lines)
Builds a bus stop.
GNEEdge & getParentEdge()
Returns underlying parent edge.
Encapsulated SAX-Attributes.
static bool hasDefaultValue(SumoXMLTag tag, SumoXMLAttr attr)
check if attribute of an element has a default avlue
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
A point in 2D or 3D with translation and scaling methods.
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
void parseAndBuildRerouter(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a rerouter.
bool setContainerNumber(int containerNumber)
set number of container
A lane area vehicles can halt at (netedit-version)
bool setDepartPos(std::string departPos)
set depart position
const std::string getID() const
function to support debugging
bool checkAdditionalParent(SumoXMLTag currentTag)
used to check hierarchy of aditionals with parents and childs (for example, E3)
GNEViewNet * myViewNet
pointer to View's Net
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
void parseAndBuildRouteProbe(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds routeProbe.
GNEDetectorE3 * myE3Parent
Pointer to the last inserted E3.
A road/street connecting two junctions (netedit-version)
static bool buildRerouter(GNEViewNet *viewNet, const std::string &id, Position pos, const std::vector< GNEEdge * > &edges, SUMOReal prob, const std::string &file, bool off)
builds a rerouter
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
bool setLine(std::string line)
set line of busStop/containerStop
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
trigger: the time of the step
bool setProbability(SUMOReal probability)
set probability of vehicle
SUMOReal getLaneShapeLenght() const
returns the length of the lane's shape
bool setArrivalPos(std::string arrivalPos)
set arrival position
void parseAndBuildBusStop(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a bus stop.
void parseAndBuildContainerStop(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a container stop.
void insertFlow(GNECalibratorFlow *flow)
insert a new flow
bool setColor(std::string color)
set color of flow
static T getParsedAttribute(const SUMOSAXAttributes &attrs, const char *objectid, SumoXMLTag tag, SumoXMLAttr attribute, bool &abort, bool report=true)
get parsed attribute of XML and show warnings if there are problems
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a vaporization.
static bool buildCalibrator(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal pos, const std::string &outfile, SUMOReal freq, const std::vector< GNECalibrator::GNECalibratorFlow * > &flowValues)
builds a microscopic calibrator
SUMOReal getPosition(const SUMOSAXAttributes &attrs, GNELane &lane, const std::string &tt, const std::string &tid)
extracts the position, checks whether it shall be mirrored and checks whether it is within the lane...
void resetLastTag()
reset last Tag and clear non-valid Additionals (For example, created E3 withouts Entry/Exit childs) ...
GNENet * getNet() const
get the net object
bool setDepartLane(std::string departLane)
set depart lane
SumoXMLTag getTag() const
get XML Tag assigned to this object
Eficiency of the charge in Charging Stations.
SumoXMLTag myLastTag
last used Tag
parent of an additional element
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
Delay in the charge of charging stations.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
int getNumberOfEntryChilds() const
get number of entry childs
int getNumberOfExitChilds() const
get number of exit childs
GNEAdditional * retrieveAdditional(const std::string &idl, bool hardFail=true) const
Returns the named additional.
A lane area vehicles can halt at (netedit-version)
void parseAndBuildDetectorEntry(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Entry detector.
static bool buildDetectorE2(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, SUMOReal length, SUMOReal freq, const std::string &filename, bool cont, const SUMOReal timeThreshold, SUMOReal speedThreshold, SUMOReal jamThreshold)
Builds a lane Area Detector (E2)
alternative tag for e3 detector
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occured errors.
alternative tag for e2 detector
trigger: a step description