60 routeID(originalDemandElement->getTagProperty().isRoute() ?
61 originalDemandElement->getID() :
62 originalDemandElement->getViewNet()->getNet()->generateDemandElementID(originalDemandElement->getID(),
SUMO_TAG_ROUTE)),
63 edges(originalDemandElement->getParentEdges()),
64 vClass(originalDemandElement->getVClass()),
65 color(originalDemandElement->getColor()) {
75 edges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(viewNet->
getNet(), edgeIDs);
85 if (fromID.size() + toID.size() > 0) {
90 if (from ==
nullptr) {
91 WRITE_ERROR(
"Invalid from-edge '" + fromID +
"' used in trip '" + vehicleID +
"'.");
92 }
else if (to ==
nullptr) {
93 WRITE_ERROR(
"Invalid to-edge '" + toID +
"' used in trip '" + vehicleID +
"'.");
95 WRITE_ERROR(
"Invalid 'via' edges used in trip '" + vehicleID +
"'.");
98 std::vector<GNEEdge*> viaEdges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(viewNet->
getNet(), viaIDs);
100 edges.push_back(from);
101 for (
const auto& i : viaEdges) {
131 WRITE_ERROR(
"There is another " +
toString(vehicleTag) +
" with the same ID='" +
id +
"'.");
143 WRITE_ERROR(
"There is another " +
toString(personTag) +
" with the same ID='" +
id +
"'.");
160 if (vType ==
nullptr) {
161 WRITE_ERROR(
"Invalid vehicle type '" + vehicleParameters.
vtypeid +
"' used in " +
toString(vehicleParameters.
tag) +
" '" + vehicleParameters.
id +
"'.");
162 }
else if (route ==
nullptr) {
171 if (undoDemandElements) {
175 for (
const auto& i : vehicleParameters.
stops) {
184 vehicle->
incRef(
"buildVehicleOverRoute");
186 for (
const auto& i : vehicleParameters.
stops) {
204 if (vType ==
nullptr) {
205 WRITE_ERROR(
"Invalid vehicle type '" + vehicleParameters.
vtypeid +
"' used in " +
toString(vehicleParameters.
tag) +
" '" + vehicleParameters.
id +
"'.");
206 }
else if (route ==
nullptr) {
215 if (undoDemandElements) {
219 for (
const auto& i : vehicleParameters.
stops) {
228 flow->
incRef(
"buildFlowOverRoute");
230 for (
const auto& i : vehicleParameters.
stops) {
247 if (vType ==
nullptr) {
248 WRITE_ERROR(
"Invalid vehicle type '" + vehicleParameters.
vtypeid +
"' used in " +
toString(vehicleParameters.
tag) +
" '" + vehicleParameters.
id +
"'.");
263 if (undoDemandElements) {
274 vehicle->
incRef(
"buildVehicleWithEmbeddedRoute");
278 i->addChildDemandElement(vehicle);
282 embeddedRoute->
incRef(
"buildVehicleWithEmbeddedRoute");
297 if (vType ==
nullptr) {
298 WRITE_ERROR(
"Invalid vehicle type '" + vehicleParameters.
vtypeid +
"' used in " +
toString(vehicleParameters.
tag) +
" '" + vehicleParameters.
id +
"'.");
313 if (undoDemandElements) {
324 flow->
incRef(
"buildFlowWithEmbeddedRoute");
328 i->addChildDemandElement(flow);
332 embeddedRoute->
incRef(
"buildFlowWithEmbeddedRoute");
347 if (vType ==
nullptr) {
348 WRITE_ERROR(
"Invalid vehicle type '" + vehicleParameters.
vtypeid +
"' used in " +
toString(vehicleParameters.
tag) +
" '" + vehicleParameters.
id +
"'.");
355 for (
const auto& viaEdge : via) {
356 vehicleParameters.
via.push_back(viaEdge->getID());
360 if (undoDemandElements) {
364 for (
const auto& i : vehicleParameters.
stops) {
372 trip->
incRef(
"buildTrip");
376 for (
const auto& viaEdge : via) {
377 viaEdge->addChildDemandElement(trip);
380 for (
const auto& i : vehicleParameters.
stops) {
397 if (vType ==
nullptr) {
398 WRITE_ERROR(
"Invalid vehicle type '" + vehicleParameters.
vtypeid +
"' used in " +
toString(vehicleParameters.
tag) +
" '" + vehicleParameters.
id +
"'.");
405 for (
const auto& viaEdge : via) {
406 vehicleParameters.
via.push_back(viaEdge->getID());
410 if (undoDemandElements) {
414 for (
const auto& i : vehicleParameters.
stops) {
422 flow->
incRef(
"buildFlow");
426 for (
const auto& viaEdge : via) {
427 viaEdge->addChildDemandElement(flow);
430 for (
const auto& i : vehicleParameters.
stops) {
445 bool validParentDemandElement =
true;
446 if (stopParameters.
busstop.size() > 0) {
458 WRITE_ERROR(
"Persons doesn't support stops over container stops");
459 validParentDemandElement =
false;
467 WRITE_ERROR(
"Persons doesn't support stops over charging stations");
468 validParentDemandElement =
false;
472 }
else if (stopParameters.
parkingarea.size() > 0) {
476 WRITE_ERROR(
"Persons doesn't support stops over parking areas");
477 validParentDemandElement =
false;
481 }
else if (stopParameters.
lane.size() > 0) {
491 if (validParentDemandElement) {
493 if (stoppingPlace && lane) {
494 WRITE_ERROR(
"A stop must be defined either over a stoppingPlace or over a lane");
495 }
else if (!stoppingPlace && !lane) {
496 WRITE_ERROR(
"A stop requires a stoppingPlace or a lane");
497 }
else if (stoppingPlace) {
499 GNEStop* stop =
new GNEStop(stopTagType, viewNet, stopParameters, stoppingPlace, stopParent);
501 if (undoDemandElements) {
509 stop->
incRef(
"buildStoppingPlaceStop");
513 GNEStop* stop =
new GNEStop(viewNet, stopParameters, lane, stopParent);
515 if (undoDemandElements) {
523 stop->
incRef(
"buildLaneStop");
536 if (pType ==
nullptr) {
541 if (undoDemandElements) {
549 person->
incRef(
"buildPerson");
562 if (pType ==
nullptr) {
563 WRITE_ERROR(
"Invalid personFlow type '" + personFlowParameters.
vtypeid +
"' used in " +
toString(personFlowParameters.
tag) +
" '" + personFlowParameters.
id +
"'.");
567 if (undoDemandElements) {
575 personFlow->
incRef(
"buildPersonFlow");
584 const std::vector<std::string>& types,
const std::vector<std::string>& modes) {
588 if (undoDemandElements) {
596 personTripFromTo->
incRef(
"buildPersonTripFromTo");
605 const std::vector<std::string>& types,
const std::vector<std::string>& modes) {
609 if (undoDemandElements) {
619 personTripBusStop->
incRef(
"buildPersonTripBusStop");
629 if (edges.size() == 0) {
635 if (pathEdges.size() == 0) {
639 GNEWalk* walkEdges =
new GNEWalk(viewNet, personParent, pathEdges, arrivalPos);
641 if (undoDemandElements) {
650 for (
const auto& i : edges) {
651 i->addChildDemandElement(walkEdges);
653 walkEdges->
incRef(
"buildWalkEdges");
664 GNEWalk* walkFromTo =
new GNEWalk(viewNet, personParent, fromEdge, toEdge, {}, arrivalPos);
666 if (undoDemandElements) {
677 walkFromTo->
incRef(
"buildWalkFromTo");
687 GNEWalk* walkBusStop =
new GNEWalk(viewNet, personParent, fromEdge, busStop, {});
689 if (undoDemandElements) {
699 walkBusStop->
incRef(
"buildWalkBusStop");
709 GNEWalk* walkRoute =
new GNEWalk(viewNet, personParent, route, arrivalPos);
711 if (undoDemandElements) {
720 walkRoute->
incRef(
"buildWalkRoute");
730 GNERide* rideFromTo =
new GNERide(viewNet, personParent, fromEdge, toEdge, {}, arrivalPos, lines);
732 if (undoDemandElements) {
743 rideFromTo->
incRef(
"buildRideFromTo");
753 GNERide* rideBusStop =
new GNERide(viewNet, personParent, fromEdge, busStop, {}, lines);
755 if (undoDemandElements) {
766 rideBusStop->
incRef(
"buildRideBusStop");
805 if (createEmbeddedRoute) {
865 if (createEmbeddedRoute) {
923 newVehicleParameters);
938 newVehicleParameters);
949 if (separatedEmbeddedRoute) {
989 newVehicleParameters);
1000 newVehicleParameters);
1011 if (separatedEmbeddedRoute) {
1035 switch (attribute) {
1120 return vehicleWithoutEmbebbeRoute;
1196 if (vType ==
nullptr) {
1228 embeddedRoute->
incRef(
"buildVehicleAndRoute");
1258 i->addChildDemandElement(route);
1260 route->
incRef(
"buildRoute");
1322 vType->
incRef(
"buildVType");
1337 if (pType ==
nullptr) {
1341 bool abortPersonPlans =
false;
1353 if (i->from && i->to) {
1357 i->from = (i - 1)->getLastEdge();
1360 WRITE_ERROR(
"The first person plan of type '" +
toString(i->tag) +
"' needs a from edge. Person cannot be created.");
1364 abortPersonPlans =
true;
1373 i->from = (i - 1)->getLastEdge();
1376 WRITE_ERROR(
"The first person plan of type '" +
toString(i->tag) +
"' needs a from edge. Person cannot be created.");
1380 abortPersonPlans =
true;
1385 if (i->from && i->to) {
1389 i->from = (i - 1)->getLastEdge();
1392 WRITE_ERROR(
"The first person plan of type '" +
toString(i->tag) +
"' needs a from edge. Person cannot be created.");
1396 abortPersonPlans =
true;
1405 i->from = (i - 1)->getLastEdge();
1408 WRITE_ERROR(
"The first person plan of type '" +
toString(i->tag) +
"' needs a from edge. Person cannot be created.");
1412 abortPersonPlans =
true;
1420 if (i->from && i->to) {
1424 i->from = (i - 1)->getLastEdge();
1427 WRITE_ERROR(
"The first person plan of type '" +
toString(i->tag) +
"' needs a from edge. Person cannot be created.");
1431 abortPersonPlans =
true;
1440 i->from = (i - 1)->getLastEdge();
1443 WRITE_ERROR(
"The first person plan of type '" +
toString(i->tag) +
"' needs a from edge. Person cannot be created.");
1447 abortPersonPlans =
true;
1464 if (!abortPersonPlans) {
1497 std::vector<GNEEdge*> viaEdges;
1518 std::vector<GNEEdge*> viaEdges;
1532 std::string errorSuffix;
1547 if (bs ==
nullptr) {
1569 if (cs ==
nullptr) {
1588 if (cs ==
nullptr) {
1606 if (pa ==
nullptr) {
1635 WRITE_ERROR(
"Deprecated attribute 'pos' in description of stop" + errorSuffix);
1681 bool validValues =
true;
1685 if (personTripValuesLoaded.
from ==
nullptr) {
1687 validValues =
false;
1691 personTripValuesLoaded.
vTypes = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs,
"", personTripValuesLoaded.
tag,
SUMO_ATTR_VTYPES,
myAbort);
1692 personTripValuesLoaded.
modes = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs,
"", personTripValuesLoaded.
tag,
SUMO_ATTR_MODES,
myAbort);
1697 if (personTripValuesLoaded.
to ==
nullptr) {
1699 validValues =
false;
1702 for (
const auto& i : personTripValuesLoaded.
modes) {
1703 if ((i !=
"public") && (i !=
"car") && (i !=
"bicycle")) {
1704 validValues =
false;
1709 std::sort(personTripValuesLoaded.
modes.begin(), personTripValuesLoaded.
modes.end());
1710 personTripValuesLoaded.
modes.erase(unique(personTripValuesLoaded.
modes.begin(), personTripValuesLoaded.
modes.end()), personTripValuesLoaded.
modes.end());
1712 WRITE_ERROR(
"A person trip mode can be only a combination of 'public', 'car' or 'bicycle'");
1714 for (
const auto& i : personTripValuesLoaded.
vTypes) {
1717 validValues =
false;
1728 bool validValues =
true;
1732 if (personTripValuesLoaded.
from ==
nullptr) {
1734 validValues =
false;
1738 personTripValuesLoaded.
vTypes = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs,
"", personTripValuesLoaded.
tag,
SUMO_ATTR_VTYPES,
myAbort);
1739 personTripValuesLoaded.
modes = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs,
"", personTripValuesLoaded.
tag,
SUMO_ATTR_MODES,
myAbort);
1744 if (personTripValuesLoaded.
busStop ==
nullptr) {
1746 validValues =
false;
1749 for (
const auto& i : personTripValuesLoaded.
modes) {
1750 if ((i !=
"public") && (i !=
"car") && (i !=
"bicycle")) {
1751 validValues =
false;
1756 std::sort(personTripValuesLoaded.
modes.begin(), personTripValuesLoaded.
modes.end());
1757 personTripValuesLoaded.
modes.erase(unique(personTripValuesLoaded.
modes.begin(), personTripValuesLoaded.
modes.end()), personTripValuesLoaded.
modes.end());
1759 WRITE_ERROR(
"A person trip mode can be only a combination of 'public', 'car' or 'bicycle'");
1761 for (
const auto& i : personTripValuesLoaded.
vTypes) {
1764 validValues =
false;
1772 WRITE_ERROR(
"A personTrip requires either a from-to edges or a from edge and a busStop");
1789 std::string edgeIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs,
"", walkValuesLoaded.
tag,
SUMO_ATTR_EDGES,
myAbort);
1791 walkValuesLoaded.
edges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(
myViewNet->
getNet(), edgeIDs);
1798 if (walkValuesLoaded.
edges.empty()) {
1810 if (walkValuesLoaded.
from ==
nullptr) {
1819 if (walkValuesLoaded.
to ==
nullptr) {
1831 if (walkValuesLoaded.
from ==
nullptr) {
1841 if (walkValuesLoaded.
busStop ==
nullptr) {
1856 if (walkValuesLoaded.
route ==
nullptr) {
1863 WRITE_ERROR(
"A walk requires either a from-to edges, a from edge and a busStop or a route");
1893 if (rideValuesLoaded.
from ==
nullptr) {
1898 rideValuesLoaded.
lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs,
"", rideValuesLoaded.
tag,
SUMO_ATTR_LINES,
myAbort);
1903 if (rideValuesLoaded.
lines.empty()) {
1904 rideValuesLoaded.
lines.push_back(
"ANY");
1907 if (rideValuesLoaded.
to ==
nullptr) {
1919 if (rideValuesLoaded.
from ==
nullptr) {
1924 rideValuesLoaded.
lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs,
"", rideValuesLoaded.
tag,
SUMO_ATTR_LINES,
myAbort);
1929 if (rideValuesLoaded.
lines.empty()) {
1930 rideValuesLoaded.
lines.push_back(
"ANY");
1933 if (rideValuesLoaded.
busStop ==
nullptr) {
1940 WRITE_ERROR(
"A ride requires either a from-to edges or a from edge and a busStop");
1965 containerStop(nullptr),
1966 chargingStation(nullptr),
1967 parkingArea(nullptr),
1976 if (edges.size() > 0) {
1977 return edges.back();
1980 }
else if (busStop) {
1981 return busStop->getParentLanes().front()->getParentEdge();
1982 }
else if (laneStop) {
1983 return laneStop->getParentEdge();