void NWWriter_DlrNavteq::writeProhibitedManoeuvres(const OptionsCont& oc, const NBNodeCont& nc, const NBEdgeCont& ec) { OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_prohibited_manoeuvres.txt"); writeHeader(device, oc); // need to invent id for relation std::set<std::string> reservedRelIDs; if (oc.isSet("reserved-ids")) { NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "rel:", reservedRelIDs); } std::vector<std::string> avoid = ec.getAllNames(); // already used for tls RELATREC_ID avoid.insert(avoid.end(), reservedRelIDs.begin(), reservedRelIDs.end()); IDSupplier idSupplier("", avoid); // @note: use a global relRecIDsupplier if this is used more often // write format specifier device << "#No driving allowed from ID1 to ID2 or the complete chain from ID1 to IDn\n"; device << "#RELATREC_ID\tPERMANENT_ID_INFO\tVALIDITY_PERIOD\tTHROUGH_TRAFFIC\tVEHICLE_TYPE\tNAVTEQ_LINK_ID1\t[NAVTEQ_LINK_ID2 ...]\n"; // write record for every pair of incoming/outgoing edge that are not connected despite having common permissions for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) { NBNode* n = (*i).second; const EdgeVector& incoming = n->getIncomingEdges(); const EdgeVector& outgoing = n->getOutgoingEdges(); for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) { NBEdge* inEdge = *j; const SVCPermissions inPerm = inEdge->getPermissions(); for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); ++k) { NBEdge* outEdge = *k; const SVCPermissions outPerm = outEdge->getPermissions(); const SVCPermissions commonPerm = inPerm & outPerm; if (commonPerm != 0 && commonPerm != SVC_PEDESTRIAN && !inEdge->isConnectedTo(outEdge)) { device << idSupplier.getNext() << "\t" << 1 << "\t" // permanent id << UNDEFINED << "\t" << 1 << "\t" << getAllowedTypes(SVCAll) << "\t" << inEdge->getID() << "\t" << outEdge->getID() << "\n"; } } } } device.close(); }
void NBTurningDirectionsComputer::computeTurnDirectionsForNode(NBNode* node) { const std::vector<NBEdge*>& incoming = node->getIncomingEdges(); const std::vector<NBEdge*>& outgoing = node->getOutgoingEdges(); std::vector<Combination> combinations; for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) { NBEdge* outedge = *j; for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) { NBEdge* e = *k; if (e->getConnections().size() != 0 && !e->isConnectedTo(outedge)) { // has connections, but not to outedge; outedge will not be the turn direction // // @todo: this seems to be needed due to legacy issues; actually, we could regard // such pairs, too, and it probably would increase the accuracy. But there is // no mechanism implemented, yet, which would avoid adding them as turnarounds though // no connection is specified. continue; } // @todo: check whether NBHelpers::relAngle is properly defined and whether it should really be used, here SUMOReal angle = fabs(NBHelpers::relAngle(e->getAngleAtNode(node), outedge->getAngleAtNode(node))); if (angle < 160) { continue; } if (e->getFromNode() == outedge->getToNode()) { // they connect the same nodes; should be the turnaround direction // we'll assign a maximum number // // @todo: indeed, we have observed some pathological intersections // see "294831560" in OSM/adlershof. Here, several edges are connecting // same nodes. We have to do the angle check before... // // @todo: and well, there are some other as well, see plain import // of delphi_muenchen (elmar), intersection "59534191". Not that it would // be realistic in any means; we will warn, here. angle += 360; } Combination c; c.from = e; c.to = outedge; c.angle = angle; combinations.push_back(c); } } // sort combinations so that the ones with the highest angle are at the begin std::sort(combinations.begin(), combinations.end(), combination_by_angle_sorter()); std::set<NBEdge*> seen; bool haveWarned = false; for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) { if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) { // do not regard already set edges if ((*j).angle > 360 && !haveWarned) { WRITE_WARNING("Ambiguity in turnarounds computation at node '" + node->getID() + "'."); haveWarned = true; } continue; } // mark as seen seen.insert((*j).from); seen.insert((*j).to); // set turnaround information (*j).from->setTurningDestination((*j).to); } }
void NIXMLConnectionsHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { if (element == SUMO_TAG_DELETE) { bool ok = true; std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok); std::string to = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok); if (!ok) { return; } // these connections were removed when the edge was deleted if (myEdgeCont.wasRemoved(from) || myEdgeCont.wasRemoved(to)) { return; } NBEdge* fromEdge = myEdgeCont.retrieve(from); NBEdge* toEdge = myEdgeCont.retrieve(to); if (fromEdge == 0) { myErrorMsgHandler->inform("The connection-source edge '" + from + "' to reset is not known."); return; } if (toEdge == 0) { myErrorMsgHandler->inform("The connection-destination edge '" + to + "' to reset is not known."); return; } if (!fromEdge->isConnectedTo(toEdge) && fromEdge->getStep() >= NBEdge::EDGE2EDGES) { WRITE_WARNING("Target edge '" + toEdge->getID() + "' is not connected with '" + fromEdge->getID() + "'; the connection cannot be reset."); return; } int fromLane = -1; // Assume all lanes are to be reset. int toLane = -1; if (attrs.hasAttribute(SUMO_ATTR_LANE) || attrs.hasAttribute(SUMO_ATTR_FROM_LANE) || attrs.hasAttribute(SUMO_ATTR_TO_LANE)) { if (!parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) { return; } // we could be trying to reset a connection loaded from a sumo net and which has become obsolete. // In this case it's ok to encounter invalid lance indices if (!fromEdge->hasConnectionTo(toEdge, toLane) && fromEdge->getStep() >= NBEdge::LANES2EDGES) { WRITE_WARNING("Edge '" + fromEdge->getID() + "' has no connection to lane " + toString(toLane) + " of edge '" + toEdge->getID() + "'; the connection cannot be reset."); } } fromEdge->removeFromConnections(toEdge, fromLane, toLane, true); } if (element == SUMO_TAG_CONNECTION) { bool ok = true; std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, "connection", ok); std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, "connection", ok, ""); if (!ok || myEdgeCont.wasIgnored(from) || myEdgeCont.wasIgnored(to)) { return; } // extract edges NBEdge* fromEdge = myEdgeCont.retrieve(from); NBEdge* toEdge = to.length() != 0 ? myEdgeCont.retrieve(to) : 0; // check whether they are valid if (fromEdge == 0) { myErrorMsgHandler->inform("The connection-source edge '" + from + "' is not known."); return; } if (toEdge == 0 && to.length() != 0) { myErrorMsgHandler->inform("The connection-destination edge '" + to + "' is not known."); return; } fromEdge->getToNode()->invalidateTLS(myTLLogicCont, true, false); // parse optional lane information if (attrs.hasAttribute(SUMO_ATTR_LANE) || attrs.hasAttribute(SUMO_ATTR_FROM_LANE) || attrs.hasAttribute(SUMO_ATTR_TO_LANE)) { parseLaneBound(attrs, fromEdge, toEdge); } else { fromEdge->addEdge2EdgeConnection(toEdge); } } if (element == SUMO_TAG_PROHIBITION) { bool ok = true; std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, 0, ok, ""); std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, 0, ok, ""); if (!ok) { return; } NBConnection prohibitorC = parseConnection("prohibitor", prohibitor); NBConnection prohibitedC = parseConnection("prohibited", prohibited); if (prohibitorC == NBConnection::InvalidConnection || prohibitedC == NBConnection::InvalidConnection) { // something failed return; } NBNode* n = prohibitorC.getFrom()->getToNode(); n->addSortedLinkFoes(prohibitorC, prohibitedC); } if (element == SUMO_TAG_CROSSING) { addCrossing(attrs); } if (element == SUMO_TAG_WALKINGAREA) { addWalkingArea(attrs); } }