void MSLaneSpeedTrigger::myStartElement(int element, const SUMOSAXAttributes& attrs) { // check whether the correct tag is read if (element != SUMO_TAG_STEP) { return; } // extract the values bool ok = true; SUMOTime next = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME, getID().c_str(), ok); SUMOReal speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, getID().c_str(), ok, -1); // check the values if (next < 0) { WRITE_ERROR("Wrong time in vss '" + getID() + "'."); return; } if (speed < 0) { speed = myDefaultSpeed; } // set the values for the next step if they are valid if (myLoadedSpeeds.size() != 0 && myLoadedSpeeds.back().first == next) { WRITE_WARNING("Time " + time2string(next) + " was set twice for vss '" + getID() + "'; replacing first entry."); myLoadedSpeeds.back().second = speed; } else { myLoadedSpeeds.push_back(std::make_pair(next, speed)); } }
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 GeoConvHelper::x2cartesian_const(Position& from) const { double x = from.x() * myGeoScale; double y = from.y() * myGeoScale; if (myProjectionMethod == NONE) { from.add(myOffset); } else if (myUseInverseProjection) { cartesian2geo(from); } else { if (x > 180.1 || x < -180.1) { WRITE_WARNING("Invalid longitude " + toString(x)); return false; } if (y > 90.1 || y < -90.1) { WRITE_WARNING("Invalid latitude " + toString(y)); return false; } #ifdef HAVE_PROJ if (myProjection != 0) { projUV p; p.u = x * DEG_TO_RAD; p.v = y * DEG_TO_RAD; p = pj_fwd(p, myProjection); //!!! check pj_errno x = p.u; y = p.v; } #endif if (myProjectionMethod == SIMPLE) { double ys = y; x *= 111320. * cos(DEG2RAD(ys)); y *= 111136.; from.set((SUMOReal)x, (SUMOReal)y); //!!! recheck whether the axes are mirrored from.add(myOffset); } } if (x > std::numeric_limits<double>::max() || y > std::numeric_limits<double>::max()) { return false; } if (myProjectionMethod != SIMPLE) { from.set((SUMOReal)x, (SUMOReal)y); from.add(myOffset); } return true; }
bool NWFrame::checkOptions() { OptionsCont& oc = OptionsCont::getOptions(); bool ok = true; // check whether the output is valid and can be build if (!oc.isSet("output-file") && !oc.isSet("plain-output-prefix") && !oc.isSet("amitran-output") && !oc.isSet("matsim-output") && !oc.isSet("opendrive-output") && !oc.isSet("dlr-navteq-output")) { std::string net = "net.net.xml"; if (oc.isSet("configuration-file")) { net = FileHelpers::getConfigurationRelative(oc.getString("configuration-file"), net); } oc.setDefault("output-file", net); } // some outputs need internal lanes if (oc.isSet("opendrive-output") && oc.getBool("no-internal-links")) { WRITE_ERROR("OpenDRIVE export needs internal links computation."); ok = false; } if (oc.isSet("opendrive-output") && oc.isDefault("no-internal-links")) { oc.set("no-internal-links", "false"); } if (oc.isSet("opendrive-output") && oc.isDefault("rectangular-lane-cut")) { oc.set("rectangular-lane-cut", "true"); } if (oc.isSet("opendrive-output") && !oc.getBool("rectangular-lane-cut")) { WRITE_WARNING("OpenDRIVE cannot represent oblique lane cuts and should use option 'rectangular-lane-cut'."); } if (oc.isSet("dlr-navteq-output") && oc.isDefault("numerical-ids")) { oc.set("numerical-ids", "true"); } if (oc.isSet("dlr-navteq-output") && oc.isDefault("osm.all-attributes")) { oc.set("osm.all-attributes", "true"); } if (oc.exists("ptline-output") && oc.isSet("ptline-output") && !oc.isSet("ptstop-output")) { WRITE_ERROR("public transport lines output requires 'ptstop-output' to be set"); ok = false; } if (oc.exists("ptline-clean-up") && oc.getBool("ptline-clean-up") && !oc.isSet("ptline-output")) { WRITE_WARNING("'ptline-clean-up' only works in conjunction with 'ptline-output'. Ignoring invalid option."); } return ok; }
void NWWriter_DlrNavteq::writeNodesUnsplitted(const OptionsCont& oc, NBNodeCont& nc, NBEdgeCont& ec) { // For "real" nodes we simply use the node id. // For internal nodes (geometry vectors describing edge geometry in the parlance of this format) // we use the id of the edge and do not bother with // compression (each direction gets its own internal node). // XXX add option for generating numerical ids in case the input network has string ids and the target process needs integers OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_nodes_unsplitted.txt"); writeHeader(device, oc); const GeoConvHelper& gch = GeoConvHelper::getFinal(); const bool haveGeo = gch.usingGeoProjection(); const SUMOReal geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE device.setPrecision(0); if (!haveGeo) { WRITE_WARNING("DlrNavteq node data will be written in (floating point) cartesian coordinates"); } // write format specifier device << "# NODE_ID\tIS_BETWEEN_NODE\tamount_of_geocoordinates\tx1\ty1\t[x2 y2 ... xn yn]\n"; // write normal nodes for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) { NBNode* n = (*i).second; Position pos = n->getPosition(); gch.cartesian2geo(pos); pos.mul(geoScale); device << n->getID() << "\t0\t1\t" << pos.x() << "\t" << pos.y() << "\n"; } // write "internal" nodes for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) { NBEdge* e = (*i).second; const PositionVector& geom = e->getGeometry(); if (geom.size() > 2) { if (e->getID() == UNDEFINED) { WRITE_WARNING("Edge id '" + UNDEFINED + "' clashes with the magic value for NO_BETWEEN_NODE. Internal geometry for this edge will be lost."); } device << e->getID() << "\t1\t" << geom.size() - 2; for (size_t ii = 1; ii < geom.size() - 1; ++ii) { Position pos = geom[(int)ii]; gch.cartesian2geo(pos); pos.mul(geoScale); device << "\t" << pos.x() << "\t" << pos.y(); } device << "\n"; } } device.close(); }
void RORouteHandler::openRoute(const SUMOSAXAttributes& attrs) { // check whether the id is really necessary std::string rid; if (myCurrentAlternatives != 0) { myActiveRouteID = myCurrentAlternatives->getID(); rid = "distribution '" + myCurrentAlternatives->getID() + "'"; } else if (myVehicleParameter != 0) { // ok, a vehicle is wrapping the route, // we may use this vehicle's id as default myVehicleParameter->routeid = myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this if (attrs.hasAttribute(SUMO_ATTR_ID)) { WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "')."); } } else { bool ok = true; myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { return; } rid = "'" + myActiveRouteID + "'"; } if (myVehicleParameter != 0) { // have to do this here for nested route distributions rid = "for vehicle '" + myVehicleParameter->id + "'"; } bool ok = true; if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid); } myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, ""); if (myActiveRouteRefID != "" && myNet.getRouteDef(myActiveRouteRefID) == 0) { myErrorOutput->inform("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + "."); } if (myCurrentAlternatives != 0 && !attrs.hasAttribute(SUMO_ATTR_PROB)) { WRITE_WARNING("No probability for a route in '" + rid + "', using default."); } myActiveRouteProbability = attrs.getOpt<SUMOReal>(SUMO_ATTR_PROB, myActiveRouteID.c_str(), ok, DEFAULT_VEH_PROB); if (ok && myActiveRouteProbability < 0) { myErrorOutput->inform("Invalid probability for route '" + myActiveRouteID + "'."); } myActiveRouteColor = attrs.hasAttribute(SUMO_ATTR_COLOR) ? new RGBColor(attrs.get<RGBColor>(SUMO_ATTR_COLOR, myActiveRouteID.c_str(), ok)) : 0; ok = true; myCurrentCosts = attrs.getOpt<SUMOReal>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1); if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) { myErrorOutput->inform("Invalid cost for route '" + myActiveRouteID + "'."); } }
// =========================================================================== // method definitions // =========================================================================== TraCIServer::TraCIServer(const SUMOTime begin, const int port) : mySocket(0), myTargetTime(begin), myDoingSimStep(false), myAmEmbedded(port == 0), myLaneTree(0) { myVehicleStateChanges[MSNet::VEHICLE_STATE_BUILT] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_DEPARTED] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_TELEPORT] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_TELEPORT] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_ARRIVED] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_NEWROUTE] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_PARKING] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_PARKING] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_STOP] = std::vector<std::string>(); myVehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_STOP] = std::vector<std::string>(); MSNet::getInstance()->addVehicleStateListener(this); myExecutors[CMD_GET_INDUCTIONLOOP_VARIABLE] = &TraCIServerAPI_InductionLoop::processGet; myExecutors[CMD_GET_AREAL_DETECTOR_VARIABLE] = &TraCIServerAPI_ArealDetector::processGet; myExecutors[CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE] = &TraCIServerAPI_MeMeDetector::processGet; myExecutors[CMD_GET_TL_VARIABLE] = &TraCIServerAPI_TLS::processGet; myExecutors[CMD_SET_TL_VARIABLE] = &TraCIServerAPI_TLS::processSet; myExecutors[CMD_GET_LANE_VARIABLE] = &TraCIServerAPI_Lane::processGet; myExecutors[CMD_SET_LANE_VARIABLE] = &TraCIServerAPI_Lane::processSet; myExecutors[CMD_GET_VEHICLE_VARIABLE] = &TraCIServerAPI_Vehicle::processGet; myExecutors[CMD_SET_VEHICLE_VARIABLE] = &TraCIServerAPI_Vehicle::processSet; myExecutors[CMD_GET_VEHICLETYPE_VARIABLE] = &TraCIServerAPI_VehicleType::processGet; myExecutors[CMD_SET_VEHICLETYPE_VARIABLE] = &TraCIServerAPI_VehicleType::processSet; myExecutors[CMD_GET_ROUTE_VARIABLE] = &TraCIServerAPI_Route::processGet; myExecutors[CMD_SET_ROUTE_VARIABLE] = &TraCIServerAPI_Route::processSet; myExecutors[CMD_GET_POI_VARIABLE] = &TraCIServerAPI_POI::processGet; myExecutors[CMD_SET_POI_VARIABLE] = &TraCIServerAPI_POI::processSet; myExecutors[CMD_GET_POLYGON_VARIABLE] = &TraCIServerAPI_Polygon::processGet; myExecutors[CMD_SET_POLYGON_VARIABLE] = &TraCIServerAPI_Polygon::processSet; myExecutors[CMD_GET_JUNCTION_VARIABLE] = &TraCIServerAPI_Junction::processGet; myExecutors[CMD_GET_EDGE_VARIABLE] = &TraCIServerAPI_Edge::processGet; myExecutors[CMD_SET_EDGE_VARIABLE] = &TraCIServerAPI_Edge::processSet; myExecutors[CMD_GET_SIM_VARIABLE] = &TraCIServerAPI_Simulation::processGet; myExecutors[CMD_SET_SIM_VARIABLE] = &TraCIServerAPI_Simulation::processSet; myDoCloseConnection = false; // display warning if internal lanes are not used if (!MSGlobals::gUsingInternalLanes) { WRITE_WARNING("Starting TraCI without using internal lanes!"); MsgHandler::getWarningInstance()->inform("Vehicles will jump over junctions.", false); MsgHandler::getWarningInstance()->inform("Use without option --no-internal-links to avoid unexpected behavior", false); } if (!myAmEmbedded) { try { WRITE_MESSAGE("***Starting server on port " + toString(port) + " ***"); mySocket = new tcpip::Socket(port); mySocket->accept(); // When got here, a client has connected } catch (tcpip::SocketException& e) { throw ProcessError(e.what()); } } }
void VehicleType::setEmergencyDecel(const std::string& typeID, double decel) { MSVehicleType* v = getVType(typeID); v->setEmergencyDecel(decel); if (decel < v->getCarFollowModel().getMaxDecel()) { WRITE_WARNING("New value of emergencyDecel (" + toString(decel) + ") is lower than decel (" + toString(v->getCarFollowModel().getMaxDecel()) + ")"); } }
void MSChargingStation::setChargingPower(SUMOReal chargingPower) { if (chargingPower < 0) WRITE_WARNING("new charging power for Chargin Station with ID = " + getID() + " not valid (" + TplConvert::_2str(chargingPower) + ").") else { myChargingPower = chargingPower; } }
void MSChargingStation::setEfficency(SUMOReal efficency) { if (efficency < 0 || efficency > 1) WRITE_WARNING("new efficiency for Chargin Station with ID = " + getID() + " not valid (" + TplConvert::_2str(efficency) + ").") else { myEfficiency = efficency; } }
void MSChargingStation::setChargeDelay(int chargeDelay) { if (chargeDelay < 0) WRITE_WARNING("new charge delay for Chargin Station with ID = " + getID() + " not valid (" + TplConvert::_2str(chargeDelay) + ").") else { myChargeDelay = chargeDelay; } }
template<> std::vector<bool> GNEAttributeCarrier::getDefaultValue(SumoXMLTag tag, SumoXMLAttr attr) { std::cout << "FINISH" << std::endl; // Write warning if attribute don't have a default value and return a empty value to avoid warnings WRITE_WARNING("attribute '" + toString(attr) + "' for tag '" + toString(tag) + "' don't have a default value"); return std::vector<bool>(); }
bool NIFrame::checkOptions() { OptionsCont& oc = OptionsCont::getOptions(); bool ok = oc.checkDependingSuboptions("shapefile", "shapefile."); ok &= oc.checkDependingSuboptions("visum-file", "visum."); ok &= oc.checkDependingSuboptions("vissim-file", "vissim."); #ifdef HAVE_PROJ int numProjections = oc.getBool("simple-projection") + oc.getBool("proj.utm") + oc.getBool("proj.dhdn") + (oc.getString("proj").length() > 1); if ((oc.isSet("osm-files") || oc.isSet("dlr-navteq-prefix") || oc.isSet("shapefile-prefix")) && numProjections == 0) { if (oc.isDefault("proj")) { oc.set("proj.utm", "true"); } } if (oc.isSet("dlr-navteq-prefix") && oc.isDefault("proj.scale")) { oc.set("proj.scale", NIImporter_DlrNavteq::GEO_SCALE); } #else if ((oc.isSet("osm-files") || oc.isSet("dlr-navteq-prefix") || oc.isSet("shapefile-prefix")) && !oc.getBool("simple-projection")) { WRITE_ERROR("Cannot import network data without PROJ-Library. Please install packages proj before building sumo"); ok = false; } #endif if (oc.isSet("sumo-net-file")) { if (oc.isWriteable("no-turnarounds")) { // changed default since turnarounds are loaded from the net file. oc.set("no-turnarounds", "true"); } if (oc.isWriteable("offset.disable-normalization")) { // changed default since we wish to preserve the network as far as possible oc.set("offset.disable-normalization", "true"); } } if (!oc.isSet("type-files")) { const char* sumoPath = std::getenv("SUMO_HOME"); if (sumoPath == 0) { WRITE_WARNING("Environment variable SUMO_HOME is not set, using built in type maps."); } else { const std::string path = sumoPath + std::string("/data/typemap/"); if (oc.isSet("osm-files")) { oc.setDefault("type-files", path + "osmNetconvert.typ.xml"); } if (oc.isSet("opendrive-files")) { oc.setDefault("type-files", path + "opendriveNetconvert.typ.xml"); } } } if (oc.isSet("opendrive-files")) { if (oc.isDefault("tls.left-green.time")) { // legacy behavior. see #2114 oc.set("tls.left-green.time", "0"); } if (oc.isDefault("rectangular-lane-cut")) { // a better interpretation of imported geometries oc.set("rectangular-lane-cut", "true"); } } return ok; }
void NBLoadedSUMOTLDef::patchIfCrossingsAdded() { // XXX what to do if crossings are removed during network building? const unsigned int size = myTLLogic->getNumLinks(); unsigned int noLinksAll = 0; for (NBConnectionVector::const_iterator it = myControlledLinks.begin(); it != myControlledLinks.end(); it++) { const NBConnection& c = *it; if (c.getTLIndex() != NBConnection::InvalidTlIndex) { noLinksAll = MAX2(noLinksAll, (unsigned int)c.getTLIndex() + 1); } } int oldCrossings = 0; // collect crossings std::vector<NBNode::Crossing> crossings; for (std::vector<NBNode*>::iterator i = myControlledNodes.begin(); i != myControlledNodes.end(); i++) { const std::vector<NBNode::Crossing>& c = (*i)->getCrossings(); // set tl indices for crossings (*i)->setCrossingTLIndices(noLinksAll); copy(c.begin(), c.end(), std::back_inserter(crossings)); noLinksAll += (unsigned int)c.size(); oldCrossings += (*i)->numCrossingsFromSumoNet(); } const int newCrossings = (int)crossings.size() - oldCrossings; if (newCrossings > 0) { const std::vector<NBTrafficLightLogic::PhaseDefinition> phases = myTLLogic->getPhases(); if (phases.size() > 0) { if (phases.front().state.size() == noLinksAll - newCrossings) { // patch states for the newly added crossings // collect edges EdgeVector fromEdges(size, 0); EdgeVector toEdges(size, 0); std::vector<int> fromLanes(size, 0); collectEdgeVectors(fromEdges, toEdges, fromLanes); const std::string crossingDefaultState(newCrossings, 'r'); // rebuild the logic (see NBOwnTLDef.cpp::myCompute) const std::vector<NBTrafficLightLogic::PhaseDefinition> phases = myTLLogic->getPhases(); NBTrafficLightLogic* newLogic = new NBTrafficLightLogic(getID(), getProgramID(), 0, myOffset, myType); SUMOTime brakingTime = TIME2STEPS(3); //std::cout << "patchIfCrossingsAdded for " << getID() << " numPhases=" << phases.size() << "\n"; for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it = phases.begin(); it != phases.end(); it++) { if ((*it).state.find_first_of("yY") != std::string::npos) { brakingTime = MAX2(brakingTime, it->duration); } NBOwnTLDef::addPedestrianPhases(newLogic, it->duration, it->state + crossingDefaultState, crossings, fromEdges, toEdges); } NBOwnTLDef::addPedestrianScramble(newLogic, noLinksAll, TIME2STEPS(10), brakingTime, crossings, fromEdges, toEdges); delete myTLLogic; myTLLogic = newLogic; } else if (phases.front().state.size() != noLinksAll) { WRITE_WARNING("Could not patch tlLogic " + getID() + "for new crossings"); } } } }
SUMOReal NIVissimDistrictConnection::getRealSpeed(/*NBDistribution &dc, */int distNo) const { std::string id = toString<int>(distNo); Distribution* dist = NBDistribution::dictionary("speed", id); if (dist == 0) { WRITE_WARNING("The referenced speed distribution '" + id + "' is not known."); WRITE_WARNING(". Using default."); return OptionsCont::getOptions().getFloat("vissim.default-speed"); } assert(dist != 0); SUMOReal speed = dist->getMax(); if (speed < 0 || speed > 1000) { WRITE_WARNING(" False speed at district '" + id); WRITE_WARNING(". Using default."); speed = OptionsCont::getOptions().getFloat("vissim.default-speed"); } return speed; }
void NIXMLEdgesHandler::addSplit(const SUMOSAXAttributes& attrs) { if (myCurrentEdge == 0) { if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) { WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge"); } return; } bool ok = true; Split e; e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok); if (ok) { if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) { WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + "."); return; } std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos)); if (i != mySplits.end()) { WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + "."); return; } const std::string nameid = toString((int)e.pos); if (e.pos < 0) { e.pos += myCurrentEdge->getGeometry().length(); } std::vector<std::string> lanes; SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes); for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) { try { int lane = TplConvert::_2int((*i).c_str()); e.lanes.push_back(lane); } catch (NumberFormatException&) { WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "')."); } catch (EmptyData&) { WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "')."); } } if (e.lanes.empty()) { for (int l = 0; l < myCurrentEdge->getNumLanes(); ++l) { e.lanes.push_back(l); } } e.speed = attrs.getOpt(SUMO_ATTR_SPEED, 0, ok, myCurrentEdge->getSpeed()); if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) { e.speed /= (SUMOReal) 3.6; } e.idBefore = attrs.getOpt(SUMO_ATTR_ID_BEFORE, 0, ok, std::string("")); e.idAfter = attrs.getOpt(SUMO_ATTR_ID_AFTER, 0, ok, std::string("")); if (!ok) { return; } e.node = new NBNode(myCurrentID + "." + nameid, myCurrentEdge->getGeometry().positionAtOffset(e.pos)); NIXMLNodesHandler::processNodeType(attrs, e.node, e.node->getID(), e.node->getPosition(), false, myNodeCont, myTLLogicCont); mySplits.push_back(e); } }
void GeoConvHelper::setLoaded(const GeoConvHelper& loaded) { myNumLoaded++; if (myNumLoaded > 1) { WRITE_WARNING("Ignoring loaded location attribute nr. " + toString(myNumLoaded) + " for tracking of original location"); } else { myLoaded = loaded; } }
bool MSE3Collector::MSE3EntryReminder::notifyLeave(SUMOVehicle& veh, SUMOReal, MSMoveReminder::Notification reason) { if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) { WRITE_WARNING("Vehicle '" + veh.getID() + "' arrived inside " + toString(SUMO_TAG_E3DETECTOR) + " '" + myCollector.getID() + "'."); myCollector.myEnteredContainer.erase(&veh); return false; } return true; }
void GNEUndoList::undo() { //std::cout << undoName().text() << "\n"; if (OptionsCont::getOptions().getBool("gui-testing-debug")) { WRITE_WARNING("Keys Ctrl + Z (Undo) pressed"); } FXUndoList::undo(); myParent->updateControls(); }
bool NIImporter_DlrNavteq::ProhibitionHandler::report(const std::string& result) { // # NAME_ID Name if (result[0] == '#') { if (myVersion == 0) { const double version = readVersion(result, myFile); if (version > 0) { myVersion = version; } } return true; } StringTokenizer st(result, StringTokenizer::TAB); if (st.size() == 1) { return true; // one line with the number of data containing lines in it (also starts with a comment # since ersion 6.5) } if (myVersion >= 6) { assert(st.size() >= 7); const std::string id = st.next(); const std::string permanent = st.next(); const std::string validityPeriod = st.next(); const std::string throughTraffic = st.next(); const std::string vehicleType = st.next(); if (validityPeriod != UNDEFINED) { WRITE_WARNING("Ignoring temporary prohibited manoeuvre (" + validityPeriod + ")"); return true; } } const std::string startEdge = st.next(); const std::string endEdge = st.get(st.size() - 1); NBEdge* from = myEdgeCont.retrieve(startEdge); if (from == nullptr) { WRITE_WARNING("Ignoring prohibition from unknown start edge '" + startEdge + "'"); return true; } NBEdge* to = myEdgeCont.retrieve(endEdge); if (to == nullptr) { WRITE_WARNING("Ignoring prohibition from unknown end edge '" + endEdge + "'"); return true; } from->removeFromConnections(to, -1, -1, true); return true; }
bool SUMORouteHandler::checkLastDepart() { if (myVehicleParameter->departProcedure == DEPART_GIVEN) { if (myVehicleParameter->depart < myLastDepart) { WRITE_WARNING("Route file should be sorted by departure time, ignoring '" + myVehicleParameter->id + "'!"); return false; } } return true; }
void GUISUMOAbstractView::checkSnapshots() { std::map<SUMOTime, std::string>::iterator snapIt = mySnapshots.find(getCurrentTimeStep()); if (snapIt != mySnapshots.end()) { std::string error = makeSnapshot(snapIt->second); if (error != "") { WRITE_WARNING(error); } } }
// ----------- Adapting the input void NBNodeCont::removeSelfLoops(NBDistrictCont& dc, NBEdgeCont& ec, NBTrafficLightLogicCont& tc) { unsigned int no = 0; for (NodeCont::iterator i = myNodes.begin(); i != myNodes.end(); i++) { no += (*i).second->removeSelfLoops(dc, ec, tc); } if (no != 0) { WRITE_WARNING(toString(no) + " self-looping edge(s) removed."); } }
void MSRouteHandler::openRoute(const SUMOSAXAttributes& attrs) { // check whether the id is really necessary std::string rid; if (myCurrentRouteDistribution != 0) { myActiveRouteID = myCurrentRouteDistributionID + "#" + toString(myCurrentRouteDistribution->getProbs().size()); // !!! document this rid = "distribution '" + myCurrentRouteDistributionID + "'"; } else if (myVehicleParameter != 0) { // ok, a vehicle is wrapping the route, // we may use this vehicle's id as default myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this if (attrs.hasAttribute(SUMO_ATTR_ID)) { WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "')."); } } else { bool ok = true; myActiveRouteID = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok, false); if (!ok) { return; } rid = "'" + myActiveRouteID + "'"; } if (myVehicleParameter != 0) { // have to do this here for nested route distributions rid = "for vehicle '" + myVehicleParameter->id + "'"; } bool ok = true; if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid); } myActiveRouteRefID = attrs.getOptStringReporting(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, ""); if (attrs.hasAttribute(SUMO_ATTR_REFID__DEPRECATED)) { myActiveRouteRefID = attrs.getOptStringReporting(SUMO_ATTR_REFID__DEPRECATED, myActiveRouteID.c_str(), ok, ""); if (!myHaveWarnedAboutDeprecatedRefID) { myHaveWarnedAboutDeprecatedRefID = true; WRITE_WARNING("'" + toString(SUMO_ATTR_REFID__DEPRECATED) + "' is deprecated, please use '" + toString(SUMO_ATTR_REFID) + "' instead."); } } if (myActiveRouteRefID != "" && MSRoute::dictionary(myActiveRouteRefID) == 0) { WRITE_ERROR("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + "."); } myActiveRouteProbability = attrs.getOptSUMORealReporting(SUMO_ATTR_PROB, myActiveRouteID.c_str(), ok, DEFAULT_VEH_PROB); myActiveRouteColor = attrs.hasAttribute(SUMO_ATTR_COLOR) ? RGBColor::parseColorReporting(attrs.getString(SUMO_ATTR_COLOR), attrs.getObjectType(), myActiveRouteID.c_str(), true, ok) : RGBColor::getDefaultColor(); }
bool MSDevice_BTreceiver::notifyMove(SUMOVehicle& veh, SUMOReal /* oldPos */, SUMOReal newPos, SUMOReal newSpeed) { if (sVehicles.find(veh.getID()) == sVehicles.end()) { WRITE_WARNING("btreceiver: Can not update position of vehicle '" + veh.getID() + "' which is not on the road."); return true; } const MSVehicle& v = static_cast<MSVehicle&>(veh); sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(newSpeed, veh.getPosition(), v.getLane()->getID(), newPos, v.getRoutePosition())); return true; }
void NBLoadedTLDef::SignalGroup::patchTYellow(unsigned int tyellow, bool forced) { if (myTYellow < 0) { // was not set before (was not loaded) myTYellow = tyellow; } else if (forced && myTYellow < tyellow) { WRITE_WARNING("TYellow of signal group '" + getID() + "' was less than the computed one; patched (was:" + toString(myTYellow) + ", is:" + toString(tyellow) + ")"); myTYellow = tyellow; } }
void GARDetectorHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { if (element == SUMO_TAG_DETECTOR_DEFINITION) { try { bool ok = true; // get the id, report an error if not given or empty... std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { throw ProcessError(); } std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok); if (!ok) { throw ProcessError(); } ROEdge* edge = myNet.getEdge(lane.substr(0, lane.rfind('_'))); unsigned int laneIndex = TplConvert::_2intSec( lane.substr(lane.rfind('_') + 1).c_str(), INT_MAX); if (edge == 0 || laneIndex >= edge->getLaneNo()) { throw ProcessError( "Unknown lane '" + lane + "' for detector '" + id + "' in '" + getFileName() + "'."); } SUMOReal pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok); std::string mml_type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, ""); if (!ok) { throw ProcessError(); } GARDetectorType type = TYPE_NOT_DEFINED; if (mml_type == "between") { type = BETWEEN_DETECTOR; } else if (mml_type == "source" || mml_type == "highway_source") { // !!! highway-source is legacy (removed accoring output on 06.08.2007) type = SOURCE_DETECTOR; } else if (mml_type == "sink") { type = SINK_DETECTOR; } GARDetector* detector = new GARDetector(id, lane, pos, type); if (!myContainer.addDetector(detector)) { delete detector; throw ProcessError( "Could not add detector '" + id + "' (probably the id is already used)."); } } catch (ProcessError& e) { if (myIgnoreErrors) { WRITE_WARNING(e.what()); } else { throw e; } } } }
void NIVissimConnection::dict_buildNBEdgeConnections(NBEdgeCont &ec) { unsigned int unsetConnections = 0; // go through connections for (DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { unsetConnections += (*i).second->buildEdgeConnections(ec); } if (unsetConnections!=0) { WRITE_WARNING(toString<size_t>(unsetConnections) + " of " + toString<size_t>(myDict.size())+ " connections could not be assigned."); } }
unsigned int NIVissimConnection::buildEdgeConnections(NBEdgeCont &ec) { unsigned int unsetConnections = 0; // try to determine the connected edges NBEdge *fromEdge = 0; NBEdge *toEdge = 0; NIVissimEdge *vissimFrom = NIVissimEdge::dictionary(getFromEdgeID()); if (vissimFrom->wasWithinAJunction()) { // this edge was not built, try to get one that approaches it vissimFrom = vissimFrom->getBestIncoming(); if (vissimFrom!=0) { fromEdge = ec.retrievePossiblySplitted(toString(vissimFrom->getID()), toString(getFromEdgeID()), true); } } else { // this edge was built, try to get the proper part fromEdge = ec.retrievePossiblySplitted(toString(getFromEdgeID()), toString(getToEdgeID()), true); } NIVissimEdge *vissimTo = NIVissimEdge::dictionary(getToEdgeID()); if (vissimTo->wasWithinAJunction()) { vissimTo = vissimTo->getBestOutgoing(); if (vissimTo!=0) { toEdge = ec.retrievePossiblySplitted(toString(vissimTo->getID()), toString(getToEdgeID()), true); } } else { toEdge = ec.retrievePossiblySplitted(toString(getToEdgeID()), toString(getFromEdgeID()), false); } // try to get the edges the current connection connects /* NBEdge *fromEdge = ec.retrievePossiblySplitted(toString(getFromEdgeID()), toString(getToEdgeID()), true); NBEdge *toEdge = ec.retrievePossiblySplitted(toString(getToEdgeID()), toString(getFromEdgeID()), false); */ if (fromEdge==0||toEdge==0) { WRITE_WARNING("Could not build connection between '" + toString(getFromEdgeID())+ "' and '" + toString(getToEdgeID())+ "'."); return 1; // !!! actually not 1 } recheckLanes(fromEdge, toEdge); const IntVector &fromLanes = getFromLanes(); const IntVector &toLanes = getToLanes(); if (fromLanes.size()!=toLanes.size()) { MsgHandler::getWarningInstance()->inform("Lane sizes differ for connection '" + toString(getID()) + "'."); } else { for (unsigned int index=0; index<fromLanes.size(); ++index) { if (fromEdge->getNoLanes()<=static_cast<unsigned int>(fromLanes[index])) { MsgHandler::getWarningInstance()->inform("Could not set connection between '" + fromEdge->getID() + "_" + toString(fromLanes[index]) + "' and '" + toEdge->getID() + "_" + toString(toLanes[index]) + "'."); ++unsetConnections; } else if (!fromEdge->addLane2LaneConnection(fromLanes[index], toEdge, toLanes[index], NBEdge::L2L_VALIDATED)) { MsgHandler::getWarningInstance()->inform("Could not set connection between '" + fromEdge->getID() + "_" + toString(fromLanes[index]) + "' and '" + toEdge->getID() + "_" + toString(toLanes[index]) + "'."); ++unsetConnections; } } } return unsetConnections; }
bool MSTriggeredRerouter::notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) { if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) { return false; } // check whether the vehicle shall be rerouted SUMOTime time = MSNet::getInstance()->getCurrentTimeStep(); if (!hasCurrentReroute(time, veh)) { return false; } SUMOReal prob = myAmInUserMode ? myUserProbability : myProbability; if (RandHelper::rand() > prob) { return false; } // get vehicle params const MSRoute& route = veh.getRoute(); const MSEdge* lastEdge = route.getLastEdge(); // get rerouting params const MSTriggeredRerouter::RerouteInterval& rerouteDef = getCurrentReroute(time, veh); const MSRoute* newRoute = rerouteDef.routeProbs.getOverallProb() > 0 ? rerouteDef.routeProbs.get() : 0; // we will use the route if given rather than calling our own dijsktra... if (newRoute != 0) { veh.replaceRoute(newRoute); return false; } const MSEdge* newEdge = lastEdge; // ok, try using a new destination const bool destUnreachable = std::find(rerouteDef.closed.begin(), rerouteDef.closed.end(), lastEdge) != rerouteDef.closed.end(); // if we have a closingReroute, only assign new destinations to vehicles which cannot reach their original destination if (rerouteDef.closed.size() == 0 || destUnreachable) { newEdge = rerouteDef.edgeProbs.getOverallProb() > 0 ? rerouteDef.edgeProbs.get() : route.getLastEdge(); if (newEdge == &mySpecialDest_terminateRoute) { newEdge = veh.getEdge(); } else if (newEdge == &mySpecialDest_keepDestination || newEdge == lastEdge) { if (destUnreachable) { WRITE_WARNING("Cannot keep destination for vehicle '" + veh.getID() + "' due to closed edges. Terminating route."); newEdge = veh.getEdge(); } else { newEdge = lastEdge; } } else if (newEdge == 0) { assert(false); // this should never happen newEdge = veh.getEdge(); } } // we have a new destination, let's replace the vehicle route std::vector<const MSEdge*> edges; MSNet::getInstance()->getRouterTT(rerouteDef.closed).compute( veh.getEdge(), newEdge, &veh, MSNet::getInstance()->getCurrentTimeStep(), edges); veh.replaceRouteEdges(edges); return false; }