void RONetHandler::parseDistrict(const SUMOSAXAttributes& attrs) { myCurrentEdge = 0; bool ok = true; myCurrentName = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { return; } ROEdge* sink = myEdgeBuilder.buildEdge(myCurrentName + "-sink", 0, 0, 0); sink->setType(ROEdge::ET_DISTRICT); myNet.addEdge(sink); ROEdge* source = myEdgeBuilder.buildEdge(myCurrentName + "-source", 0, 0, 0); source->setType(ROEdge::ET_DISTRICT); myNet.addEdge(source); if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES); for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) { ROEdge* edge = myNet.getEdge(*i); // check whether the edge exists if (edge == 0) { throw ProcessError("The edge '" + *i + "' within district '" + myCurrentName + "' is not known."); } source->addFollower(edge); edge->addFollower(sink); } } }
void NIImporter_SUMO::addRoundabout(const SUMOSAXAttributes& attrs) { if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { myRoundabouts.push_back(attrs.getStringVector(SUMO_ATTR_EDGES)); } else { WRITE_ERROR("Empty edges in roundabout."); } }
void NLHandler::addDistrict(const SUMOSAXAttributes& attrs) { bool ok = true; myCurrentIsBroken = false; // get the id, report an error if not given or empty... myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { myCurrentIsBroken = true; return; } try { MSEdge* sink = myEdgeControlBuilder.buildEdge(myCurrentDistrictID + "-sink", MSEdge::EDGEFUNCTION_DISTRICT); if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) { delete sink; throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists."); } sink->initialize(new std::vector<MSLane*>()); MSEdge* source = myEdgeControlBuilder.buildEdge(myCurrentDistrictID + "-source", MSEdge::EDGEFUNCTION_DISTRICT); if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) { delete source; throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists."); } source->initialize(new std::vector<MSLane*>()); if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES); for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) { MSEdge* edge = MSEdge::dictionary(*i); // check whether the edge exists if (edge == 0) { throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known."); } source->addFollower(edge); edge->addFollower(sink); } } if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) { PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, myCurrentDistrictID.c_str(), ok); if (shape.size() != 0) { if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) { WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists."); } } } } catch (InvalidArgument& e) { WRITE_ERROR(e.what()); myCurrentIsBroken = true; } }
void NLHandler::addRoundabout(const SUMOSAXAttributes& attrs) { if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES); for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) { MSEdge* edge = MSEdge::dictionary(*it); if (edge == 0) { WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout"); } else { edge->markAsRoundabout(); } } } else { WRITE_ERROR("Empty edges in roundabout."); } }
void RONetHandler::parseDistrict(const SUMOSAXAttributes& attrs) { myCurrentEdge = 0; bool ok = true; myCurrentName = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { return; } myNet.addDistrict(myCurrentName, myEdgeBuilder.buildEdge(myCurrentName + "-source", 0, 0, 0), myEdgeBuilder.buildEdge(myCurrentName + "-sink", 0, 0, 0)); if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES); for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) { myNet.addDistrictEdge(myCurrentName, *i, true); myNet.addDistrictEdge(myCurrentName, *i, false); } } }
void ODDistrictHandler::openDistrict(const SUMOSAXAttributes& attrs) { myCurrentDistrict = 0; // get the id, report an error if not given or empty... bool ok = true; std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { return; } myCurrentDistrict = new ODDistrict(id); if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES); for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) { myCurrentDistrict->addSource(*i, 1.); myCurrentDistrict->addSink(*i, 1.); } } }
void NIXMLEdgesHandler::addRoundabout(const SUMOSAXAttributes& attrs) { if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES); EdgeSet roundabout; for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) { NBEdge* edge = myEdgeCont.retrieve(*it); if (edge == 0) { if (!myEdgeCont.wasIgnored(*it)) { WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout"); } } else { roundabout.insert(edge); } } myEdgeCont.addRoundabout(roundabout); } else { WRITE_ERROR("Empty edges in roundabout."); } }
void NLHandler::addDistrict(const SUMOSAXAttributes& attrs) { bool ok = true; myCurrentIsBroken = false; // get the id, report an error if not given or empty... myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok); if (!ok) { myCurrentIsBroken = true; return; } try { MSEdge* sink = myEdgeControlBuilder.buildEdge(myCurrentDistrictID + "-sink", MSEdge::EDGEFUNCTION_DISTRICT); if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) { delete sink; throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists."); } sink->initialize(new std::vector<MSLane*>()); MSEdge* source = myEdgeControlBuilder.buildEdge(myCurrentDistrictID + "-source", MSEdge::EDGEFUNCTION_DISTRICT); if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) { delete source; throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists."); } source->initialize(new std::vector<MSLane*>()); if (attrs.hasAttribute(SUMO_ATTR_EDGES)) { std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES); for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) { MSEdge* edge = MSEdge::dictionary(*i); // check whether the edge exists if (edge == 0) { throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known."); } source->addFollower(edge); edge->addFollower(sink); } } } catch (InvalidArgument& e) { WRITE_ERROR(e.what()); myCurrentIsBroken = true; } }