68 if (additionalParent) {
83 SumoXMLTag tag = static_cast<SumoXMLTag>(element);
114 SumoXMLTag tag = static_cast<SumoXMLTag>(element);
118 if (TAZ !=
nullptr) {
123 b.
add(i->getCenteringBoundary());
153 if (edge ==
nullptr || laneIndex < 0 || edge->getNumLanes() <= laneIndex) {
154 WRITE_ERROR(
"Lane '" + laneID +
"' to place poi '" + poiID +
"' on is not known.");
160 if (lanePos < 0 || lanePos > edge->
getLength()) {
163 return edge->
getLanes()[laneIndex].shape.positionAtOffset(lanePos, -lanePosLat);
201 return parseAndBuildTAZ(viewNet, allowUndoRedo, attrs, insertedAdditionals);
240 GNEAdditionalHandler::buildBusStop(
GNEViewNet* viewNet,
bool allowUndoRedo,
const std::string&
id,
GNELane* lane,
const std::string& startPos,
const std::string& endPos,
const std::string& name,
const std::vector<std::string>& lines,
int personCapacity,
bool friendlyPosition,
bool blockMovement) {
242 GNEBusStop* busStop =
new GNEBusStop(
id, lane, viewNet, startPos, endPos, name, lines, personCapacity, friendlyPosition, blockMovement);
250 busStop->
incRef(
"buildBusStop");
262 if (lane ==
nullptr) {
264 }
else if (busStop ==
nullptr) {
269 GNEAccess* access =
new GNEAccess(busStop, lane, viewNet, pos, length, friendlyPos, blockMovement);
278 access->
incRef(
"buildAccess");
296 containerStop->
incRef(
"buildContainerStop");
298 return containerStop;
307 double chargingPower,
double efficiency,
bool chargeInTransit,
SUMOTime chargeDelay,
bool friendlyPosition,
bool blockMovement) {
309 GNEChargingStation* chargingStation =
new GNEChargingStation(
id, lane, viewNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition, blockMovement);
317 chargingStation->
incRef(
"buildChargingStation");
319 return chargingStation;
328 bool friendlyPosition,
int roadSideCapacity,
bool onRoad,
double width,
const std::string& length,
double angle,
bool blockMovement) {
330 GNEParkingArea* parkingArea =
new GNEParkingArea(
id, lane, viewNet, startPos, endPos, name, friendlyPosition, roadSideCapacity, onRoad, width, length, angle, blockMovement);
338 parkingArea->
incRef(
"buildParkingArea");
357 parkingSpace->
incRef(
"buildParkingSpace");
364 GNEAdditionalHandler::buildDetectorE1(
GNEViewNet* viewNet,
bool allowUndoRedo,
const std::string&
id,
GNELane* lane,
double pos,
SUMOTime freq,
const std::string& filename,
const std::string& vehicleTypes,
const std::string& name,
bool friendlyPos,
bool blockMovement) {
366 GNEDetectorE1* detectorE1 =
new GNEDetectorE1(
id, lane, viewNet, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement);
374 detectorE1->
incRef(
"buildDetectorE1");
385 const std::string& vehicleTypes,
const std::string& name,
SUMOTime timeThreshold,
double speedThreshold,
double jamThreshold,
bool friendlyPos,
bool blockMovement) {
387 GNEDetectorE2* detectorE2 =
new GNEDetectorE2(
id, lane, viewNet, pos, length, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold, friendlyPos, blockMovement);
395 detectorE2->
incRef(
"buildDetectorE2");
406 const std::string& vehicleTypes,
const std::string& name,
SUMOTime timeThreshold,
double speedThreshold,
double jamThreshold,
bool friendlyPos,
bool blockMovement) {
408 GNEDetectorE2* detectorE2 =
new GNEDetectorE2(
id, lanes, viewNet, pos, endPos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold, friendlyPos, blockMovement);
415 for (
auto i : lanes) {
416 i->addAdditionalChild(detectorE2);
418 detectorE2->
incRef(
"buildDetectorE2Multilane");
431 const std::string& name,
SUMOTime timeThreshold,
double speedThreshold,
bool blockMovement) {
433 GNEDetectorE3* detectorE3 =
new GNEDetectorE3(
id, viewNet, pos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, blockMovement);
440 detectorE3->
incRef(
"buildDetectorE3");
452 if (lane ==
nullptr) {
454 }
else if (E3Parent ==
nullptr) {
466 entry->
incRef(
"buildDetectorEntry");
476 if (lane ==
nullptr) {
478 }
else if (E3Parent ==
nullptr) {
490 exit->
incRef(
"buildDetectorExit");
508 detectorE1Instant->
incRef(
"buildDetectorE1Instant");
510 return detectorE1Instant;
530 calibrator->
incRef(
"buildCalibrator");
552 calibrator->
incRef(
"buildCalibrator");
563 const std::string& vehsPerHour,
const std::string& speed,
const RGBColor& color,
const std::string& departLane,
const std::string& departPos,
564 const std::string& departSpeed,
const std::string& arrivalLane,
const std::string& arrivalPos,
const std::string& arrivalSpeed,
const std::string& line,
565 int personNumber,
int containerNumber,
bool reroute,
const std::string& departPosLat,
const std::string& arrivalPosLat,
SUMOTime begin,
SUMOTime end) {
569 arrivalLane, arrivalPos, arrivalSpeed, line, personNumber, containerNumber, reroute,
570 departPosLat, arrivalPosLat, begin, end);
577 flow->
incRef(
"buildCalibratorFlow");
584 GNEAdditionalHandler::buildRerouter(
GNEViewNet* viewNet,
bool allowUndoRedo,
const std::string&
id,
Position pos,
const std::vector<GNEEdge*>& edges,
double prob,
const std::string& name,
const std::string& file,
bool off,
SUMOTime timeThreshold,
const std::string& vTypes,
bool blockMovement) {
586 GNERerouter* rerouter =
new GNERerouter(
id, viewNet, pos, edges, name, file, prob, off, timeThreshold, vTypes, blockMovement);
594 for (
auto i : edges) {
595 i->addAdditionalParent(rerouter);
597 rerouter->
incRef(
"buildRerouter");
604 GNEAdditionalHandler rerouterValuesHandler(currentAdditionalFilename + file, viewNet, rerouter);
633 rerouterInterval->
incRef(
"buildRerouterInterval");
635 return rerouterInterval;
653 closingLaneReroute->
incRef(
"buildClosingLaneReroute");
655 return closingLaneReroute;
670 closingReroute->
incRef(
"buildClosingReroute");
672 return closingReroute;
687 destProbReroute->
incRef(
"builDestProbReroute");
689 return destProbReroute;
704 parkingAreaReroute->
incRef(
"builParkingAreaReroute");
706 return parkingAreaReroute;
721 routeProbReroute->
incRef(
"buildRouteProbReroute");
723 return routeProbReroute;
740 routeProbe->
incRef(
"buildRouteProbe");
760 for (
auto i : lanes) {
761 i->addAdditionalParent(variableSpeedSign);
763 variableSpeedSign->
incRef(
"buildVariableSpeedSign");
765 return variableSpeedSign;
783 variableSpeedSignStep->
incRef(
"buildVariableSpeedSignStep");
785 return variableSpeedSignStep;
801 vaporizer->
incRef(
"buildVaporizer");
809 GNETAZ* TAZ =
new GNETAZ(
id, viewNet, shape, color, blockMovement);
816 for (
auto i : edges) {
828 for (
auto i : edges) {
831 TAZSource->
incRef(
"buildTAZ");
835 TAZSink->
incRef(
"buildTAZ");
858 if (TAZSink ==
nullptr) {
867 TAZSink->
incRef(
"buildTAZSource");
879 if (TAZSource ==
nullptr) {
888 TAZSource->
incRef(
"buildTAZSource");
898 TAZSource->
incRef(
"buildTAZSource");
915 if (TAZSource ==
nullptr) {
924 TAZSource->
incRef(
"buildTAZSink");
935 if (TAZSink ==
nullptr) {
944 TAZSink->
incRef(
"buildTAZSink");
954 TAZSink->
incRef(
"buildTAZSink");
970 WRITE_WARNING(
"The position of additional '" + additionalID +
"' lies beyond the lane's '" + lane.
getID() +
"' length.");
978 if (fabs(pos) > laneLength) {
981 }
else if (pos < 0) {
983 }
else if (pos > laneLength) {
984 pos = laneLength - 0.01;
992 if ((pos < 0) || ((pos + length) > laneLength)) {
995 }
else if (pos < 0) {
997 }
else if (pos > laneLength) {
998 pos = laneLength - 0.01;
1000 }
else if ((pos + length) > laneLength) {
1001 length = laneLength - pos - 0.01;
1029 std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1034 sortedIntervals.back().first = GNEAttributeCarrier::parse<SUMOTime>(i->getAttribute(
SUMO_ATTR_BEGIN));
1035 sortedIntervals.back().second = GNEAttributeCarrier::parse<SUMOTime>(i->getAttribute(
SUMO_ATTR_END));
1038 sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1040 std::sort(sortedIntervals.begin(), sortedIntervals.end());
1042 for (
int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1043 if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1066 if (edge ==
nullptr) {
1070 }
else if (begin > end) {
1076 if (insertedAdditionals) {
1090 const std::string
id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
"",
SUMO_TAG_TAZ,
SUMO_ATTR_ID, abort);
1094 bool blockMovement =
false;
1099 std::vector<std::string> edgeIDs;
1101 std::string parsedAttribute = attrs.
get<std::string>(
SUMO_ATTR_EDGES,
id.c_str(), abort,
false);
1102 edgeIDs = GNEAttributeCarrier::parse<std::vector<std::string> >(parsedAttribute);
1105 std::vector<GNEEdge*> edges;
1106 for (
auto i : edgeIDs) {
1108 if (edge ==
nullptr) {
1112 edges.push_back(edge);
1122 GNEAdditional* additionalCreated =
buildTAZ(viewNet, allowUndoRedo,
id, shape, color, edges, blockMovement);
1124 if (insertedAdditionals) {
1146 if (insertedAdditionals) {
1153 if (edge ==
nullptr) {
1155 }
else if (TAZ ==
nullptr) {
1161 if (insertedAdditionals) {
1183 if (insertedAdditionals) {
1190 if (edge ==
nullptr) {
1192 }
else if (TAZ ==
nullptr) {
1198 if (insertedAdditionals) {
1225 }
else if (edge ==
nullptr) {
1230 if (GNEAttributeCarrier::canParse<double>(freq)) {
1231 if (GNEAttributeCarrier::parse<double>(freq) < 0) {
1244 if (insertedAdditionals) {
1284 if (insertedAdditionals) {
1291 if (route ==
nullptr) {
1294 }
else if (vtype ==
nullptr) {
1297 }
else if ((vehsPerHour.empty()) && (speed.empty())) {
1300 }
else if (calibrator !=
nullptr) {
1302 GNEAdditional* additionalCreated =
buildCalibratorFlow(viewNet, allowUndoRedo, calibrator, route, vtype, vehsPerHour, speed, color, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
1303 line, personNumber, containerNumber, reroute, departPosLat, arrivalPosLat, begin, end);
1305 if (insertedAdditionals) {
1319 std::string polygonID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
"",
SUMO_TAG_POLY,
SUMO_ATTR_ID, abort);
1324 std::string type = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, polygonID,
SUMO_TAG_POLY,
SUMO_ATTR_TYPE, abort);
1336 bool success =
true;
1337 for (
int i = 0; i < (int)shape.size(); i++) {
1341 WRITE_WARNING(
"Unable to project coordinates for polygon '" + polygonID +
"'.");
1350 if (!
myShapeContainer.
addPolygon(polygonID, type, color, layer, angle, imgFile, relativePath, shape, geo, fill, lineWidth,
false)) {
1351 WRITE_WARNING(
"Polygon with ID '" + polygonID +
"' already exists.");
1364 std::string
id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
"",
SUMO_TAG_VSS,
SUMO_ATTR_ID, abort);
1370 bool blockMovement =
false;
1377 std::vector<GNELane*> lanes;
1379 lanes = GNEAttributeCarrier::parse<std::vector<GNELane*> >(viewNet->
getNet(), lanesIDs);
1384 }
else if (lanes.size() == 0) {
1385 WRITE_WARNING(
"A Variable Speed Sign needs at least one lane.");
1390 if (insertedAdditionals) {
1411 if (insertedAdditionals) {
1418 if (variableSpeedSign !=
nullptr) {
1422 if (insertedAdditionals) {
1446 bool blockMovement =
false;
1453 std::vector<GNEEdge*> edges;
1455 edges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(viewNet->
getNet(), edgesIDs);
1460 }
else if (edges.size() == 0) {
1465 file, off, timeThreshold, vTypes, blockMovement);
1467 if (insertedAdditionals) {
1488 if (insertedAdditionals) {
1495 if (rerouter ==
nullptr) {
1498 if (insertedAdditionals) {
1504 if (lastInsertedRerouterInterval) {
1511 }
else if (rerouter !=
nullptr) {
1515 if (insertedAdditionals) {
1538 if (insertedAdditionals) {
1545 if (lane ==
nullptr) {
1547 }
else if (rerouterInterval !=
nullptr) {
1551 if (insertedAdditionals) {
1574 if (insertedAdditionals) {
1581 if (edge ==
nullptr) {
1583 }
else if (rerouterInterval !=
nullptr) {
1587 if (insertedAdditionals) {
1609 if (insertedAdditionals) {
1616 if (edge ==
nullptr) {
1618 }
else if (rerouterInterval !=
nullptr) {
1622 if (insertedAdditionals) {
1645 if (insertedAdditionals) {
1652 if (parkingArea ==
nullptr) {
1654 }
else if (rerouterInterval !=
nullptr) {
1658 if (insertedAdditionals) {
1679 if (insertedAdditionals) {
1686 if (rerouterInterval !=
nullptr) {
1690 if (insertedAdditionals) {
1709 std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id,
SUMO_TAG_BUS_STOP,
SUMO_ATTR_LINES, abort);
1713 bool blockMovement =
false;
1724 }
else if (lane ==
nullptr) {
1732 GNEAdditional* additionalCreated =
buildBusStop(viewNet, allowUndoRedo,
id, lane, startPos, endPos, name, lines, personCapacity, friendlyPosition, blockMovement);
1734 if (insertedAdditionals) {
1756 bool blockMovement =
false;
1767 }
else if (lane ==
nullptr) {
1775 GNEAdditional* additionalCreated =
buildContainerStop(viewNet, allowUndoRedo,
id, lane, startPos, endPos, name, lines, friendlyPosition, blockMovement);
1777 if (insertedAdditionals) {
1796 bool blockMovement =
false;
1802 double posDouble = GNEAttributeCarrier::parse<double>(position);
1807 if (insertedAdditionals) {
1814 if (lane ==
nullptr) {
1816 }
else if (busStop ==
nullptr) {
1826 if (insertedAdditionals) {
1851 bool blockMovement =
false;
1862 }
else if (lane ==
nullptr) {
1871 efficiency, chargeInTransit, chargeDelay, friendlyPosition, blockMovement);
1873 if (insertedAdditionals) {
1899 bool blockMovement =
false;
1910 }
else if (lane ==
nullptr) {
1919 roadSideCapacity, onRoad, width, length, angle, blockMovement);
1921 if (insertedAdditionals) {
1940 bool blockMovement =
false;
1949 if (insertedAdditionals) {
1956 if (parkingAreaParent !=
nullptr) {
1960 if (insertedAdditionals) {
1974 std::string edgeID, laneId, id;
1991 }
else if (edge ==
nullptr) {
1997 if (insertedAdditionals) {
2018 }
else if (lane ==
nullptr) {
2024 if (insertedAdditionals) {
2050 bool blockMovement =
false;
2061 }
else if (lane ==
nullptr) {
2068 GNEAdditional* additionalCreated =
buildDetectorE1(viewNet, allowUndoRedo,
id, lane, position, frequency, file, vehicleTypes, name, friendlyPos, blockMovement);
2070 if (insertedAdditionals) {
2086 std::string
id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
"", E2Tag,
SUMO_ATTR_ID, abort);
2094 double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs,
id, E2Tag,
SUMO_ATTR_POSITION, abort);
2096 std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
id, E2Tag,
SUMO_ATTR_FILE, abort);
2097 std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
id, E2Tag,
SUMO_ATTR_VTYPES, abort);
2098 std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
id, E2Tag,
SUMO_ATTR_NAME, abort);
2102 bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs,
id, E2Tag,
SUMO_ATTR_FRIENDLY_POS, abort);
2104 bool blockMovement =
false;
2106 blockMovement = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs,
id, E2Tag,
GNE_ATTR_BLOCK_MOVEMENT, abort);
2109 GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
id, E2Tag,
SUMO_ATTR_CONT, abort);
2113 if (laneId.empty() && laneIds.empty()) {
2119 std::vector<GNELane*> lanes;
2120 bool laneConsecutives =
true;
2122 lanes = GNEAttributeCarrier::parse<std::vector<GNELane*> >(viewNet->
getNet(), laneIds);
2132 WRITE_WARNING(
"The lane '" + laneId +
"' to use within the " +
toString(E2Tag) +
" '" +
id +
"' is not known.");
2138 WRITE_WARNING(
"The list of lanes '" + laneIds +
"' to use within the " +
toString(E2Tag) +
" '" +
id +
"' isn't valid.");
2139 }
else if (!lanes.empty() && !laneConsecutives) {
2140 WRITE_WARNING(
"The lanes '" + laneIds +
"' to use within the " +
toString(E2Tag) +
" '" +
id +
"' aren't consecutives.");
2143 }
else if (!lanes.empty() && !
fixE2DetectorPosition(position, length, lanes.front()->getParentEdge().getNBEdge()->getFinalLength(), friendlyPos)) {
2145 }
else if (!lanes.empty() && !
fixE2DetectorPosition(endPos, length, lanes.back()->getParentEdge().getNBEdge()->getFinalLength(), friendlyPos)) {
2150 name, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, friendlyPos, blockMovement);
2152 if (insertedAdditionals) {
2159 name, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, friendlyPos, blockMovement);
2161 if (insertedAdditionals) {
2185 bool blockMovement =
false;
2196 GNEAdditional* additionalCreated =
buildDetectorE3(viewNet, allowUndoRedo,
id, pos, frequency, file, vehicleTypes, name, haltingTimeThreshold, haltingSpeedThreshold, blockMovement);
2198 if (insertedAdditionals) {
2216 bool blockMovement =
false;
2226 if (insertedAdditionals) {
2233 if (lane ==
nullptr) {
2237 }
else if (E3Parent) {
2241 if (insertedAdditionals) {
2259 bool blockMovement =
false;
2269 if (insertedAdditionals) {
2276 if (lane ==
nullptr) {
2280 }
else if (E3Parent) {
2284 if (insertedAdditionals) {
2306 bool blockMovement =
false;
2317 }
else if (lane ==
nullptr) {
2326 if (insertedAdditionals) {
2343 std::string POIID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
"",
SUMO_TAG_POI,
SUMO_ATTR_ID, abort);
2355 std::string type = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, POIID,
SUMO_TAG_POI,
SUMO_ATTR_TYPE, abort);
2370 WRITE_WARNING(
"The lane '" + laneID +
"' to use within the PoI '" + POIID +
"' is not known.");
2374 bool useGeo =
false;
2380 pos =
getLanePos(POIID, laneID, lanePos, lanePosLat);
2384 WRITE_WARNING(
"Either (x, y), (lon, lat) or (lane, pos) must be specified for PoI '" + POIID +
"'.");
2387 WRITE_WARNING(
"(lon, lat) is specified for PoI '" + POIID +
"' but no geo-conversion is specified for the network.");
2394 WRITE_WARNING(
"Unable to project coordinates for PoI '" + POIID +
"'.");
2400 if (!
myShapeContainer.
addPOI(POIID, type, color, pos, useGeo, laneID, lanePos, lanePosLat, layer, angle, imgFile, relativePath, width, height,
false)) {
2401 WRITE_WARNING(
"POI with ID '" + POIID +
"' already exists.");
2420 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key cannot be empty");
2424 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key contains invalid characters");
2428 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key doesn't exist");
2434 WRITE_WARNING(
"Error parsing value from shape generic parameter. Value contains invalid characters");
2439 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + val +
"' into shape.");
2451 WRITE_WARNING(
"Error parsing key from additional generic parameter. Key cannot be empty");
2455 WRITE_WARNING(
"Error parsing key from additional generic parameter. Key contains invalid characters");
2459 WRITE_WARNING(
"Error parsing key from additional generic parameter. Key doesn't exist");
2465 WRITE_WARNING(
"Error parsing value from additional generic parameter. Value contains invalid characters");
2477 WRITE_WARNING(
"Generic Parameters has to be declared within the definition of an additional or a shape element");
2493 myInsertedElements.back().second = additional;
2499 if (!myInsertedElements.empty()) {
2500 myInsertedElements.pop_back();
2507 if (myInsertedElements.size() < 2) {
2509 WRITE_WARNING(
"A " +
toString(myInsertedElements.back().first) +
" must be declared within the definition of a " +
toString(expectedTag) +
".");
2512 if (myInsertedElements.size() < 2) {
2515 }
else if ((myInsertedElements.end() - 2)->second ==
nullptr) {
2521 if (retrievedAdditional ==
nullptr) {
2523 WRITE_WARNING(
"A " +
toString((myInsertedElements.end() - 1)->first) +
" must be declared within the definition of a " +
toString(expectedTag) +
".");
2527 WRITE_WARNING(
"A " +
toString((myInsertedElements.end() - 1)->first) +
" cannot be declared within the definition of a " + retrievedAdditional->
getTagStr() +
".");
2530 return retrievedAdditional;
2539 for (std::vector<std::pair<SumoXMLTag, GNEAdditional*> >::const_reverse_iterator i = myInsertedElements.rbegin(); i != myInsertedElements.rend(); i++) {