本文整理汇总了C++中NBEdge::setPermissions方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::setPermissions方法的具体用法?C++ NBEdge::setPermissions怎么用?C++ NBEdge::setPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::setPermissions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InvalidArgument
void
GNELane::setAttribute(SumoXMLAttr key, const std::string& value) {
NBEdge* edge = myParentEdge.getNBEdge();
switch (key) {
case SUMO_ATTR_ID:
throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
case SUMO_ATTR_SPEED:
edge->setSpeed(myIndex, parse<SUMOReal>(value));
break;
case SUMO_ATTR_ALLOW:
edge->setPermissions(parseVehicleClasses(value), myIndex);
break;
case SUMO_ATTR_DISALLOW:
edge->setPermissions(~parseVehicleClasses(value), myIndex); // negation yields allowed
break;
case SUMO_ATTR_WIDTH:
edge->setLaneWidth(myIndex, parse<SUMOReal>(value));
break;
case SUMO_ATTR_ENDOFFSET:
edge->setEndOffset(myIndex, parse<SUMOReal>(value));
break;
default:
throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
}
}
示例2:
void
NINavTeqHelper::addVehicleClasses(NBEdge& e, const std::string& oclassS) {
std::string classS = "0000000000" + oclassS;
classS = classS.substr(classS.length() - 10);
// 0: allow all vehicle types
if (classS[0] == '1') {
return;
}
// we have some restrictions. disallow all and then add classes indiviually
e.setPermissions(0);
// Passenger cars -- becomes SVC_PASSENGER
if (classS[1] == '1') {
e.allowVehicleClass(-1, SVC_PASSENGER);
}
// High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
if (classS[2] == '1') {
e.allowVehicleClass(-1, SVC_HOV);
e.allowVehicleClass(-1, SVC_PASSENGER);
}
// Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
if (classS[3] == '1') {
e.allowVehicleClass(-1, SVC_PUBLIC_EMERGENCY);
}
// Taxi -- becomes SVC_TAXI
if (classS[4] == '1') {
e.allowVehicleClass(-1, SVC_TAXI);
}
// Public Bus -- becomes SVC_BUS|SVC_PUBLIC_TRANSPORT
if (classS[5] == '1') {
e.allowVehicleClass(-1, SVC_PUBLIC_TRANSPORT);
e.allowVehicleClass(-1, SVC_BUS);
}
// Delivery Truck -- becomes SVC_DELIVERY
if (classS[6] == '1') {
e.allowVehicleClass(-1, SVC_DELIVERY);
}
// Transport Truck -- becomes SVC_TRANSPORT
if (classS[7] == '1') {
e.allowVehicleClass(-1, SVC_TRANSPORT);
}
// Bicycle -- becomes SVC_BICYCLE
if (classS[8] == '1') {
e.allowVehicleClass(-1, SVC_BICYCLE);
}
// Pedestrian -- becomes SVC_PEDESTRIAN
if (classS[9] == '1') {
e.allowVehicleClass(-1, SVC_PEDESTRIAN);
}
}
示例3: ProcessError
//.........这里部分代码省略.........
int priority;
try {
priority = -StringUtils::toInt(getColumn(st, FUNCTIONAL_ROAD_CLASS));
// lower priority using form_of_way
if (form_of_way == 11) {
priority -= 1; // frontage road, very often with lowered curb
} else if (form_of_way > 11) {
priority -= 2; // parking/service access assume lowered curb
}
} catch (NumberFormatException&) {
throw ProcessError("Non-numerical value for street_type of link '" + id + "').");
}
// street name
std::string streetName = getStreetNameFromIDs(
getColumn(st, NAME_ID1_REGIONAL),
getColumn(st, NAME_ID2_LOCAL));
// try to get the nodes
const std::string fromID = getColumn(st, NODE_ID_FROM);
const std::string toID = getColumn(st, NODE_ID_TO);
NBNode* from = myNodeCont.retrieve(fromID);
NBNode* to = myNodeCont.retrieve(toID);
if (from == nullptr) {
throw ProcessError("The from-node '" + fromID + "' of link '" + id + "' could not be found");
}
if (to == nullptr) {
throw ProcessError("The to-node '" + toID + "' of link '" + id + "' could not be found");
}
// speed
double speed;
try {
speed = StringUtils::toInt(getColumn(st, SPEED_RESTRICTION, "-1")) / 3.6;
} catch (NumberFormatException&) {
throw ProcessError("Non-numerical value for the SPEED_RESTRICTION of link '" + id + "'.");
}
if (speed < 0) {
// speed category as fallback
speed = NINavTeqHelper::getSpeed(id, getColumn(st, SPEED_CATEGORY));
}
// number of lanes
int numLanes;
try {
// EXTENDED_NUMBER_OF_LANES is prefered but may not be defined
numLanes = StringUtils::toInt(getColumn(st, EXTENDED_NUMBER_OF_LANES, "-1"));
if (numLanes == -1) {
numLanes = NINavTeqHelper::getLaneNumber(id, getColumn(st, NUMBER_OF_LANES), speed);
}
} catch (NumberFormatException&) {
throw ProcessError("Non-numerical value for the number of lanes of link '" + id + "'.");
}
const std::string navTeqTypeId = getColumn(st, VEHICLE_TYPE) + "_" + getColumn(st, FORM_OF_WAY);
// build the edge
NBEdge* e = nullptr;
const std::string interID = getColumn(st, BETWEEN_NODE_ID);
if (interID == "-1") {
e = new NBEdge(id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId : "", speed, numLanes, priority,
NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET, streetName);
} else {
PositionVector geoms = myGeoms[interID];
if (getColumn(st, CONNECTION, "0") == "1") {
geoms = geoms.reverse();
}
geoms.insert(geoms.begin(), from->getPosition());
geoms.push_back(to->getPosition());
const std::string origID = OptionsCont::getOptions().getBool("output.original-names") ? id : "";
e = new NBEdge(id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId : "", speed, numLanes, priority,
NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET, geoms, streetName, origID, LANESPREAD_CENTER);
}
// NavTeq imports can be done with a typemap (if supplied), if not, the old defaults are used
if (myTypeCont.knows(navTeqTypeId)) {
e->setPermissions(myTypeCont.getPermissions(navTeqTypeId));
} else {
// add vehicle type information to the edge
if (myVersion < 6.0) {
NINavTeqHelper::addVehicleClasses(*e, getColumn(st, VEHICLE_TYPE));
} else {
NINavTeqHelper::addVehicleClassesV6(*e, getColumn(st, VEHICLE_TYPE));
}
if (e->getPermissions() == SVCAll) {
e->setPermissions(myTypeCont.getPermissions(""));
}
// permission modifications based on form_of_way
if (form_of_way == 14) { // pedestrian area (fussgaengerzone)
// unfortunately, the veh_type string is misleading in this case
e->disallowVehicleClass(-1, SVC_PASSENGER);
}
// permission modifications based on brunnel_type
if (brunnel_type == 10) { // ferry
e->setPermissions(SVC_SHIP, -1);
}
}
// insert the edge to the network
if (!myEdgeCont.insert(e)) {
delete e;
throw ProcessError("Could not add edge '" + id + "'.");
}
return true;
}
示例4: ProcessError
//.........这里部分代码省略.........
WRITE_ERROR("Unknown edge '" + c.toEdgeID + "' given in connection.");
continue;
}
NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
if (toEdge == 0) { // removed by explicit list, vclass, ...
continue;
}
if (nbe->hasConnectionTo(toEdge, c.toLaneIdx)) {
WRITE_WARNING("Target lane '" + toEdge->getLaneID(c.toLaneIdx) + "' has multiple connections from '" + nbe->getID() + "'.");
}
nbe->addLane2LaneConnection(
fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::L2L_VALIDATED,
true, c.mayDefinitelyPass, c.keepClear, c.contPos);
// maybe we have a tls-controlled connection
if (c.tlID != "" && myRailSignals.count(c.tlID) == 0) {
const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.tlID);
if (programs.size() > 0) {
std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
for (it = programs.begin(); it != programs.end(); it++) {
NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it->second);
if (tlDef) {
tlDef->addConnection(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkNo);
} else {
throw ProcessError("Corrupt traffic light definition '" + c.tlID + "' (program '" + it->first + "')");
}
}
} else {
WRITE_ERROR("The traffic light '" + c.tlID + "' is not known.");
}
}
}
// allow/disallow XXX preferred
nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow), fromLaneIndex);
// width, offset
nbe->setLaneWidth(fromLaneIndex, lane->width);
nbe->setEndOffset(fromLaneIndex, lane->endOffset);
nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
}
nbe->declareConnectionsAsLoaded();
if (!nbe->hasLaneSpecificWidth() && nbe->getLanes()[0].width != NBEdge::UNSPECIFIED_WIDTH) {
nbe->setLaneWidth(-1, nbe->getLaneWidth(0));
}
if (!nbe->hasLaneSpecificEndOffset() && nbe->getEndOffset(0) != NBEdge::UNSPECIFIED_OFFSET) {
nbe->setEndOffset(-1, nbe->getEndOffset(0));
}
}
// insert loaded prohibitions
for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
NBEdge* prohibitedTo = myEdges[it->prohibitedTo]->builtEdge;
NBEdge* prohibitorFrom = myEdges[it->prohibitorFrom]->builtEdge;
NBEdge* prohibitorTo = myEdges[it->prohibitorTo]->builtEdge;
if (prohibitedFrom == 0) {
WRITE_WARNING("Edge '" + it->prohibitedFrom + "' in prohibition was not built");
} else if (prohibitedTo == 0) {
WRITE_WARNING("Edge '" + it->prohibitedTo + "' in prohibition was not built");
} else if (prohibitorFrom == 0) {
WRITE_WARNING("Edge '" + it->prohibitorFrom + "' in prohibition was not built");
} else if (prohibitorTo == 0) {
WRITE_WARNING("Edge '" + it->prohibitorTo + "' in prohibition was not built");
} else {
NBNode* n = prohibitedFrom->getToNode();
n->addSortedLinkFoes(
NBConnection(prohibitorFrom, prohibitorTo),
NBConnection(prohibitedFrom, prohibitedTo));
示例5: ProcessError
//.........这里部分代码省略.........
}
if (to == 0) {
WRITE_ERROR("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
continue;
}
// edge shape
PositionVector geom;
if (ed->shape.size() > 0) {
geom = ed->shape;
mySuspectKeepShape = false; // no problem with reconstruction if edge shape is given explicit
} else {
// either the edge has default shape consisting only of the two node
// positions or we have a legacy network
geom = reconstructEdgeShape(ed, from->getPosition(), to->getPosition());
}
// build and insert the edge
NBEdge* e = new NBEdge(ed->id, from, to,
ed->type, ed->maxSpeed,
(unsigned int) ed->lanes.size(),
ed->priority, NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET,
geom, ed->streetName, ed->lsf, true); // always use tryIgnoreNodePositions to keep original shape
e->setLoadedLength(ed->length);
if (!myNetBuilder.getEdgeCont().insert(e)) {
WRITE_ERROR("Could not insert edge '" + ed->id + "'.");
delete e;
continue;
}
ed->builtEdge = myNetBuilder.getEdgeCont().retrieve(ed->id);
}
// assign further lane attributes (edges are built)
for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
EdgeAttrs* ed = (*i).second;
NBEdge* nbe = ed->builtEdge;
if (nbe == 0) { // inner edge or removed by explicit list, vclass, ...
continue;
}
for (unsigned int fromLaneIndex = 0; fromLaneIndex < (unsigned int) ed->lanes.size(); ++fromLaneIndex) {
LaneAttrs* lane = ed->lanes[fromLaneIndex];
// connections
const std::vector<Connection>& connections = lane->connections;
for (std::vector<Connection>::const_iterator c_it = connections.begin(); c_it != connections.end(); c_it++) {
const Connection& c = *c_it;
if (myEdges.count(c.toEdgeID) == 0) {
WRITE_ERROR("Unknown edge '" + c.toEdgeID + "' given in connection.");
continue;
}
NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
if (toEdge == 0) { // removed by explicit list, vclass, ...
continue;
}
nbe->addLane2LaneConnection(
fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::L2L_VALIDATED,
false, c.mayDefinitelyPass);
// maybe we have a tls-controlled connection
if (c.tlID != "" && !OptionsCont::getOptions().getBool("tls.discard-loaded")) {
const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.tlID);
if (programs.size() > 0) {
std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
for (it = programs.begin(); it != programs.end(); it++) {
NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it->second);
if (tlDef) {
tlDef->addConnection(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkNo);
} else {
throw ProcessError("Corrupt traffic light definition '" + c.tlID + "' (program '" + it->first + "')");
}
}
} else {
WRITE_ERROR("The traffic light '" + c.tlID + "' is not known.");
}
}
}
// allow/disallow XXX preferred
nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow), fromLaneIndex);
// width, offset
nbe->setWidth(fromLaneIndex, lane->width);
nbe->setOffset(fromLaneIndex, lane->offset);
nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
}
nbe->declareConnectionsAsLoaded();
}
// insert loaded prohibitions
for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
if (prohibitedFrom == 0) {
WRITE_ERROR("Edge '" + it->prohibitedFrom + "' in prohibition was not built");
} else {
NBNode* n = prohibitedFrom->getToNode();
n->addSortedLinkFoes(
NBConnection(myEdges[it->prohibitorFrom]->builtEdge, myEdges[it->prohibitorTo]->builtEdge),
NBConnection(prohibitedFrom, myEdges[it->prohibitedTo]->builtEdge));
}
}
// final warning
if (mySuspectKeepShape) {
WRITE_WARNING("The input network may have been built using option 'xml.keep-shape'.\n... Accuracy of junction positions cannot be guaranteed.");
}
}