void loadJTRDefinitions(RONet& net, OptionsCont& oc) { // load the turning definitions (and possible sink definition) if (oc.isSet("turn-ratio-files")) { ROJTRTurnDefLoader loader(net); std::vector<std::string> ratio_files = oc.getStringVector("turn-ratio-files"); for (std::vector<std::string>::const_iterator i = ratio_files.begin(); i != ratio_files.end(); ++i) { if (!XMLSubSys::runParser(loader, *i)) { throw ProcessError(); } } } if (MsgHandler::getErrorInstance()->wasInformed() && oc.getBool("ignore-errors")) { MsgHandler::getErrorInstance()->clear(); } // parse sink edges specified at the input/within the configuration if (oc.isSet("sink-edges")) { std::vector<std::string> edges = oc.getStringVector("sink-edges"); for (std::vector<std::string>::const_iterator i = edges.begin(); i != edges.end(); ++i) { ROJTREdge* edge = static_cast<ROJTREdge*>(net.getEdge(*i)); if (edge == 0) { throw ProcessError("The edge '" + *i + "' declared as a sink is not known."); } edge->setSink(); } } }
void NBHeightMapper::loadIfSet(OptionsCont& oc) { if (oc.isSet("heightmap.geotiff")) { // parse file(s) std::vector<std::string> files = oc.getStringVector("heightmap.geotiff"); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { PROGRESS_BEGIN_MESSAGE("Parsing from GeoTIFF '" + *file + "'"); int numFeatures = Singleton.loadTiff(*file); MsgHandler::getMessageInstance()->endProcessMsg( " done (parsed " + toString(numFeatures) + " features, Boundary: " + toString(Singleton.getBoundary()) + ")."); } } if (oc.isSet("heightmap.shapefiles")) { // parse file(s) std::vector<std::string> files = oc.getStringVector("heightmap.shapefiles"); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { PROGRESS_BEGIN_MESSAGE("Parsing from shape-file '" + *file + "'"); int numFeatures = Singleton.loadShapeFile(*file); MsgHandler::getMessageInstance()->endProcessMsg( " done (parsed " + toString(numFeatures) + " features, Boundary: " + toString(Singleton.getBoundary()) + ")."); } } }
void MSFrame::setMSGlobals(OptionsCont& oc) { // pre-initialise the network // set whether empty edges shall be printed on dump MSGlobals::gOmitEmptyEdgesOnDump = !oc.getBool("netstate-dump.empty-edges"); #ifdef HAVE_INTERNAL_LANES // set whether internal lanes shall be used MSGlobals::gUsingInternalLanes = !oc.getBool("no-internal-links"); #else MSGlobals::gUsingInternalLanes = false; #endif // set the grid lock time MSGlobals::gTimeToGridlock = string2time(oc.getString("time-to-teleport")) < 0 ? 0 : string2time(oc.getString("time-to-teleport")); MSGlobals::gCheck4Accidents = !oc.getBool("ignore-accidents"); MSGlobals::gCheckRoutes = !oc.getBool("ignore-route-errors"); #ifdef HAVE_INTERNAL MSGlobals::gStateLoaded = oc.isSet("load-state"); MSGlobals::gUseMesoSim = oc.getBool("mesosim"); MSGlobals::gMesoLimitedJunctionControl = oc.getBool("meso-junction-control.limited"); if (MSGlobals::gUseMesoSim) { MSGlobals::gUsingInternalLanes = false; } #endif #ifdef HAVE_SUBSECOND_TIMESTEPS DELTA_T = string2time(oc.getString("step-length")); #endif if (oc.isSet("routeDist.maxsize")) { MSRoute::setMaxRouteDistSize(oc.getInt("routeDist.maxsize")); } }
// =========================================================================== // method definitions // =========================================================================== void PCLoaderDlrNavteq::loadIfSet(OptionsCont& oc, PCPolyContainer& toFill, PCTypeMap& tm) { if (oc.isSet("dlr-navteq-poly-files")) { loadPolyFiles(oc, toFill, tm); } if (oc.isSet("dlr-navteq-poi-files")) { loadPOIFiles(oc, toFill, tm); } }
/** * loads the net * The net is in this meaning made up by the net itself and the dynamic * weights which may be supplied in a separate file */ void initNet(RONet& net, ROLoader& loader, OptionsCont& oc) { // load the net RODUAEdgeBuilder builder(oc.getBool("weights.expand"), oc.getBool("weights.interpolate")); loader.loadNet(net, builder); // load the weights when wished/available if (oc.isSet("weight-files")) { loader.loadWeights(net, "weight-files", oc.getString("weight-attribute"), false); } if (oc.isSet("lane-weight-files")) { loader.loadWeights(net, "lane-weight-files", oc.getString("weight-attribute"), true); } }
void NBTrafficLightLogicCont::applyOptions(OptionsCont &oc) throw() { // check whether any offsets shall be manipulated by setting // them to half of the duration if (oc.isSet("tl-logics.half-offset")) { myHalfOffsetTLS = oc.getStringVector("tl-logics.half-offset"); } // check whether any offsets shall be manipulated by setting // them to a quarter of the duration if (oc.isSet("tl-logics.quarter-offset")) { myQuarterOffsetTLS = oc.getStringVector("tl-logics.quarter-offset"); } }
void NBTrafficLightLogicCont::applyOptions(OptionsCont& oc) { // check whether any offsets shall be manipulated by setting // them to half of the duration if (oc.isSet("tls.half-offset")) { std::vector<std::string> ids = oc.getStringVector("tls.half-offset"); myHalfOffsetTLS.insert(ids.begin(), ids.end()); } // check whether any offsets shall be manipulated by setting // them to a quarter of the duration if (oc.isSet("tls.quarter-offset")) { std::vector<std::string> ids = oc.getStringVector("tls.quarter-offset"); myHalfOffsetTLS.insert(ids.begin(), ids.end()); } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods // --------------------------------------------------------------------------- void NWWriter_XML::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether plain-output files shall be generated if (oc.isSet("plain-output-prefix")) { writeNodes(oc, nb.getNodeCont()); writeEdgesAndConnections(oc, nb.getNodeCont(), nb.getEdgeCont()); writeTrafficLights(oc, nb.getTLLogicCont(), nb.getEdgeCont()); } if (oc.isSet("junctions.join-output")) { writeJoinedJunctions(oc, nb.getNodeCont()); } if (oc.isSet("street-sign-output")) { writeStreetSigns(oc, nb.getEdgeCont()); } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods // --------------------------------------------------------------------------- void NIImporter_ITSUMO::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether the option is set (properly) if (!oc.isSet("itsumo-files")) { return; } /* Parse file(s) * Each file is parsed twice: first for nodes, second for edges. */ std::vector<std::string> files = oc.getStringVector("itsumo-files"); // load nodes, first Handler Handler(nb); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { // nodes if (!FileHelpers::exists(*file)) { WRITE_ERROR("Could not open itsumo-file '" + *file + "'."); return; } Handler.setFileName(*file); PROGRESS_BEGIN_MESSAGE("Parsing nodes from itsumo-file '" + *file + "'"); if (!XMLSubSys::runParser(Handler, *file)) { return; } PROGRESS_DONE_MESSAGE(); } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods (interface in this case) // --------------------------------------------------------------------------- void NIImporter_RobocupRescue::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether the option is set (properly) if (!oc.isSet("robocup-dir")) { return; } // build the handler NIImporter_RobocupRescue handler(nb.getNodeCont(), nb.getEdgeCont()); // parse file(s) std::vector<std::string> files = oc.getStringVector("robocup-dir"); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { // nodes std::string nodesName = (*file) + "/node.bin"; if (!FileHelpers::exists(nodesName)) { WRITE_ERROR("Could not open robocup-node-file '" + nodesName + "'."); return; } PROGRESS_BEGIN_MESSAGE("Parsing robocup-nodes from '" + nodesName + "'"); handler.loadNodes(nodesName); PROGRESS_DONE_MESSAGE(); // edges std::string edgesName = (*file) + "/road.bin"; if (!FileHelpers::exists(edgesName)) { WRITE_ERROR("Could not open robocup-road-file '" + edgesName + "'."); return; } PROGRESS_BEGIN_MESSAGE("Parsing robocup-roads from '" + edgesName + "'"); handler.loadEdges(edgesName); PROGRESS_DONE_MESSAGE(); } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods // --------------------------------------------------------------------------- void NIImporter_MATSim::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether the option is set (properly) if (!oc.isSet("matsim-files")) { return; } /* Parse file(s) * Each file is parsed twice: first for nodes, second for edges. */ std::vector<std::string> files = oc.getStringVector("matsim-files"); // load nodes, first NodesHandler nodesHandler(nb.getNodeCont()); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { // nodes if (!FileHelpers::isReadable(*file)) { WRITE_ERROR("Could not open matsim-file '" + *file + "'."); return; } nodesHandler.setFileName(*file); PROGRESS_BEGIN_MESSAGE("Parsing nodes from matsim-file '" + *file + "'"); if (!XMLSubSys::runParser(nodesHandler, *file)) { return; } PROGRESS_DONE_MESSAGE(); } // load edges, then EdgesHandler edgesHandler(nb.getNodeCont(), nb.getEdgeCont(), oc.getBool("matsim.keep-length"), oc.getBool("matsim.lanes-from-capacity"), NBCapacity2Lanes(oc.getFloat("lanes-from-capacity.norm"))); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { // edges edgesHandler.setFileName(*file); PROGRESS_BEGIN_MESSAGE("Parsing edges from matsim-file '" + *file + "'"); XMLSubSys::runParser(edgesHandler, *file); PROGRESS_DONE_MESSAGE(); } }
void MSBaseVehicle::initMoveReminderOutput(const OptionsCont& oc) { if (oc.isSet("movereminder-output.vehicles")) { const std::vector<std::string> vehicles = oc.getStringVector("movereminder-output.vehicles"); myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end()); } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods (interface in this case) // --------------------------------------------------------------------------- void NIImporter_ArcView::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) { if (!oc.isSet("shapefile-prefix")) { return; } // check whether the correct set of entries is given // and compute both file names std::string dbf_file = oc.getString("shapefile-prefix") + ".dbf"; std::string shp_file = oc.getString("shapefile-prefix") + ".shp"; std::string shx_file = oc.getString("shapefile-prefix") + ".shx"; // check whether the files do exist if (!FileHelpers::isReadable(dbf_file)) { WRITE_ERROR("File not accessible: " + dbf_file); } if (!FileHelpers::isReadable(shp_file)) { WRITE_ERROR("File not accessible: " + shp_file); } if (!FileHelpers::isReadable(shx_file)) { WRITE_ERROR("File not accessible: " + shx_file); } if (MsgHandler::getErrorInstance()->wasInformed()) { return; } // load the arcview files NIImporter_ArcView loader(oc, nb.getNodeCont(), nb.getEdgeCont(), nb.getTypeCont(), dbf_file, shp_file, oc.getBool("speed-in-kmh")); loader.load(); }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // NBRampsComputer // --------------------------------------------------------------------------- void NBRampsComputer::computeRamps(NBNetBuilder& nb, OptionsCont& oc) { SUMOReal minHighwaySpeed = oc.getFloat("ramps.min-highway-speed"); SUMOReal maxRampSpeed = oc.getFloat("ramps.max-ramp-speed"); SUMOReal rampLength = oc.getFloat("ramps.ramp-length"); bool dontSplit = oc.getBool("ramps.no-split"); std::set<NBEdge*> incremented; // check whether on-off ramps shall be guessed if (oc.getBool("ramps.guess")) { NBNodeCont& nc = nb.getNodeCont(); NBEdgeCont& ec = nb.getEdgeCont(); NBDistrictCont& dc = nb.getDistrictCont(); std::set<NBNode*> potOnRamps; std::set<NBNode*> potOffRamps; for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) { NBNode* cur = (*i).second; if (mayNeedOnRamp(cur, minHighwaySpeed, maxRampSpeed)) { potOnRamps.insert(cur); } if (mayNeedOffRamp(cur, minHighwaySpeed, maxRampSpeed)) { potOffRamps.insert(cur); } } for (std::set<NBNode*>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) { buildOnRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented); } for (std::set<NBNode*>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) { buildOffRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented); } } // check whether on-off ramps shall be guessed if (oc.isSet("ramps.set")) { std::vector<std::string> edges = oc.getStringVector("ramps.set"); NBNodeCont& nc = nb.getNodeCont(); NBEdgeCont& ec = nb.getEdgeCont(); NBDistrictCont& dc = nb.getDistrictCont(); for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) { NBEdge* e = ec.retrieve(*i); if (e == 0) { WRITE_WARNING("Can not build on ramp on edge '" + *i + "' - the edge is not known."); continue; } NBNode* from = e->getFromNode(); if (from->getIncomingEdges().size() == 2 && from->getOutgoingEdges().size() == 1) { buildOnRamp(from, nc, ec, dc, rampLength, dontSplit, incremented); } // load edge again to check offramps e = ec.retrieve(*i); if (e == 0) { WRITE_WARNING("Can not build off ramp on edge '" + *i + "' - the edge is not known."); continue; } NBNode* to = e->getToNode(); if (to->getIncomingEdges().size() == 1 && to->getOutgoingEdges().size() == 2) { buildOffRamp(to, nc, ec, dc, rampLength, dontSplit, incremented); } } } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods (interface in this case) // --------------------------------------------------------------------------- void NIImporter_Vissim::loadNetwork(const OptionsCont &oc, NBNetBuilder &nb) { if (!oc.isSet("vissim")) { return; } // load the visum network NIImporter_Vissim loader(nb, oc.getString("vissim")); loader.load(oc); }
// --------------------------------------------------------------------------- // static methods // --------------------------------------------------------------------------- void NWWriter_DlrNavteq::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether a matsim-file shall be generated if (!oc.isSet("dlr-navteq-output")) { return; } writeNodesUnsplitted(oc, nb.getNodeCont(), nb.getEdgeCont()); writeLinksUnsplitted(oc, nb.getEdgeCont()); }
/** * loads the net * The net is in this meaning made up by the net itself and the dynamic * weights which may be supplied in a separate file */ void initNet(RONet &net, ROLoader &loader, OptionsCont &oc, const std::vector<SUMOReal> &turnDefs) { // load the net ROJTREdgeBuilder builder; loader.loadNet(net, builder); // set the turn defaults const std::map<std::string, ROEdge*> &edges = net.getEdgeMap(); for (std::map<std::string, ROEdge*>::const_iterator i=edges.begin(); i!=edges.end(); ++i) { static_cast<ROJTREdge*>((*i).second)->setTurnDefaults(turnDefs); } // load the weights when wished/available if (oc.isSet("weights")) { loader.loadWeights(net, "weights", oc.getString("measure"), false); } if (oc.isSet("lane-weights")) { loader.loadWeights(net, "lane-weights", oc.getString("measure"), true); } }
void MSFrame::setMSGlobals(OptionsCont& oc) { // pre-initialise the network // set whether empty edges shall be printed on dump MSGlobals::gOmitEmptyEdgesOnDump = !oc.getBool("netstate-dump.empty-edges"); #ifdef HAVE_INTERNAL_LANES // set whether internal lanes shall be used MSGlobals::gUsingInternalLanes = !oc.getBool("no-internal-links"); MSGlobals::gIgnoreJunctionBlocker = string2time(oc.getString("ignore-junction-blocker")) < 0 ? std::numeric_limits<SUMOTime>::max() : string2time(oc.getString("ignore-junction-blocker")); #else MSGlobals::gUsingInternalLanes = false; MSGlobals::gIgnoreJunctionBlocker = 0; #endif // set the grid lock time MSGlobals::gTimeToGridlock = string2time(oc.getString("time-to-teleport")) < 0 ? 0 : string2time(oc.getString("time-to-teleport")); MSGlobals::gTimeToGridlockHighways = string2time(oc.getString("time-to-teleport.highways")) < 0 ? 0 : string2time(oc.getString("time-to-teleport.highways")); MSGlobals::gCheck4Accidents = !oc.getBool("ignore-accidents"); MSGlobals::gCheckRoutes = !oc.getBool("ignore-route-errors"); MSGlobals::gLaneChangeDuration = string2time(oc.getString("lanechange.duration")); MSGlobals::gLateralResolution = oc.getFloat("lateral-resolution"); MSGlobals::gStateLoaded = oc.isSet("load-state"); MSGlobals::gUseMesoSim = oc.getBool("mesosim"); MSGlobals::gMesoLimitedJunctionControl = oc.getBool("meso-junction-control.limited"); MSGlobals::gMesoOvertaking = oc.getBool("meso-overtaking"); MSGlobals::gMesoTLSPenalty = oc.getFloat("meso-tls-penalty"); if (MSGlobals::gUseMesoSim) { MSGlobals::gUsingInternalLanes = false; } MSGlobals::gWaitingTimeMemory = string2time(oc.getString("waiting-time-memory")); MSAbstractLaneChangeModel::initGlobalOptions(oc); MSLane::initCollisionOptions(oc); DELTA_T = string2time(oc.getString("step-length")); #ifdef _DEBUG if (oc.isSet("movereminder-output")) { MSBaseVehicle::initMoveReminderOutput(oc); } #endif }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods (interface in this case) // --------------------------------------------------------------------------- void NIImporter_VISUM::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether the option is set (properly) if (!oc.isSet("visum-file")) { return; } // build the handler NIImporter_VISUM loader(nb, oc.getString("visum-file"), NBCapacity2Lanes(oc.getFloat("lanes-from-capacity.norm")), oc.getBool("visum.use-type-priority")); loader.load(); }
// --------------------------------------------------------------------------- // static methods // --------------------------------------------------------------------------- void NWWriter_DlrNavteq::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether a matsim-file shall be generated if (!oc.isSet("dlr-navteq-output")) { return; } std::map<NBEdge*, std::string> internalNodes; writeNodesUnsplitted(oc, nb.getNodeCont(), nb.getEdgeCont(), internalNodes); writeLinksUnsplitted(oc, nb.getEdgeCont(), internalNodes); writeTrafficSignals(oc, nb.getNodeCont()); writeProhibitedManoeuvres(oc, nb.getNodeCont(), nb.getEdgeCont()); writeConnectedLanes(oc, nb.getNodeCont()); }
// =========================================================================== // method definitions // =========================================================================== void PCLoaderArcView::loadIfSet(OptionsCont& oc, PCPolyContainer& toFill, PCTypeMap& tm) { if (!oc.isSet("shapefile-prefixes")) { return; } // parse file(s) std::vector<std::string> files = oc.getStringVector("shapefile-prefixes"); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { PROGRESS_BEGIN_MESSAGE("Parsing from shape-file '" + *file + "'"); load(*file, oc, toFill, tm); PROGRESS_DONE_MESSAGE(); } }
void NWFrame::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) { NWWriter_SUMO::writeNetwork(oc, nb); NWWriter_MATSim::writeNetwork(oc, nb); NWWriter_OpenDrive::writeNetwork(oc, nb); NWWriter_DlrNavteq::writeNetwork(oc, nb); NWWriter_XML::writeNetwork(oc, nb); // save the mapping information when wished if (oc.isSet("map-output")) { OutputDevice& mdevice = OutputDevice::getDevice(oc.getString("map-output")); mdevice << nb.getJoinedEdgesMap(); mdevice.close(); } }
bool ROFrame::checkOptions(OptionsCont& oc) { // check whether the output is valid and can be build if (!oc.isSet("output-file")) { WRITE_ERROR("No output specified."); return false; } // if (oc.getInt("max-alternatives") < 2) { WRITE_ERROR("At least two alternatives should be enabled"); return false; } return true; }
bool ROFrame::checkOptions(OptionsCont &oc) { // check whether the output is valid and can be build if (!oc.isSet("output")) { MsgHandler::getErrorInstance()->inform("No output specified."); return false; } // if (oc.getInt("max-alternatives")<2) { MsgHandler::getErrorInstance()->inform("At least two alternatives should be enabled"); return false; } // check departure/arrival options return true; }
// =========================================================================== // method definitions // =========================================================================== void PCLoaderVisum::loadIfSet(OptionsCont& oc, PCPolyContainer& toFill, PCTypeMap& tm) { if (!oc.isSet("visum-files")) { return; } // parse file(s) std::vector<std::string> files = oc.getStringVector("visum-files"); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { if (!FileHelpers::exists(*file)) { throw ProcessError("Could not open visum-file '" + *file + "'."); } PROGRESS_BEGIN_MESSAGE("Parsing from visum-file '" + *file + "'"); load(*file, oc, toFill, tm); PROGRESS_DONE_MESSAGE(); } }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static interface // --------------------------------------------------------------------------- void PCLoaderXML::loadIfSet(OptionsCont& oc, PCPolyContainer& toFill, PCTypeMap& tm) { if (!oc.isSet("xml-files")) { return; } PCLoaderXML handler(toFill, tm, oc); // parse file(s) std::vector<std::string> files = oc.getStringVector("xml"); for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) { if (!FileHelpers::isReadable(*file)) { throw ProcessError("Could not open xml-file '" + *file + "'."); } PROGRESS_BEGIN_MESSAGE("Parsing XML from '" + *file + "'"); if (!XMLSubSys::runParser(handler, *file)) { throw ProcessError(); } PROGRESS_DONE_MESSAGE(); } }
void readDetectorFlows(RODFDetectorFlows& flows, OptionsCont& oc, RODFDetectorCon& dc) { if (!oc.isSet("measure-files")) { // ok, not given, return an empty container return; } // check whether the file exists std::vector<std::string> files = oc.getStringVector("measure-files"); for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (!FileHelpers::exists(*fileIt)) { throw ProcessError("The measure-file '" + *fileIt + "' can not be opened."); } // parse PROGRESS_BEGIN_MESSAGE("Loading flows from '" + *fileIt + "'"); RODFDetFlowLoader dfl(dc, flows, string2time(oc.getString("begin")), string2time(oc.getString("end")), string2time(oc.getString("time-offset")), string2time(oc.getString("time-factor"))); dfl.read(*fileIt); PROGRESS_DONE_MESSAGE(); } }
bool ROFrame::checkOptions(OptionsCont& oc) { // check whether the output is valid and can be build if (!oc.isSet("output-file")) { WRITE_ERROR("No output specified."); return false; } // if (oc.getInt("max-alternatives") < 2) { WRITE_ERROR("At least two alternatives should be enabled."); return false; } #ifndef HAVE_FOX if (oc.getInt("routing-threads") > 1) { WRITE_ERROR("Parallel routing is only possible when compiled with Fox."); return false; } #endif return true; }
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(); }
// =========================================================================== // method definitions // =========================================================================== // --------------------------------------------------------------------------- // static methods // --------------------------------------------------------------------------- void NWWriter_MATSim::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) { // check whether a matsim-file shall be generated if (!oc.isSet("matsim-output")) { return; } OutputDevice& device = OutputDevice::getDevice(oc.getString("matsim-output")); device << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; device << "<!DOCTYPE network SYSTEM \"http://www.matsim.org/files/dtd/network_v1.dtd\">\n\n"; device << "<network name=\"NAME\">\n"; // !!! name // write nodes device << " <nodes>\n"; NBNodeCont& nc = nb.getNodeCont(); for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) { device << " <node id=\"" << (*i).first << "\" x=\"" << (*i).second->getPosition().x() << "\" y=\"" << (*i).second->getPosition().y() << "\"/>\n"; } device << " </nodes>\n"; // write edges device << " <links capperiod=\"01:00:00\">\n"; NBEdgeCont& ec = nb.getEdgeCont(); for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) { device << " <link id=\"" << (*i).first << "\" from=\"" << (*i).second->getFromNode()->getID() << "\" to=\"" << (*i).second->getToNode()->getID() << "\" length=\"" << (*i).second->getLoadedLength() << "\" capacity=\"" << (oc.getFloat("lanes-from-capacity.norm") * (*i).second->getNumLanes()) << "\" freespeed=\"" << (*i).second->getSpeed() << "\" permlanes=\"" << (*i).second->getNumLanes() << "\"/>\n"; } device << " </links>\n"; // device << "</network>\n"; // !!! name device.close(); }