void SUMORouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, false, false, true); break; case SUMO_TAG_CONTAINER: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs, myBeginDefault, myEndDefault); break; case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs, getFileName()); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP: { myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, true); if (myVehicleParameter->id == "") { //@todo warn about deprecation of missing trip ids myVehicleParameter->id = myIdSupplier.getNext(); } myVehicleParameter->setParameter |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; break; } case SUMO_TAG_INTERVAL: { bool ok; myBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, 0, ok); myEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, 0, ok); break; } case SUMO_TAG_PARAM: addParam(attrs); break; default: break; } }
void SUMORouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs); break; case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs, getFileName()); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP: { myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myVehicleParameter->setParameter |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; } break; default: break; } }
void MSRouteHandler::myStartElement(SumoXMLTag element, const SUMOSAXAttributes &attrs) throw(ProcessError) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myActivePlan = new MSPerson::MSPersonPlan(); break; case SUMO_TAG_RIDE: { const std::string pid = myVehicleParameter->id; bool ok = true; MSEdge *from = 0; if (attrs.hasAttribute(SUMO_ATTR_FROM)) { const std::string fromID = attrs.getStringReporting(SUMO_ATTR_FROM, "ride", pid.c_str(), ok); from = MSEdge::dictionary(fromID); if (from==0) { throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known."); } if (myActivePlan->empty() || &myActivePlan->back()->getDestination() != from) { myActivePlan->push_back(new MSPerson::MSPersonStage_Waiting(*from, -1, myVehicleParameter->depart)); } } const std::string toID = attrs.getStringReporting(SUMO_ATTR_TO, "ride", pid.c_str(), ok); MSEdge *to = MSEdge::dictionary(toID); if (to==0) { throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known."); } const std::string desc = attrs.getStringReporting(SUMO_ATTR_LINES, "ride", pid.c_str(), ok); StringTokenizer st(desc); myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, st.getVector())); break; } case SUMO_TAG_WALK: { myActiveRoute.clear(); bool ok = true; MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_EDGES, "walk", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); if (myActiveRoute.empty()) { throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'."); } if (myActivePlan->empty() || &myActivePlan->back()->getDestination() != myActiveRoute.front()) { myActivePlan->push_back(new MSPerson::MSPersonStage_Waiting(*myActiveRoute.front(), -1, myVehicleParameter->depart)); } const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "walk", 0, ok, -1); const SUMOReal speed = attrs.getOptSUMORealReporting(SUMO_ATTR_SPEED, "walk", 0, ok, -1); myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myActiveRoute, duration, speed)); myActiveRoute.clear(); break; } case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs); if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) { myActiveRouteID = "!" + myVehicleParameter->id; bool ok = true; MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, "flow", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, "flow", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); closeRoute(); } break; case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_TRIPDEF: { bool ok = true; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myActiveRouteID = "!" + myVehicleParameter->id; if (attrs.hasAttribute(SUMO_ATTR_FROM) || !myVehicleParameter->wasSet(VEHPARS_TAZ_SET)) { MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, "tripdef", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, "tripdef", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); } else { const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz+"-source"); if (fromTaz == 0) { WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' not known for '" + myVehicleParameter->id + "'!"); } else if (fromTaz->getNoFollowing() == 0) { WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' has no outgoing edges for '" + myVehicleParameter->id + "'!"); } else { myActiveRoute.push_back(fromTaz->getFollower(0)); } } closeRoute(); closeVehicle(); } break; default: break; } // parse embedded vtype information if (myCurrentVType!=0&&element!=SUMO_TAG_VTYPE) { SUMOVehicleParserHelper::parseVTypeEmbedded(*myCurrentVType, element, attrs); return; } if (element==SUMO_TAG_STOP) { bool ok = true; SUMOVehicleParameter::Stop stop; // try to parse the assigne bus stop stop.busstop = attrs.getOptStringReporting(SUMO_ATTR_BUS_STOP, "stop", 0, ok, ""); if (stop.busstop!="") { // ok, we have obviously a bus stop MSBusStop *bs = MSNet::getInstance()->getBusStop(stop.busstop); if (bs!=0) { const MSLane &l = bs->getLane(); stop.lane = l.getID(); stop.pos = bs->getEndLanePosition(); } else { MsgHandler::getErrorInstance()->inform("The bus stop '" + stop.busstop + "' is not known."); return; } } else { // no, the lane and the position should be given // get the lane stop.lane = attrs.getOptStringReporting(SUMO_ATTR_LANE, "stop", 0, ok, ""); if (stop.lane!="") { if (MSLane::dictionary(stop.lane)==0) { MsgHandler::getErrorInstance()->inform("The lane '" + stop.lane + "' for a stop is not known."); return; } } else { MsgHandler::getErrorInstance()->inform("A stop must be placed on a bus stop or a lane."); return; } // get the position bool ok = true; stop.pos = attrs.getSUMORealReporting(SUMO_ATTR_POSITION, "stop", 0, ok); if (!ok) { return; } } // get the standing duration if (!attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL)) { MsgHandler::getErrorInstance()->inform("The duration of a stop is not defined."); return; } else { bool ok = true; stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "stop", 0, ok, -1); stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, "stop", 0, ok, -1); if (!ok) { return; } if (stop.duration<0&&stop.until<0) { MsgHandler::getErrorInstance()->inform("Neither the duration nor the end time is given for a stop."); return; } } if (myActiveRouteID != "") { myActiveRouteStops.push_back(stop); } else { myVehicleParameter->stops.push_back(stop); } } }
void MSRouteHandler::myStartElement (int element, const SUMOSAXAttributes& attrs) { if(oc.getLoadVerbosity()>1) std::cout << "----> MSRouteHandler::myStartElement" << std::endl; switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); if(oc.getLoadVerbosity()>1) std::cout << "[110] MSRouteHandler::myStartElement\n myVehiclePar" "ameter->vtypeid=" << myVehicleParameter->vtypeid << "\n myVehicleParameter->id=" << myVehicleParameter ->id << std::endl; /*TASK * This could be the first place where we can process the * electric or nonelectric characteristics of the vehicles */ if((myVehicleParameter->id.substr(0, 4)=="elec") ||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHelec")||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHElec")|| (myVehicleParameter->id.substr(0, 9)=="SHItaElec")|| (myVehicleParameter->id.substr(0, 9)=="SHGerElec")|| (myVehicleParameter->id.substr(0, 3)=="fev")) { //TASK (uprego) This should be safe, but I'm not completely sure myVehicleParameter->vtypeid = DEFAULT_ELECVTYPE_ID; // Electric cars turn green myVehicleParameter->color = HIB_CAR_COLOR_GREEN; } else if((myVehicleParameter->id.substr(0, 4)=="norm")||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHnorm")||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHItaNorm")|| (myVehicleParameter->id.substr(0, 6)=="SHGerNorm")|| (myVehicleParameter->id.substr(0, 6)=="SHNorm")) { // Normal cars remain yellow myVehicleParameter->color = HIB_CAR_COLOR_YELLOW_TRY; } else { /* BUSCARLO EN LOS VEHICLES TO TRACK LIST !!! IF ESTA // CREARLE EL VTYPEID ELSE // Default yellow myVehicleParameter->color = HIB_CAR_COLOR_YELLOW_TRY; */ myVehicleParameter->color=HIB_CAR_COLOR_YELLOW_TRY; // TASK TODO FIXME ALERT DANGER DELETEME } break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myActivePlan = new MSPerson::MSPersonPlan(); break; case SUMO_TAG_RIDE: { const std::string pid = myVehicleParameter->id; bool ok = true; MSEdge* from = 0; if (attrs.hasAttribute(SUMO_ATTR_FROM)) { const std::string fromID = attrs.getStringReporting(SUMO_ATTR_FROM, pid.c_str(), ok); from = MSEdge::dictionary(fromID); if (from == 0) { throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known."); } if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != from) { throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActivePlan->back()->getDestination().getID() + ")."); } if (myActivePlan->empty()) { myActivePlan->push_back(new MSPerson::MSPersonStage_Waiting(*from, -1, myVehicleParameter->depart)); } } const std::string toID = attrs.getStringReporting(SUMO_ATTR_TO, pid.c_str(), ok); MSEdge* to = MSEdge::dictionary(toID); if (to == 0) { throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known."); } const std::string desc = attrs.getStringReporting(SUMO_ATTR_LINES, pid.c_str(), ok); StringTokenizer st(desc); myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, st.getVector())); break; } case SUMO_TAG_WALK: { myActiveRoute.clear(); bool ok = true; MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_EDGES, myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); if (myActiveRoute.empty()) { throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'."); } if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != myActiveRoute.front()) { throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ")."); } if (myActivePlan->empty()) { myActivePlan->push_back(new MSPerson::MSPersonStage_Waiting(*myActiveRoute.front(), -1, myVehicleParameter->depart)); } const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, 0, ok, -1); const SUMOReal speed = attrs.getOptSUMORealReporting(SUMO_ATTR_SPEED, 0, ok, -1); myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myActiveRoute, duration, speed)); myActiveRoute.clear(); break; } case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs); if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) { myActiveRouteID = "!" + myVehicleParameter->id; bool ok = true; MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); closeRoute(); } break; case SUMO_TAG_VTYPE__DEPRECATED: if (!myHaveWarnedAboutDeprecatedVType) { myHaveWarnedAboutDeprecatedVType = true; WRITE_WARNING("'" + toString(SUMO_TAG_VTYPE__DEPRECATED) + "' is deprecated; please use '" + toString(SUMO_TAG_VTYPE) + "'."); } case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs); break; case SUMO_TAG_VTYPE_DISTRIBUTION__DEPRECATED: if (!myHaveWarnedAboutDeprecatedVTypeDistribution) { myHaveWarnedAboutDeprecatedVTypeDistribution = true; WRITE_WARNING("'" + toString(SUMO_TAG_VTYPE_DISTRIBUTION__DEPRECATED) + "' is deprecated; please use '" + toString(SUMO_TAG_VTYPE_DISTRIBUTION) + "'."); } case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP__DEPRECATED: case SUMO_TAG_TRIP: { bool ok = true; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myVehicleParameter->setParameter |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; if (attrs.hasAttribute(SUMO_ATTR_FROM) || !myVehicleParameter->wasSet(VEHPARS_TAZ_SET)) { MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); } else { const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz + "-source"); if (fromTaz == 0) { WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' not known for '" + myVehicleParameter->id + "'!"); } else if (fromTaz->getNoFollowing() == 0) { WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' has no outgoing edges for '" + myVehicleParameter->id + "'!"); } else { myActiveRoute.push_back(fromTaz->getFollower(0)); } } closeRoute(); closeVehicle(); } break; default: break; } // parse embedded vtype information if (myCurrentVType != 0 && element != SUMO_TAG_VTYPE && element != SUMO_TAG_VTYPE__DEPRECATED) { SUMOVehicleParserHelper::parseVTypeEmbedded(*myCurrentVType, element, attrs); return; } }
void SUMORouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, false, false, true); break; case SUMO_TAG_CONTAINER: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs, myBeginDefault, myEndDefault); break; case SUMO_TAG_VTYPE: // XXX: Where is this deleted? Delegated to subclasses?! MSRouteHandler takes care of this, in case of RORouteHandler this is not obvious. Consider introduction of a shared_ptr myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs, getFileName()); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP: { myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, true); if (myVehicleParameter->id == "") { WRITE_WARNING("Omitting trip ids is deprecated!"); myVehicleParameter->id = myIdSupplier.getNext(); } myVehicleParameter->parametersSet |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; break; } case SUMO_TAG_PERSONTRIP: case SUMO_TAG_WALK: if (attrs.hasAttribute(SUMO_ATTR_EDGES) || attrs.hasAttribute(SUMO_ATTR_ROUTE)) { addWalk(attrs); } else { addPersonTrip(attrs); } break; case SUMO_TAG_INTERVAL: { bool ok; myBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, 0, ok); myEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, 0, ok); break; } case SUMO_TAG_PARAM: addParam(attrs); break; default: // parse embedded car following model information if (myCurrentVType != 0) { WRITE_WARNING("Defining car following parameters in a nested element is deprecated in vType '" + myCurrentVType->id + "', use attributes instead!"); SUMOVehicleParserHelper::parseVTypeEmbedded(*myCurrentVType, (SumoXMLTag)element, attrs); } break; } }