void NWWriter_DlrNavteq::writeLinksUnsplitted(const OptionsCont& oc, NBEdgeCont& ec) { OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_links_unsplitted.txt"); writeHeader(device, oc); // write format specifier device << "# LINK_ID\tNODE_ID_FROM\tNODE_ID_TO\tBETWEEN_NODE_ID\tLENGTH\tVEHICLE_TYPE\tFORM_OF_WAY\tBRUNNEL_TYPE\tFUNCTIONAL_ROAD_CLASS\tSPEED_CATEGORY\tNUMBER_OF_LANES\tSPEED_LIMIT\tSPEED_RESTRICTION\tNAME_ID1_REGIONAL\tNAME_ID2_LOCAL\tHOUSENUMBERS_RIGHT\tHOUSENUMBERS_LEFT\tZIP_CODE\tAREA_ID\tSUBAREA_ID\tTHROUGH_TRAFFIC\tSPECIAL_RESTRICTIONS\tEXTENDED_NUMBER_OF_LANES\tISRAMP\tCONNECTION\n"; // write edges for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) { NBEdge* e = (*i).second; const int kph = speedInKph(e->getSpeed()); const std::string& betweenNodeID = (e->getGeometry().size() > 2) ? e->getID() : UNDEFINED; device << e->getID() << "\t" << e->getFromNode()->getID() << "\t" << e->getToNode()->getID() << "\t" << betweenNodeID << "\t" << getGraphLength(e) << "\t" << getAllowedTypes(e->getPermissions()) << "\t" << "3\t" // Speed Category 1-8 XXX refine this << UNDEFINED << "\t" // no special brunnel type (we don't know yet) << getRoadClass(e) << "\t" << getSpeedCategory(kph) << "\t" << getNavteqLaneCode(e->getNumLanes()) << "\t" << getSpeedCategoryUpperBound(kph) << "\t" << kph << "\t" << UNDEFINED << "\t" // NAME_ID1_REGIONAL XXX << UNDEFINED << "\t" // NAME_ID2_LOCAL XXX << UNDEFINED << "\t" // housenumbers_right << UNDEFINED << "\t" // housenumbers_left << UNDEFINED << "\t" // ZIP_CODE << UNDEFINED << "\t" // AREA_ID << UNDEFINED << "\t" // SUBAREA_ID << "1\t" // through_traffic (allowed) << UNDEFINED << "\t" // special_restrictions << UNDEFINED << "\t" // extended_number_of_lanes << UNDEFINED << "\t" // isRamp << "0\t" // connection (between nodes always in order) << "\n"; } }
bool NIImporter_DlrNavteq::EdgesHandler::report(const std::string& result) { // parse version number from first comment line and initialize column definitions if (result[0] == '#') { if (!myColumns.empty()) { return true; } const double version = readVersion(result, myFile); if (version > 0) { myVersion = version; // init columns const int NUM_COLUMNS = 25; // @note arrays must match this size! const int MC = MISSING_COLUMN; if (myVersion < 3) { const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, MC, 12, 13, 14, 15, 16, 17, 18, 19, 20, MC, MC, -21}; myColumns = std::vector<int>(columns, columns + NUM_COLUMNS); } else if (myVersion < 6) { const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, MC, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -23}; myColumns = std::vector<int>(columns, columns + NUM_COLUMNS); } else { const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; myColumns = std::vector<int>(columns, columns + NUM_COLUMNS); } } return true; } if (myColumns.empty()) { throw ProcessError("Missing version string in file '" + myFile + "'."); } // interpret link attributes StringTokenizer st(result, StringTokenizer::WHITECHARS); const std::string id = getColumn(st, LINK_ID); // form of way (for priority and permissions) int form_of_way; try { form_of_way = StringUtils::toInt(getColumn(st, FORM_OF_WAY)); } catch (NumberFormatException&) { throw ProcessError("Non-numerical value for form_of_way of link '" + id + "'."); } // brunnel type (bridge/tunnel/ferry (for permissions) int brunnel_type; try { brunnel_type = StringUtils::toInt(getColumn(st, BRUNNEL_TYPE)); } catch (NumberFormatException&) { throw ProcessError("Non-numerical value for brunnel_type of link '" + id + "'."); } // priority based on street_type / frc 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; }
void NBTrafficLightDefinition::collectAllLinks() { myControlledLinks.clear(); int tlIndex = 0; // build the list of links which are controled by the traffic light for (EdgeVector::iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) { NBEdge* incoming = *i; unsigned int noLanes = incoming->getNumLanes(); for (unsigned int j = 0; j < noLanes; j++) { std::vector<NBEdge::Connection> connected = incoming->getConnectionsFromLane(j); for (std::vector<NBEdge::Connection>::iterator k = connected.begin(); k != connected.end(); k++) { const NBEdge::Connection& el = *k; if (incoming->mayBeTLSControlled(el.fromLane, el.toEdge, el.toLane)) { if (el.toEdge != 0 && el.toLane >= (int) el.toEdge->getNumLanes()) { throw ProcessError("Connection '" + incoming->getID() + "_" + toString(j) + "->" + el.toEdge->getID() + "_" + toString(el.toLane) + "' yields in a not existing lane."); } if (incoming->getToNode()->getType() != NODETYPE_RAIL_CROSSING || !isRailway(incoming->getPermissions())) { myControlledLinks.push_back(NBConnection(incoming, el.fromLane, el.toEdge, el.toLane, tlIndex++)); } else { myControlledLinks.push_back(NBConnection(incoming, el.fromLane, el.toEdge, el.toLane, -1)); } } } } } }
void NWWriter_DlrNavteq::writeLinksUnsplitted(const OptionsCont& oc, NBEdgeCont& ec, std::map<NBEdge*, std::string>& internalNodes) { std::map<const std::string, std::string> nameIDs; OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_links_unsplitted.txt"); writeHeader(device, oc); // write format specifier device << "# LINK_ID\tNODE_ID_FROM\tNODE_ID_TO\tBETWEEN_NODE_ID\tLENGTH\tVEHICLE_TYPE\tFORM_OF_WAY\tBRUNNEL_TYPE\tFUNCTIONAL_ROAD_CLASS\tSPEED_CATEGORY\tNUMBER_OF_LANES\tSPEED_LIMIT\tSPEED_RESTRICTION\tNAME_ID1_REGIONAL\tNAME_ID2_LOCAL\tHOUSENUMBERS_RIGHT\tHOUSENUMBERS_LEFT\tZIP_CODE\tAREA_ID\tSUBAREA_ID\tTHROUGH_TRAFFIC\tSPECIAL_RESTRICTIONS\tEXTENDED_NUMBER_OF_LANES\tISRAMP\tCONNECTION\n"; // write edges for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) { NBEdge* e = (*i).second; const int kph = speedInKph(e->getSpeed()); const std::string& betweenNodeID = (e->getGeometry().size() > 2) ? internalNodes[e] : UNDEFINED; std::string nameID = UNDEFINED; if (oc.getBool("output.street-names")) { const std::string& name = i->second->getStreetName(); if (name != "") { if (nameIDs.count(name) == 0) { nameIDs[name] = toString(nameIDs.size()); } nameID = nameIDs[name]; } } device << e->getID() << "\t" << e->getFromNode()->getID() << "\t" << e->getToNode()->getID() << "\t" << betweenNodeID << "\t" << getGraphLength(e) << "\t" << getAllowedTypes(e->getPermissions()) << "\t" << getFormOfWay(e) << "\t" << getBrunnelType(e) << "\t" << getRoadClass(e) << "\t" << getSpeedCategory(kph) << "\t" << getNavteqLaneCode(e->getNumLanes()) << "\t" << getSpeedCategoryUpperBound(kph) << "\t" << kph << "\t" << UNDEFINED << "\t" // NAME_ID1_REGIONAL XXX << nameID << "\t" // NAME_ID2_LOCAL << UNDEFINED << "\t" // housenumbers_right << UNDEFINED << "\t" // housenumbers_left << getSinglePostalCode(e->getParameter("postal_code", UNDEFINED), e->getID()) << "\t" // ZIP_CODE << UNDEFINED << "\t" // AREA_ID << UNDEFINED << "\t" // SUBAREA_ID << "1\t" // through_traffic (allowed) << UNDEFINED << "\t" // special_restrictions << UNDEFINED << "\t" // extended_number_of_lanes << UNDEFINED << "\t" // isRamp << "0\t" // connection (between nodes always in order) << "\n"; } if (oc.getBool("output.street-names")) { OutputDevice& namesDevice = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_names.txt"); writeHeader(namesDevice, oc); // write format specifier namesDevice << "# NAME_ID\tPERMANENT_ID_INFO\tName\n"; namesDevice << "# [elements] " << nameIDs.size() << "\n"; for (std::map<const std::string, std::string>::const_iterator i = nameIDs.begin(); i != nameIDs.end(); ++i) { namesDevice << i->second << "\t" << 0 << "\t" << i->first << "\n"; } namesDevice.close(); } device.close(); }