void MSRouteProbe::writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime) { if (myCurrentRouteDistribution.second->getOverallProb() > 0) { dev.openTag("routeDistribution") << " id=\"" << getID() + "_" + time2string(startTime) << "\""; const std::vector<const MSRoute*>& routes = myCurrentRouteDistribution.second->getVals(); const std::vector<SUMOReal>& probs = myCurrentRouteDistribution.second->getProbs(); for (unsigned int j = 0; j < routes.size(); ++j) { const MSRoute* r = routes[j]; dev.openTag("route") << " id=\"" << r->getID() + "_" + time2string(startTime) << "\" edges=\""; for (MSRouteIterator i = r->begin(); i != r->end(); ++i) { if (i != r->begin()) { dev << " "; } dev << (*i)->getID(); } dev << "\" probability=\"" << probs[j] << "\""; dev.closeTag(); } dev.closeTag(); if (myLastRouteDistribution.second != 0) { MSRoute::checkDist(myLastRouteDistribution.first); } myLastRouteDistribution = myCurrentRouteDistribution; myCurrentRouteDistribution.first = getID() + "_" + toString(stopTime); myCurrentRouteDistribution.second = new RandomDistributor<const MSRoute*>(); MSRoute::dictionary(myCurrentRouteDistribution.first, myCurrentRouteDistribution.second, false); } }
void ROPerson::saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const { // write the person's vehicles for (std::vector<PlanItem*>::const_iterator it = myPlan.begin(); it != myPlan.end(); ++it) { (*it)->saveVehicles(os, typeos, asAlternatives, options); } if (typeos != 0 && myType != 0 && !myType->saved) { myType->write(*typeos); myType->saved = true; } if (myType != 0 && !myType->saved) { myType->write(os); myType->saved = asAlternatives; } // write the person myParameter.write(os, options, SUMO_TAG_PERSON); for (std::vector<PlanItem*>::const_iterator it = myPlan.begin(); it != myPlan.end(); ++it) { (*it)->saveAsXML(os); } for (std::map<std::string, std::string>::const_iterator j = myParameter.getMap().begin(); j != myParameter.getMap().end(); ++j) { os.openTag(SUMO_TAG_PARAM); os.writeAttr(SUMO_ATTR_KEY, (*j).first); os.writeAttr(SUMO_ATTR_VALUE, (*j).second); os.closeTag(); } os.closeTag(); }
// =========================================================================== // method definitions // =========================================================================== void MSEmissionExport::write(OutputDevice& of, SUMOTime timestep, int precision) { of.openTag("timestep").writeAttr("time", time2string(timestep)); of.setPrecision(precision); MSVehicleControl& vc = MSNet::getInstance()->getVehicleControl(); for (MSVehicleControl::constVehIt it = vc.loadedVehBegin(); it != vc.loadedVehEnd(); ++it) { const SUMOVehicle* veh = it->second; const MSVehicle* microVeh = dynamic_cast<const MSVehicle*>(veh); if (veh->isOnRoad()) { std::string fclass = veh->getVehicleType().getID(); fclass = fclass.substr(0, fclass.find_first_of("@")); PollutantsInterface::Emissions emiss = PollutantsInterface::computeAll(veh->getVehicleType().getEmissionClass(), veh->getSpeed(), veh->getAcceleration(), veh->getSlope()); of.openTag("vehicle").writeAttr("id", veh->getID()).writeAttr("eclass", PollutantsInterface::getName(veh->getVehicleType().getEmissionClass())); of.writeAttr("CO2", emiss.CO2).writeAttr("CO", emiss.CO).writeAttr("HC", emiss.HC).writeAttr("NOx", emiss.NOx); of.writeAttr("PMx", emiss.PMx).writeAttr("fuel", emiss.fuel).writeAttr("electricity", emiss.electricity); of.writeAttr("noise", HelpersHarmonoise::computeNoise(veh->getVehicleType().getEmissionClass(), veh->getSpeed(), veh->getAcceleration())); of.writeAttr("route", veh->getRoute().getID()).writeAttr("type", fclass); if (microVeh != 0) { of.writeAttr("waiting", microVeh->getWaitingSeconds()); of.writeAttr("lane", microVeh->getLane()->getID()); } of.writeAttr("pos", veh->getPositionOnLane()).writeAttr("speed", veh->getSpeed()); of.writeAttr("angle", GeomHelper::naviDegree(veh->getAngle())).writeAttr("x", veh->getPosition().x()).writeAttr("y", veh->getPosition().y()); of.closeTag(); } } of.setPrecision(OUTPUT_ACCURACY); of.closeTag(); }
void NWWriter_SUMO::writeTrafficLights(OutputDevice& into, const NBTrafficLightLogicCont& tllCont) { std::vector<NBTrafficLightLogic*> logics = tllCont.getComputed(); for (std::vector<NBTrafficLightLogic*>::iterator it = logics.begin(); it != logics.end(); it++) { into.openTag(SUMO_TAG_TLLOGIC); into.writeAttr(SUMO_ATTR_ID, (*it)->getID()); into.writeAttr(SUMO_ATTR_TYPE, (*it)->getType()); into.writeAttr(SUMO_ATTR_PROGRAMID, (*it)->getProgramID()); into.writeAttr(SUMO_ATTR_OFFSET, writeSUMOTime((*it)->getOffset())); // write params const std::map<std::string, std::string>& params = (*it)->getMap(); for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) { into.openTag(SUMO_TAG_PARAM); into.writeAttr(SUMO_ATTR_KEY, (*i).first); into.writeAttr(SUMO_ATTR_VALUE, (*i).second); into.closeTag(); } // write the phases const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = (*it)->getPhases(); for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator j = phases.begin(); j != phases.end(); ++j) { into.openTag(SUMO_TAG_PHASE); into.writeAttr(SUMO_ATTR_DURATION, writeSUMOTime(j->duration)); into.writeAttr(SUMO_ATTR_STATE, j->state); into.closeTag(); } into.closeTag(); } if (logics.size() > 0) { into.lf(); } }
void MSFullExport::writeEdge(OutputDevice& of) { of.openTag("edges") << ">\n"; MSEdgeControl& ec = MSNet::getInstance()->getEdgeControl(); const std::vector<MSEdge*>& edges = ec.getEdges(); for (std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) { MSEdge& edge = **e; of.openTag("edge") << " id=\"" << edge.getID() << "\" traveltime=\"" << edge.getCurrentTravelTime() << "\">\n"; const std::vector<MSLane*>& lanes = edge.getLanes(); for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) { writeLane(of, **lane); } of.closeTag(); } of.closeTag(); }
void NWWriter_SUMO::writeDistrict(OutputDevice& into, const NBDistrict& d) { std::vector<SUMOReal> sourceW = d.getSourceWeights(); VectorHelper<SUMOReal>::normaliseSum(sourceW, 1.0); std::vector<SUMOReal> sinkW = d.getSinkWeights(); VectorHelper<SUMOReal>::normaliseSum(sinkW, 1.0); // write the head and the id of the district into.openTag(SUMO_TAG_TAZ).writeAttr(SUMO_ATTR_ID, d.getID()); if (d.getShape().size() > 0) { into.writeAttr(SUMO_ATTR_SHAPE, d.getShape()); } size_t i; // write all sources const std::vector<NBEdge*>& sources = d.getSourceEdges(); for (i = 0; i < sources.size(); i++) { // write the head and the id of the source into.openTag(SUMO_TAG_TAZSOURCE).writeAttr(SUMO_ATTR_ID, sources[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sourceW[i]); into.closeTag(); } // write all sinks const std::vector<NBEdge*>& sinks = d.getSinkEdges(); for (i = 0; i < sinks.size(); i++) { // write the head and the id of the sink into.openTag(SUMO_TAG_TAZSINK).writeAttr(SUMO_ATTR_ID, sinks[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sinkW[i]); into.closeTag(); } // write the tail into.closeTag(); }
void MSFullExport::writeTLS(OutputDevice& of, SUMOTime /* timestep */) { of.openTag("tls") << ">\n"; MSTLLogicControl& vc = MSNet::getInstance()->getTLSControl(); std::vector<std::string> ids = vc.getAllTLIds(); for (std::vector<std::string>::const_iterator id_it = ids.begin(); id_it != ids.end(); ++id_it) { MSTLLogicControl::TLSLogicVariants& vars = MSNet::getInstance()->getTLSControl().get(*id_it); const MSTrafficLightLogic::LaneVectorVector& lanes = vars.getActive()->getLanes(); std::vector<std::string> laneIDs; for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) { const MSTrafficLightLogic::LaneVector& llanes = (*i); for (MSTrafficLightLogic::LaneVector::const_iterator j = llanes.begin(); j != llanes.end(); ++j) { laneIDs.push_back((*j)->getID()); } } std::string lane_output = ""; for (unsigned int i1 = 0; i1 < laneIDs.size(); ++i1) { lane_output += laneIDs[i1] + " "; } std::string state = vars.getActive()->getCurrentPhaseDef().getState(); of.openTag("trafficlight") << " id=\"" << *id_it << "\" state=\"" << state << "\""; of.closeTag(); } of.closeTag(); }
void MESegment::saveState(OutputDevice& out) { out.openTag(SUMO_TAG_SEGMENT); for (size_t i = 0; i < myCarQues.size(); ++i) { out.openTag(SUMO_TAG_VIEWSETTINGS_VEHICLES).writeAttr(SUMO_ATTR_TIME, toString<SUMOTime>(myBlockTimes[i])); out.writeAttr(SUMO_ATTR_VALUE, myCarQues[i]); out.closeTag(); } out.closeTag(); }
void NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& eID, const std::string& lID, SUMOReal speed, SVCPermissions permissions, SVCPermissions preferred, SUMOReal endOffset, SUMOReal width, PositionVector shape, const std::string& origID, SUMOReal length, unsigned int index, bool origNames, const NBNode* node) { // output the lane's attributes into.openTag(SUMO_TAG_LANE).writeAttr(SUMO_ATTR_ID, lID); // the first lane of an edge will be the depart lane into.writeAttr(SUMO_ATTR_INDEX, index); // write the list of allowed/disallowed vehicle classes if (permissions != SVC_UNSPECIFIED) { writePermissions(into, permissions); } writePreferences(into, preferred); // some further information if (speed == 0) { WRITE_WARNING("Lane #" + toString(index) + " of edge '" + eID + "' has a maximum velocity of 0."); } else if (speed < 0) { throw ProcessError("Negative velocity (" + toString(speed) + " on edge '" + eID + "' lane#" + toString(index) + "."); } if (endOffset > 0) { length = length - endOffset; } into.writeAttr(SUMO_ATTR_SPEED, speed); into.writeAttr(SUMO_ATTR_LENGTH, length); if (endOffset != NBEdge::UNSPECIFIED_OFFSET) { into.writeAttr(SUMO_ATTR_ENDOFFSET, endOffset); } if (width != NBEdge::UNSPECIFIED_WIDTH) { into.writeAttr(SUMO_ATTR_WIDTH, width); } if (node != 0) { const NBNode::CustomShapeMap& cs = node->getCustomLaneShapes(); NBNode::CustomShapeMap::const_iterator it = cs.find(lID); if (it != cs.end()) { shape = it->second; into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true); } } into.writeAttr(SUMO_ATTR_SHAPE, endOffset > 0 ? shape.getSubpart(0, shape.length() - endOffset) : shape); if (origNames && origID != "") { into.openTag(SUMO_TAG_PARAM); into.writeAttr(SUMO_ATTR_KEY, "origId"); into.writeAttr(SUMO_ATTR_VALUE, origID); into.closeTag(); into.closeTag(); } else { into.closeTag(); } }
void NWWriter_SUMO::writeJunction(OutputDevice& into, const NBNode& n) { // write the attributes into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, n.getID()); into.writeAttr(SUMO_ATTR_TYPE, n.getType()); NWFrame::writePositionLong(n.getPosition(), into); // write the incoming lanes std::string incLanes; const std::vector<NBEdge*>& incoming = n.getIncomingEdges(); for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) { unsigned int noLanes = (*i)->getNumLanes(); for (unsigned int j = 0; j < noLanes; j++) { incLanes += (*i)->getLaneID(j); if (i != incoming.end() - 1 || j < noLanes - 1) { incLanes += ' '; } } } into.writeAttr(SUMO_ATTR_INCLANES, incLanes); // write the internal lanes std::string intLanes; if (!OptionsCont::getOptions().getBool("no-internal-links")) { unsigned int l = 0; for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) { const std::vector<NBEdge::Connection>& elv = (*i)->getConnections(); for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) { if ((*k).toEdge == 0) { continue; } if (l != 0) { intLanes += ' '; } if (!(*k).haveVia) { intLanes += (*k).id + "_0"; } else { intLanes += (*k).viaID + "_0"; } l++; } } } into.writeAttr(SUMO_ATTR_INTLANES, intLanes); // close writing into.writeAttr(SUMO_ATTR_SHAPE, n.getShape()); if (n.getType() == NODETYPE_DEAD_END) { into.closeTag(); } else { // write right-of-way logics n.writeLogic(into); into.closeTag(); } }
void MSMeanData_Net::MSLaneMeanDataValues::write(OutputDevice& dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal defaultTravelTime, const int numVehicles) const { if (myParent == 0) { if (sampleSeconds > 0) { dev << "\" density=\"" << sampleSeconds / STEPS2TIME(period) *(SUMOReal) 1000 / myLaneLength << "\" occupancy=\"" << vehLengthSum / STEPS2TIME(period) / myLaneLength / numLanes *(SUMOReal) 100 << "\" waitingTime=\"" << waitSeconds << "\" speed=\"" << travelledDistance / sampleSeconds; } dev << "\" departed=\"" << nVehDeparted << "\" arrived=\"" << nVehArrived << "\" entered=\"" << nVehEntered << "\" left=\"" << nVehLeft << "\""; if (nVehVaporized > 0) { dev << " vaporized=\"" << nVehVaporized << "\""; } dev.closeTag(); return; } if (sampleSeconds > myParent->myMinSamples) { SUMOReal traveltime = myParent->myMaxTravelTime; if (travelledDistance > 0.f) { traveltime = MIN2(traveltime, myLaneLength * sampleSeconds / travelledDistance); } if (numVehicles > 0) { dev << "\" traveltime=\"" << sampleSeconds / numVehicles << "\" waitingTime=\"" << waitSeconds << "\" speed=\"" << travelledDistance / sampleSeconds; } else { dev << "\" traveltime=\"" << traveltime << "\" density=\"" << sampleSeconds / STEPS2TIME(period) *(SUMOReal) 1000 / myLaneLength << "\" occupancy=\"" << vehLengthSum / STEPS2TIME(period) / myLaneLength / numLanes *(SUMOReal) 100 << "\" waitingTime=\"" << waitSeconds << "\" speed=\"" << travelledDistance / sampleSeconds; } } else if (defaultTravelTime >= 0.) { dev << "\" traveltime=\"" << defaultTravelTime << "\" speed=\"" << myLaneLength / defaultTravelTime; } dev << "\" departed=\"" << nVehDeparted << "\" arrived=\"" << nVehArrived << "\" entered=\"" << nVehEntered << "\" left=\"" << nVehLeft << "\" laneChangedFrom=\"" << nVehLaneChangeFrom << "\" laneChangedTo=\"" << nVehLaneChangeTo << "\""; if (nVehVaporized > 0) { dev << " vaporized=\"" << nVehVaporized << "\""; } dev.closeTag(); }
void NWWriter_SUMO::writeRoundabout(OutputDevice& into, const std::vector<std::string>& edgeIDs, const NBEdgeCont& ec) { std::vector<std::string> validEdgeIDs; std::vector<std::string> invalidEdgeIDs; std::vector<std::string> nodeIDs; for (std::vector<std::string>::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) { const NBEdge* edge = ec.retrieve(*i); if (edge != 0) { nodeIDs.push_back(edge->getToNode()->getID()); validEdgeIDs.push_back(edge->getID()); } else { invalidEdgeIDs.push_back(*i); } } std::sort(nodeIDs.begin(), nodeIDs.end()); if (validEdgeIDs.size() > 0) { into.openTag(SUMO_TAG_ROUNDABOUT); into.writeAttr(SUMO_ATTR_NODES, joinToString(nodeIDs, " ")); into.writeAttr(SUMO_ATTR_EDGES, joinToString(validEdgeIDs, " ")); into.closeTag(); if (invalidEdgeIDs.size() > 0) { WRITE_WARNING("Writing incomplete roundabout. Edges: '" + joinToString(invalidEdgeIDs, " ") + "' no longer exist'"); } } }
void NWWriter_SUMO::writeConnection(OutputDevice& into, const NBEdge& from, const NBEdge::Connection& c, bool includeInternal, ConnectionStyle style) { assert(c.toEdge != 0); into.openTag(SUMO_TAG_CONNECTION); into.writeAttr(SUMO_ATTR_FROM, from.getID()); into.writeAttr(SUMO_ATTR_TO, c.toEdge->getID()); into.writeAttr(SUMO_ATTR_FROM_LANE, c.fromLane); into.writeAttr(SUMO_ATTR_TO_LANE, c.toLane); if (c.mayDefinitelyPass) { into.writeAttr(SUMO_ATTR_PASS, c.mayDefinitelyPass); } if (style != PLAIN) { if (includeInternal) { into.writeAttr(SUMO_ATTR_VIA, c.id + "_0"); } // set information about the controlling tl if any if (c.tlID != "") { into.writeAttr(SUMO_ATTR_TLID, c.tlID); into.writeAttr(SUMO_ATTR_TLLINKINDEX, c.tlLinkNo); } if (style == SUMONET) { // write the direction information LinkDirection dir = from.getToNode()->getDirection(&from, c.toEdge); assert(dir != LINKDIR_NODIR); into.writeAttr(SUMO_ATTR_DIR, toString(dir)); // write the state information const LinkState linkState = from.getToNode()->getLinkState( &from, c.toEdge, c.toLane, c.mayDefinitelyPass, c.tlID); into.writeAttr(SUMO_ATTR_STATE, linkState); } } into.closeTag(); }
bool NWWriter_SUMO::writeInternalNodes(OutputDevice& into, const NBNode& n) { bool ret = false; const std::vector<NBEdge*>& incoming = n.getIncomingEdges(); for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); i++) { const std::vector<NBEdge::Connection>& elv = (*i)->getConnections(); for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) { if ((*k).toEdge == 0 || !(*k).haveVia) { continue; } Position pos = (*k).shape[-1]; into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, (*k).viaID + "_0"); into.writeAttr(SUMO_ATTR_TYPE, NODETYPE_INTERNAL); NWFrame::writePositionLong(pos, into); std::string incLanes = (*k).id + "_0"; if ((*k).foeIncomingLanes.length() != 0) { incLanes += " " + (*k).foeIncomingLanes; } into.writeAttr(SUMO_ATTR_INCLANES, incLanes); into.writeAttr(SUMO_ATTR_INTLANES, (*k).foeInternalLanes); into.closeTag(); ret = true; } } return ret; }
void ODMatrix::writeFlows(const SUMOTime begin, const SUMOTime end, OutputDevice& dev, bool noVtype, const std::string& prefix, bool asProbability) { if (myContainer.size() == 0) { return; } int flowName = 0; sortByBeginTime(); // recheck begin time for (std::vector<ODCell*>::const_iterator i = myContainer.begin(); i != myContainer.end(); ++i) { const ODCell* const c = *i; if (c->end > begin && c->begin < end) { dev.openTag(SUMO_TAG_FLOW).writeAttr(SUMO_ATTR_ID, prefix + toString(flowName++)); dev.writeAttr(SUMO_ATTR_BEGIN, time2string(c->begin)); dev.writeAttr(SUMO_ATTR_END, time2string(c->end)); if (!asProbability) { dev.writeAttr(SUMO_ATTR_NUMBER, int(c->vehicleNumber)); } else { const double probability = float(c->vehicleNumber) / STEPS2TIME(c->end - c->begin); if (probability > 1) { WRITE_WARNING("Flow density of " + toString(probability) + " vehicles per second, cannot be represented with a simple probability. Falling back to even spacing."); dev.writeAttr(SUMO_ATTR_NUMBER, int(c->vehicleNumber)); } else { dev.setPrecision(6); dev.writeAttr(SUMO_ATTR_PROB, probability); dev.setPrecision(); } } writeDefaultAttrs(dev, noVtype, *i); dev.closeTag(); } } }
bool RODFRouteCont::save(std::vector<std::string>& saved, const std::string& prependix, OutputDevice& out) { bool haveSavedOneAtLeast = false; for (std::vector<RODFRouteDesc>::const_iterator j = myRoutes.begin(); j != myRoutes.end(); ++j) { const RODFRouteDesc& desc = (*j); if (find(saved.begin(), saved.end(), desc.routename) != saved.end()) { continue; } saved.push_back((*j).routename); assert(desc.edges2Pass.size() >= 1); out.openTag(SUMO_TAG_ROUTE).writeAttr(SUMO_ATTR_ID, prependix + desc.routename); out << " edges=\""; for (std::vector<ROEdge*>::const_iterator k = desc.edges2Pass.begin(); k != desc.edges2Pass.end(); k++) { if (k != desc.edges2Pass.begin()) { out << ' '; } out << (*k)->getID(); } out << '"'; out.closeTag(true); haveSavedOneAtLeast = true; } return haveSavedOneAtLeast; }
void ROPerson::Ride::saveAsXML(OutputDevice& os, const bool extended) const { os.openTag(SUMO_TAG_RIDE); std::string comment = ""; if (extended && cost >= 0.) { os.writeAttr(SUMO_ATTR_COST, cost); } if (from != nullptr) { os.writeAttr(SUMO_ATTR_FROM, from->getID()); } if (to != nullptr) { os.writeAttr(SUMO_ATTR_TO, to->getID()); } if (destStop != "") { os.writeAttr(SUMO_ATTR_BUS_STOP, destStop); const std::string name = RONet::getInstance()->getStoppingPlaceName(destStop); if (name != "") { comment = " <!-- " + name + " -->"; } } os.writeAttr(SUMO_ATTR_LINES, lines); if (intended != "" && intended != lines) { os.writeAttr(SUMO_ATTR_INTENDED, intended); } if (depart >= 0) { os.writeAttr(SUMO_ATTR_DEPART, time2string(depart)); } os.closeTag(comment); }
void ROPerson::saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const { // write the person's vehicles for (std::vector<PlanItem*>::const_iterator it = myPlan.begin(); it != myPlan.end(); ++it) { (*it)->saveVehicles(os, typeos, asAlternatives, options); } if (typeos != nullptr && getType() != nullptr && !getType()->saved) { getType()->write(*typeos); getType()->saved = true; } if (getType() != nullptr && !getType()->saved) { getType()->write(os); getType()->saved = asAlternatives; } // write the person getParameter().write(os, options, SUMO_TAG_PERSON); for (std::vector<PlanItem*>::const_iterator it = myPlan.begin(); it != myPlan.end(); ++it) { (*it)->saveAsXML(os, asAlternatives); } // write params getParameter().writeParams(os); os.closeTag(); }
void ROPerson::Walk::saveAsXML(OutputDevice& os, const bool extended) const { os.openTag(SUMO_TAG_WALK); std::string comment = ""; if (extended && cost >= 0.) { os.writeAttr(SUMO_ATTR_COST, cost); } if (dur > 0) { os.writeAttr(SUMO_ATTR_DURATION, dur); } if (v > 0) { os.writeAttr(SUMO_ATTR_SPEED, v); } os.writeAttr(SUMO_ATTR_EDGES, edges); if (dep != 0.) { os.writeAttr(SUMO_ATTR_DEPARTPOS, dep); } if (arr != 0. && destStop == "") { os.writeAttr(SUMO_ATTR_ARRIVALPOS, arr); } if (destStop != "") { os.writeAttr(SUMO_ATTR_BUS_STOP, destStop); const std::string name = RONet::getInstance()->getStoppingPlaceName(destStop); if (name != "") { comment = " <!-- " + name + " -->"; } } os.closeTag(comment); }
void MSXMLRawOut::writeVehicle(OutputDevice& of, const MSBaseVehicle& veh) { if (veh.isOnRoad()) { of.openTag("vehicle") << " id=\"" << veh.getID() << "\" pos=\"" << veh.getPositionOnLane() << "\" speed=\"" << veh.getSpeed() << "\""; of.closeTag(); } }
void MSContainer::tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const { os.openTag("containerinfo").writeAttr("id", getID()).writeAttr("depart", time2string(getDesiredDepart())); for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) { (*i)->tripInfoOutput(os, transportable); } os.closeTag(); }
void NBTypeCont::writeTypes(OutputDevice& into) const { for (TypesCont::const_iterator i = myTypes.begin(); i != myTypes.end(); ++i) { into.openTag(SUMO_TAG_TYPE); into.writeAttr(SUMO_ATTR_ID, i->first); const NBTypeCont::TypeDefinition& type = i->second; if (type.attrs.count(SUMO_ATTR_PRIORITY) > 0) { into.writeAttr(SUMO_ATTR_PRIORITY, type.priority); } if (type.attrs.count(SUMO_ATTR_NUMLANES) > 0) { into.writeAttr(SUMO_ATTR_NUMLANES, type.numLanes); } if (type.attrs.count(SUMO_ATTR_SPEED) > 0) { into.writeAttr(SUMO_ATTR_SPEED, type.speed); } if (type.attrs.count(SUMO_ATTR_DISALLOW) > 0 || type.attrs.count(SUMO_ATTR_ALLOW) > 0) { writePermissions(into, type.permissions); } if (type.attrs.count(SUMO_ATTR_ONEWAY) > 0) { into.writeAttr(SUMO_ATTR_ONEWAY, type.oneWay); } if (type.attrs.count(SUMO_ATTR_DISCARD) > 0) { into.writeAttr(SUMO_ATTR_DISCARD, type.discard); } if (type.attrs.count(SUMO_ATTR_WIDTH) > 0) { into.writeAttr(SUMO_ATTR_WIDTH, type.width); } if (type.attrs.count(SUMO_ATTR_SIDEWALKWIDTH) > 0) { into.writeAttr(SUMO_ATTR_SIDEWALKWIDTH, type.sidewalkWidth); } if (type.attrs.count(SUMO_ATTR_BIKELANEWIDTH) > 0) { into.writeAttr(SUMO_ATTR_BIKELANEWIDTH, type.bikeLaneWidth); } for (std::map<SUMOVehicleClass, SUMOReal>::const_iterator j = type.restrictions.begin(); j != type.restrictions.end(); ++j) { into.openTag(SUMO_TAG_RESTRICTION); into.writeAttr(SUMO_ATTR_VCLASS, getVehicleClassNames(j->first)); into.writeAttr(SUMO_ATTR_SPEED, j->second); into.closeTag(); } into.closeTag(); } if (!myTypes.empty()) { into.lf(); } }
void NBPTLine::write(OutputDevice& device, NBEdgeCont& ec) { device.openTag(SUMO_TAG_PT_LINE); device.writeAttr(SUMO_ATTR_ID, myPTLineId); if (!myName.empty()) { device.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(myName)); } device.writeAttr(SUMO_ATTR_LINE, StringUtils::escapeXML(myRef)); device.writeAttr(SUMO_ATTR_TYPE, myType); if (myInterval > 0) { // write seconds device.writeAttr(SUMO_ATTR_PERIOD, 60 * myInterval); } if (myNightService != "") { device.writeAttr("nightService", myNightService); } device.writeAttr("completeness", toString((double)myPTStops.size() / (double)myNumOfStops)); std::vector<std::string> validEdgeIDs; // filter out edges that have been removed due to joining junctions // (therest of the route is valid) for (NBEdge* e : myRoute) { if (ec.retrieve(e->getID())) { validEdgeIDs.push_back(e->getID()); } } if (!myRoute.empty()) { device.openTag(SUMO_TAG_ROUTE); device.writeAttr(SUMO_ATTR_EDGES, validEdgeIDs); device.closeTag(); } for (auto& myPTStop : myPTStops) { device.openTag(SUMO_TAG_BUS_STOP); device.writeAttr(SUMO_ATTR_ID, myPTStop->getID()); device.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(myPTStop->getName())); device.closeTag(); } // device.writeAttr(SUMO_ATTR_LANE, myLaneId); // device.writeAttr(SUMO_ATTR_STARTPOS, myStartPos); // device.writeAttr(SUMO_ATTR_ENDPOS, myEndPos); // device.writeAttr(SUMO_ATTR_FRIENDLY_POS, "true"); device.closeTag(); }
void GNEDetectorEntry::writeAdditional(OutputDevice& device, const std::string &) { // Write parameters device.openTag(getTag()); device.writeAttr(SUMO_ATTR_LANE, myLane->getID()); device.writeAttr(SUMO_ATTR_POSITION, myPosition.x()); // Close tag device.closeTag(); }
// =========================================================================== // method definitions // =========================================================================== void MSQueueExport::write(OutputDevice& of, SUMOTime timestep) { of.openTag("data") << " timestep=\"" << time2string(timestep) << "\">\n"; writeEdge(of); of.closeTag(); }
void MSFullExport::writeLane(OutputDevice& of, const MSLane& lane) { of.openTag("lane").writeAttr("id", lane.getID()).writeAttr("CO", lane.getCOEmissions()).writeAttr("CO2", lane.getCO2Emissions()); of.writeAttr("NOx", lane.getNOxEmissions()).writeAttr("PMx", lane.getPMxEmissions()).writeAttr("HC", lane.getHCEmissions()); of.writeAttr("noise", lane.getHarmonoise_NoiseEmissions()).writeAttr("fuel", lane.getFuelConsumption()).writeAttr("maxspeed", lane.getSpeedLimit()); of.writeAttr("meanspeed", lane.getMeanSpeed() * 3.6).writeAttr("occupancy", lane.getNettoOccupancy()).writeAttr("vehicle_count", lane.getVehicleNumber()); of.closeTag(); }
void GNEVariableSpeedSignal::writeAdditional(OutputDevice& device, const std::string& currentDirectory) { // Write parameters device.openTag(getTag()); device.writeAttr(SUMO_ATTR_ID, getID()); device.writeAttr(SUMO_ATTR_LANES, joinToString(getLaneChildIds(), " ").c_str()); device.writeAttr(SUMO_ATTR_X, myPosition.x()); device.writeAttr(SUMO_ATTR_Y, myPosition.y()); // If filenam isn't empty and save in filename is enabled, save in a different file. In other case, save in the same additional XML if (!myFilename.empty() && mySaveInFilename == true) { // Write filename attribute device.writeAttr(SUMO_ATTR_FILE, myFilename); // Save values in a different file OutputDevice& deviceVSS = OutputDevice::getDevice(currentDirectory + myFilename); deviceVSS.openTag("VSS"); for (std::map<SUMOReal, SUMOReal>::const_iterator i = myVSSValues.begin(); i != myVSSValues.end(); ++i) { // Open VSS tag deviceVSS.openTag(SUMO_TAG_STEP); // Write TimeSTep deviceVSS.writeAttr(SUMO_ATTR_TIME, i->first); // Write speed deviceVSS.writeAttr(SUMO_ATTR_SPEED, i->second); // Close VSS tag deviceVSS.closeTag(); } deviceVSS.close(); } else { for (std::map<SUMOReal, SUMOReal>::const_iterator i = myVSSValues.begin(); i != myVSSValues.end(); ++i) { // Open VSS tag device.openTag(SUMO_TAG_STEP); // Write TimeSTep device.writeAttr(SUMO_ATTR_TIME, i->first); // Write speed device.writeAttr(SUMO_ATTR_SPEED, i->second); // Close VSS tag device.closeTag(); } } if (myBlocked) { device.writeAttr(GNE_ATTR_BLOCK_MOVEMENT, myBlocked); } // Close tag device.closeTag(); }
void MSInductLoop::writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime) throw(IOError) { SUMOReal t(STEPS2TIME(stopTime-startTime)); unsigned nVehCrossed ; SUMOReal flow ; SUMOReal occupancy = 0; SUMOReal meanLength, meanSpeed; dev.openTag("interval"); dev <<" begin=\""<<time2string(startTime)<<"\" end=\""<< time2string(stopTime)<<"\" \n"; unsigned totVeh = 0; for(unsigned stripIndex=0;stripIndex<myStripCount;stripIndex++){ int no_vehicles = myVehicleDataCont[stripIndex].size(); nVehCrossed = (unsigned) no_vehicles; flow = ((SUMOReal) no_vehicles / (SUMOReal) t) * (SUMOReal) 3600.0; for (std::deque< VehicleData >::const_iterator i=myVehicleDataCont[stripIndex].begin(); i!=myVehicleDataCont[stripIndex].end(); ++i) { SUMOReal timeOnDetDuringInterval = (*i).leaveTimeM - MAX2(STEPS2TIME(startTime), (*i).entryTimeM); timeOnDetDuringInterval = MIN2(timeOnDetDuringInterval, t); occupancy += timeOnDetDuringInterval; } for (std::map< MSVehicle*, SUMOReal >::const_iterator i=myVehiclesOnDet[stripIndex].begin(); i!=myVehiclesOnDet[stripIndex].end(); ++i) { SUMOReal timeOnDetDuringInterval = STEPS2TIME(stopTime) - MAX2(STEPS2TIME(startTime), (*i).second); occupancy += timeOnDetDuringInterval; } occupancy = no_vehicles!=0 ? occupancy / t * (SUMOReal) 100.0 : 0; meanSpeed = no_vehicles!=0 ? accumulate(myVehicleDataCont[stripIndex].begin(), myVehicleDataCont[stripIndex].end(), (SUMOReal) 0.0, speedSum) / (SUMOReal) myVehicleDataCont[stripIndex].size() : -1; meanLength = no_vehicles!=0 ? accumulate(myVehicleDataCont[stripIndex].begin(), myVehicleDataCont[stripIndex].end(), (SUMOReal) 0.0, lengthSum) / (SUMOReal) myVehicleDataCont[stripIndex].size() : -1; if(no_vehicles >= 1){ dev <<"\tstripNum=\""<<stripIndex<<" \"vehicle_id=\""<< (myVehicleDataCont[stripIndex].begin())->idM <<"\" flow=\""<<flow<< "\" occupancy=\""<<occupancy<<"\" speed=\""<<meanSpeed<< "\" length=\""<<meanLength<< "\" nVehEntered=\""<<no_vehicles<<"\" \n"; totVeh += no_vehicles; } else { dev << "\tstripNum=\""<<stripIndex <<"\" flow=\""<<flow<< "\" occupancy=\""<<occupancy<<"\" speed=\""<<meanSpeed<< "\" length=\""<<meanLength<< "\" nVehEntered=\""<<no_vehicles<<"\" \n"; totVeh += no_vehicles; } } dev << "total_Vehicles=\" "<<totVeh + myDismissedVehicleNumber <<"\""; dev.closeTag(true); reset(); }
void MSPerson::MSPersonStage_Walking::routeOutput(OutputDevice& os) const { os.openTag("walk").writeAttr(SUMO_ATTR_EDGES, myRoute); if (myWalkingTime > 0) { os.writeAttr(SUMO_ATTR_DURATION, time2string(myWalkingTime)); } else if (mySpeed > 0) { os.writeAttr(SUMO_ATTR_SPEED, mySpeed); } os.closeTag(); }
void MSMeanData_Amitran::MSLaneMeanDataValues::write(OutputDevice& dev, const SUMOTime /* period */, const SUMOReal /* numLanes */, const SUMOReal defaultTravelTime, const int /* numVehicles */) const { if (sampleSeconds > 0) { dev.writeAttr("amount", amount).writeAttr("averageSpeed", int(100 * travelledDistance / sampleSeconds)); } else if (defaultTravelTime >= 0.) { dev.writeAttr("amount", amount).writeAttr("averageSpeed", int(100 * myLaneLength / defaultTravelTime)); } else { dev.writeAttr("amount", amount).writeAttr("averageSpeed", "-1"); } if (myVehicleTypes != 0 && !myVehicleTypes->empty()) { for (std::map<const MSVehicleType*, unsigned>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) { dev.openTag("actorConfig").writeAttr(SUMO_ATTR_ID, it->first->getNumericalID()); dev.writeAttr("amount", it->second).writeAttr("averageSpeed", int(100 * typedTravelDistance.find(it->first)->second / typedSamples.find(it->first)->second)); dev.closeTag(); } } dev.closeTag(); }