本文整理汇总了C++中OptionsCont::getInt方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionsCont::getInt方法的具体用法?C++ OptionsCont::getInt怎么用?C++ OptionsCont::getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionsCont
的用法示例。
在下文中一共展示了OptionsCont::getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkFlows
SUMOTime
RONet::saveAndRemoveRoutesUntil(OptionsCont& options, SUMOAbstractRouter<ROEdge, ROVehicle>& router,
SUMOTime time) {
checkFlows(time);
SUMOTime lastTime = -1;
// write all vehicles (and additional structures)
while (myVehicles.size() != 0 || myPersons.size() != 0) {
// get the next vehicle and person
const ROVehicle* const veh = myVehicles.getTopVehicle();
const SUMOTime vehicleTime = veh == 0 ? SUMOTime_MAX : veh->getDepartureTime();
PersonMap::iterator person = myPersons.begin();
const SUMOTime personTime = person == myPersons.end() ? SUMOTime_MAX : person->first;
// check whether it shall not yet be computed
if (vehicleTime > time && personTime > time) {
lastTime = MIN2(vehicleTime, personTime);
break;
}
if (vehicleTime < personTime) {
// check whether to print the output
if (lastTime != vehicleTime && lastTime != -1) {
// report writing progress
if (options.getInt("stats-period") >= 0 && ((int) vehicleTime % options.getInt("stats-period")) == 0) {
WRITE_MESSAGE("Read: " + toString(myReadRouteNo) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
}
}
lastTime = vehicleTime;
// ok, compute the route (try it)
if (computeRoute(options, router, veh)) {
// write the route
veh->saveAllAsXML(*myRoutesOutput, myRouteAlternativesOutput, myTypesOutput, options.getBool("exit-times"));
myWrittenRouteNo++;
} else {
myDiscardedRouteNo++;
}
// delete routes and the vehicle
if (veh->getRouteDefinition()->getID()[0] == '!') {
if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
delete veh->getRouteDefinition();
}
}
myVehicles.erase(veh->getID());
} else {
myRoutesOutput->writePreformattedTag(person->second);
if (myRouteAlternativesOutput != 0) {
myRouteAlternativesOutput->writePreformattedTag(person->second);
}
myPersons.erase(person);
}
}
return lastTime;
}
示例2:
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"));
}
}
示例3: writeHeader
void
NWWriter_DlrNavteq::writeTrafficSignals(const OptionsCont& oc, NBNodeCont& nc) {
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_traffic_signals.txt");
writeHeader(device, oc);
const GeoConvHelper& gch = GeoConvHelper::getFinal();
const bool haveGeo = gch.usingGeoProjection();
const double geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE
device.setPrecision(oc.getInt("dlr-navteq.precision"));
// write format specifier
device << "#Traffic signal related to LINK_ID and NODE_ID with location relative to driving direction.\n#column format like pointcollection.\n#DESCRIPTION->LOCATION: 1-rechts von LINK; 2-links von LINK; 3-oberhalb LINK -1-keineAngabe\n#RELATREC_ID\tPOICOL_TYPE\tDESCRIPTION\tLONGITUDE\tLATITUDE\tLINK_ID\n";
// write record for every edge incoming to a tls controlled node
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
if (n->isTLControlled()) {
Position pos = n->getPosition();
gch.cartesian2geo(pos);
pos.mul(geoScale);
const EdgeVector& incoming = n->getIncomingEdges();
for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
NBEdge* e = *it;
device << e->getID() << "\t"
<< "12\t" // POICOL_TYPE
<< "LSA;NODEIDS#" << n->getID() << "#;LOCATION#-1#;\t"
<< pos.x() << "\t"
<< pos.y() << "\t"
<< e->getID() << "\n";
}
}
}
device.close();
}
示例4:
// ===========================================================================
// method definitions
// ===========================================================================
PCTypeMap::PCTypeMap(const OptionsCont& oc) {
myDefaultType.id = oc.getString("type");
myDefaultType.color = RGBColor::parseColor(oc.getString("color"));
myDefaultType.layer = oc.getInt("layer");
myDefaultType.discard = oc.getBool("discard");
myDefaultType.allowFill = true;
myDefaultType.prefix = oc.getString("prefix");
}
示例5:
void
NBNetBuilder::applyOptions(OptionsCont& oc) {
// apply options to type control
myTypeCont.setDefaults(oc.getInt("default.lanenumber"), oc.getFloat("default.lanewidth"), oc.getFloat("default.speed"), oc.getInt("default.priority"));
// apply options to edge control
myEdgeCont.applyOptions(oc);
// apply options to traffic light logics control
myTLLCont.applyOptions(oc);
}
示例6:
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;
}
示例7:
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;
}
示例8:
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;
}
示例9: Position
bool
GeoConvHelper::init(OptionsCont& oc) {
std::string proj = "!"; // the default
int shift = oc.getInt("proj.scale");
Position offset = Position(oc.getFloat("offset.x"), oc.getFloat("offset.y"));
bool inverse = oc.exists("proj.inverse") && oc.getBool("proj.inverse");
if (oc.getBool("simple-projection")) {
proj = "-";
}
#ifdef HAVE_PROJ
if (oc.getBool("proj.inverse") && oc.getString("proj") == "!") {
WRITE_ERROR("Inverse projection works only with explicit proj parameters.");
return false;
}
unsigned numProjections = oc.getBool("simple-projection") + oc.getBool("proj.utm") + oc.getBool("proj.dhdn") + oc.getBool("proj.dhdnutm") + (oc.getString("proj").length() > 1);
if (numProjections > 1) {
WRITE_ERROR("The projection method needs to be uniquely defined.");
return false;
}
if (oc.getBool("proj.utm")) {
proj = "UTM";
} else if (oc.getBool("proj.dhdn")) {
proj = "DHDN";
} else if (oc.getBool("proj.dhdnutm")) {
proj = "DHDN_UTM";
} else if (!oc.isDefault("proj")) {
proj = oc.getString("proj");
}
#endif
myProcessing = GeoConvHelper(proj, offset, Boundary(), Boundary(), shift, inverse);
myFinal = myProcessing;
return true;
}
示例10: min
void
NWWriter_DlrNavteq::writeNodesUnsplitted(const OptionsCont& oc, NBNodeCont& nc, NBEdgeCont& ec, std::map<NBEdge*, std::string>& internalNodes) {
// For "real" nodes we simply use the node id.
// For internal nodes (geometry vectors describing edge geometry in the parlance of this format)
// we use the id of the edge and do not bother with
// compression (each direction gets its own internal node).
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_nodes_unsplitted.txt");
writeHeader(device, oc);
const GeoConvHelper& gch = GeoConvHelper::getFinal();
const bool haveGeo = gch.usingGeoProjection();
const double geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE
device.setPrecision(oc.getInt("dlr-navteq.precision"));
if (!haveGeo) {
WRITE_WARNING("DlrNavteq node data will be written in (floating point) cartesian coordinates");
}
// write format specifier
device << "# NODE_ID\tIS_BETWEEN_NODE\tamount_of_geocoordinates\tx1\ty1\t[x2 y2 ... xn yn]\n";
// write header
Boundary boundary = gch.getConvBoundary();
Position min(boundary.xmin(), boundary.ymin());
Position max(boundary.xmax(), boundary.ymax());
gch.cartesian2geo(min);
min.mul(geoScale);
gch.cartesian2geo(max);
max.mul(geoScale);
int multinodes = 0;
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
if ((*i).second->getGeometry().size() > 2) {
multinodes++;
}
}
device << "# [xmin_region] " << min.x() << "\n";
device << "# [xmax_region] " << max.x() << "\n";
device << "# [ymin_region] " << min.y() << "\n";
device << "# [ymax_region] " << max.y() << "\n";
device << "# [elements_multinode] " << multinodes << "\n";
device << "# [elements_normalnode] " << nc.size() << "\n";
device << "# [xmin] " << min.x() << "\n";
device << "# [xmax] " << max.x() << "\n";
device << "# [ymin] " << min.y() << "\n";
device << "# [ymax] " << max.y() << "\n";
// write normal nodes
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
Position pos = n->getPosition();
gch.cartesian2geo(pos);
pos.mul(geoScale);
device << n->getID() << "\t0\t1\t" << pos.x() << "\t" << pos.y() << "\n";
}
// write "internal" nodes
std::vector<std::string> avoid;
std::set<std::string> reservedNodeIDs;
const bool numericalIDs = oc.getBool("numerical-ids");
if (oc.isSet("reserved-ids")) {
NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "node:", reservedNodeIDs); // backward compatibility
NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "junction:", reservedNodeIDs); // selection format
}
if (numericalIDs) {
avoid = nc.getAllNames();
std::vector<std::string> avoid2 = ec.getAllNames();
avoid.insert(avoid.end(), avoid2.begin(), avoid2.end());
avoid.insert(avoid.end(), reservedNodeIDs.begin(), reservedNodeIDs.end());
}
IDSupplier idSupplier("", avoid);
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
NBEdge* e = (*i).second;
PositionVector geom = e->getGeometry();
if (geom.size() > 2) {
// the import NIImporter_DlrNavteq checks for the presence of a
// negated edge id to determine spread type. We may need to do some
// shifting to make this consistent
const bool hasOppositeID = ec.getOppositeByID(e->getID()) != nullptr;
if (e->getLaneSpreadFunction() == LANESPREAD_RIGHT && !hasOppositeID) {
// need to write center-line geometry instead
try {
geom.move2side(e->getTotalWidth() / 2);
} catch (InvalidArgument& exception) {
WRITE_WARNING("Could not reconstruct shape for edge:'" + e->getID() + "' (" + exception.what() + ").");
}
} else if (e->getLaneSpreadFunction() == LANESPREAD_CENTER && hasOppositeID) {
// need to write left-border geometry instead
try {
geom.move2side(-e->getTotalWidth() / 2);
} catch (InvalidArgument& exception) {
WRITE_WARNING("Could not reconstruct shape for edge:'" + e->getID() + "' (" + exception.what() + ").");
}
}
std::string internalNodeID = e->getID();
if (internalNodeID == UNDEFINED
|| (nc.retrieve(internalNodeID) != nullptr)
|| reservedNodeIDs.count(internalNodeID) > 0
) {
// need to invent a new name to avoid clashing with the id of a 'real' node or a reserved name
if (numericalIDs) {
internalNodeID = idSupplier.getNext();
} else {
internalNodeID += "_geometry";
}
}
//.........这里部分代码省略.........
示例11: defaultVehicle
/**
* Computes the routes saving them
*/
void
computeRoutes(RONet& net, ROLoader& loader, OptionsCont& oc) {
// initialise the loader
loader.openRoutes(net);
// build the router
auto ttFunction = gWeightsRandomFactor > 1 ? &ROEdge::getTravelTimeStaticRandomized : &ROEdge::getTravelTimeStatic;
SUMOAbstractRouter<ROEdge, ROVehicle>* router;
const std::string measure = oc.getString("weight-attribute");
const std::string routingAlgorithm = oc.getString("routing-algorithm");
const SUMOTime begin = string2time(oc.getString("begin"));
const SUMOTime end = string2time(oc.getString("end"));
if (measure == "traveltime") {
if (routingAlgorithm == "dijkstra") {
if (net.hasPermissions()) {
router = new DijkstraRouter<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> >(
ROEdge::getAllEdges(), oc.getBool("ignore-errors"), ttFunction);
} else {
router = new DijkstraRouter<ROEdge, ROVehicle, SUMOAbstractRouter<ROEdge, ROVehicle> >(
ROEdge::getAllEdges(), oc.getBool("ignore-errors"), ttFunction);
}
} else if (routingAlgorithm == "astar") {
if (net.hasPermissions()) {
typedef AStarRouter<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> > AStar;
std::shared_ptr<const AStar::LookupTable> lookup;
if (oc.isSet("astar.all-distances")) {
lookup = std::make_shared<const AStar::FLT>(oc.getString("astar.all-distances"), (int)ROEdge::getAllEdges().size());
} else if (oc.isSet("astar.landmark-distances")) {
CHRouterWrapper<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> > router(
ROEdge::getAllEdges(), true, &ROEdge::getTravelTimeStatic,
begin, end, std::numeric_limits<int>::max(), 1);
ROVehicle defaultVehicle(SUMOVehicleParameter(), nullptr, net.getVehicleTypeSecure(DEFAULT_VTYPE_ID), &net);
lookup = std::make_shared<const AStar::LMLT>(oc.getString("astar.landmark-distances"), ROEdge::getAllEdges(), &router, &defaultVehicle,
oc.isSet("astar.save-landmark-distances") ? oc.getString("astar.save-landmark-distances") : "", oc.getInt("routing-threads"));
}
router = new AStar(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), ttFunction, lookup);
} else {
typedef AStarRouter<ROEdge, ROVehicle, SUMOAbstractRouter<ROEdge, ROVehicle> > AStar;
std::shared_ptr<const AStar::LookupTable> lookup;
if (oc.isSet("astar.all-distances")) {
lookup = std::make_shared<const AStar::FLT>(oc.getString("astar.all-distances"), (int)ROEdge::getAllEdges().size());
} else if (oc.isSet("astar.landmark-distances")) {
CHRouterWrapper<ROEdge, ROVehicle, SUMOAbstractRouter<ROEdge, ROVehicle> > router(
ROEdge::getAllEdges(), true, &ROEdge::getTravelTimeStatic,
begin, end, std::numeric_limits<int>::max(), 1);
ROVehicle defaultVehicle(SUMOVehicleParameter(), nullptr, net.getVehicleTypeSecure(DEFAULT_VTYPE_ID), &net);
lookup = std::make_shared<const AStar::LMLT>(oc.getString("astar.landmark-distances"), ROEdge::getAllEdges(), &router, &defaultVehicle,
oc.isSet("astar.save-landmark-distances") ? oc.getString("astar.save-landmark-distances") : "", oc.getInt("routing-threads"));
}
router = new AStar(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), ttFunction, lookup);
}
} else if (routingAlgorithm == "CH") {
const SUMOTime weightPeriod = (oc.isSet("weight-files") ?
string2time(oc.getString("weight-period")) :
std::numeric_limits<int>::max());
if (net.hasPermissions()) {
router = new CHRouter<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> >(
ROEdge::getAllEdges(), oc.getBool("ignore-errors"), &ROEdge::getTravelTimeStatic, SVC_IGNORING, weightPeriod, true);
} else {
router = new CHRouter<ROEdge, ROVehicle, SUMOAbstractRouter<ROEdge, ROVehicle> >(
ROEdge::getAllEdges(), oc.getBool("ignore-errors"), &ROEdge::getTravelTimeStatic, SVC_IGNORING, weightPeriod, false);
}
} else if (routingAlgorithm == "CHWrapper") {
const SUMOTime weightPeriod = (oc.isSet("weight-files") ?
string2time(oc.getString("weight-period")) :
std::numeric_limits<int>::max());
router = new CHRouterWrapper<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> >(
ROEdge::getAllEdges(), oc.getBool("ignore-errors"), &ROEdge::getTravelTimeStatic,
begin, end, weightPeriod, oc.getInt("routing-threads"));
} else {
throw ProcessError("Unknown routing Algorithm '" + routingAlgorithm + "'!");
}
} else {
DijkstraRouter<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> >::Operation op;
if (measure == "CO") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
} else if (measure == "CO2") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
} else if (measure == "PMx") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
} else if (measure == "HC") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
} else if (measure == "NOx") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
} else if (measure == "fuel") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
} else if (measure == "electricity") {
op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
} else if (measure == "noise") {
op = &ROEdge::getNoiseEffort;
} else {
throw ProcessError("Unknown measure (weight attribute '" + measure + "')!");
}
if (net.hasPermissions()) {
router = new DijkstraRouter<ROEdge, ROVehicle, SUMOAbstractRouterPermissions<ROEdge, ROVehicle> >(
ROEdge::getAllEdges(), oc.getBool("ignore-errors"), op, ttFunction);
} else {
router = new DijkstraRouter<ROEdge, ROVehicle, SUMOAbstractRouter<ROEdge, ROVehicle> >(
//.........这里部分代码省略.........
示例12: ProcessError
void
PCLoaderArcView::load(const std::string& file, OptionsCont& oc, PCPolyContainer& toFill,
PCTypeMap&) {
#ifdef HAVE_GDAL
GeoConvHelper& geoConvHelper = GeoConvHelper::getProcessing();
// get defaults
std::string prefix = oc.getString("prefix");
std::string type = oc.getString("type");
RGBColor color = RGBColor::parseColor(oc.getString("color"));
int layer = oc.getInt("layer");
std::string idField = oc.getString("shapefile.id-column");
bool useRunningID = oc.getBool("shapefile.use-running-id");
// start parsing
std::string shpName = file + ".shp";
OGRRegisterAll();
OGRDataSource* poDS = OGRSFDriverRegistrar::Open(shpName.c_str(), FALSE);
if (poDS == NULL) {
throw ProcessError("Could not open shape description '" + shpName + "'.");
}
// begin file parsing
OGRLayer* poLayer = poDS->GetLayer(0);
poLayer->ResetReading();
// build coordinate transformation
OGRSpatialReference* origTransf = poLayer->GetSpatialRef();
OGRSpatialReference destTransf;
// use wgs84 as destination
destTransf.SetWellKnownGeogCS("WGS84");
OGRCoordinateTransformation* poCT = OGRCreateCoordinateTransformation(origTransf, &destTransf);
if (poCT == NULL) {
if (oc.isSet("shapefile.guess-projection")) {
OGRSpatialReference origTransf2;
origTransf2.SetWellKnownGeogCS("WGS84");
poCT = OGRCreateCoordinateTransformation(&origTransf2, &destTransf);
}
if (poCT == 0) {
WRITE_WARNING("Could not create geocoordinates converter; check whether proj.4 is installed.");
}
}
OGRFeature* poFeature;
poLayer->ResetReading();
unsigned int runningID = 0;
while ((poFeature = poLayer->GetNextFeature()) != NULL) {
// read in edge attributes
std::string id = useRunningID ? toString(runningID) : poFeature->GetFieldAsString(idField.c_str());
++runningID;
id = StringUtils::prune(id);
if (id == "") {
throw ProcessError("Missing id under '" + idField + "'");
}
id = prefix + id;
// read in the geometry
OGRGeometry* poGeometry = poFeature->GetGeometryRef();
if (poGeometry == 0) {
OGRFeature::DestroyFeature(poFeature);
continue;
}
// try transform to wgs84
poGeometry->transform(poCT);
OGRwkbGeometryType gtype = poGeometry->getGeometryType();
switch (gtype) {
case wkbPoint: {
OGRPoint* cgeom = (OGRPoint*) poGeometry;
Position pos((SUMOReal) cgeom->getX(), (SUMOReal) cgeom->getY());
if (!geoConvHelper.x2cartesian(pos)) {
WRITE_ERROR("Unable to project coordinates for POI '" + id + "'.");
}
PointOfInterest* poi = new PointOfInterest(id, type, color, pos, (SUMOReal)layer);
if (!toFill.insert(id, poi, layer)) {
WRITE_ERROR("POI '" + id + "' could not be added.");
delete poi;
}
}
break;
case wkbLineString: {
OGRLineString* cgeom = (OGRLineString*) poGeometry;
PositionVector shape;
for (int j = 0; j < cgeom->getNumPoints(); j++) {
Position pos((SUMOReal) cgeom->getX(j), (SUMOReal) cgeom->getY(j));
if (!geoConvHelper.x2cartesian(pos)) {
WRITE_ERROR("Unable to project coordinates for polygon '" + id + "'.");
}
shape.push_back_noDoublePos(pos);
}
Polygon* poly = new Polygon(id, type, color, shape, false, (SUMOReal)layer);
if (!toFill.insert(id, poly, layer)) {
WRITE_ERROR("Polygon '" + id + "' could not be added.");
delete poly;
}
}
break;
case wkbPolygon: {
OGRLinearRing* cgeom = ((OGRPolygon*) poGeometry)->getExteriorRing();
PositionVector shape;
for (int j = 0; j < cgeom->getNumPoints(); j++) {
Position pos((SUMOReal) cgeom->getX(j), (SUMOReal) cgeom->getY(j));
if (!geoConvHelper.x2cartesian(pos)) {
WRITE_ERROR("Unable to project coordinates for polygon '" + id + "'.");
//.........这里部分代码省略.........
示例13: lr
void
PCLoaderDlrNavteq::loadPolyFile(const std::string& file,
OptionsCont& oc, PCPolyContainer& toFill,
PCTypeMap& tm) {
// get the defaults
RGBColor c = RGBColor::parseColor(oc.getString("color"));
// attributes of the poly
// parse
int l = 0;
LineReader lr(file);
while (lr.hasMore()) {
std::string line = lr.readLine();
++l;
// skip invalid/empty lines
if (line.length() == 0 || line.find("#") != std::string::npos) {
continue;
}
if (StringUtils::prune(line) == "") {
continue;
}
// parse the poi
StringTokenizer st(line, "\t");
std::vector<std::string> values = st.getVector();
if (values.size() < 6 || values.size() % 2 != 0) {
throw ProcessError("Invalid dlr-navteq-polygon - line: '" + line + "'.");
}
std::string id = values[0];
std::string ort = values[1];
std::string type = values[2];
std::string name = values[3];
PositionVector vec;
size_t index = 4;
// now collect the positions
while (values.size() > index) {
std::string xpos = values[index];
std::string ypos = values[index + 1];
index += 2;
SUMOReal x = TplConvert::_2SUMOReal(xpos.c_str());
SUMOReal y = TplConvert::_2SUMOReal(ypos.c_str());
Position pos(x, y);
if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
WRITE_WARNING("Unable to project coordinates for polygon '" + id + "'.");
}
vec.push_back(pos);
}
name = StringUtils::convertUmlaute(name);
if (name == "noname" || toFill.containsPolygon(name)) {
name = name + "#" + toString(toFill.getEnumIDFor(name));
}
// check the polygon
if (vec.size() == 0) {
WRITE_WARNING("The polygon '" + id + "' is empty.");
continue;
}
if (id == "") {
WRITE_WARNING("The name of a polygon is missing; it will be discarded.");
continue;
}
// patch the values
bool fill = vec.front() == vec.back();
bool discard = oc.getBool("discard");
int layer = oc.getInt("layer");
RGBColor color;
if (tm.has(type)) {
const PCTypeMap::TypeDef& def = tm.get(type);
name = def.prefix + name;
type = def.id;
color = def.color;
fill = fill && def.allowFill;
discard = def.discard;
layer = def.layer;
} else {
name = oc.getString("prefix") + name;
type = oc.getString("type");
color = c;
}
if (!discard) {
Polygon* poly = new Polygon(name, type, color, vec, fill, (SUMOReal)layer);
toFill.insert(name, poly, layer);
}
vec.clear();
}
}
示例14: toString
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods
// ---------------------------------------------------------------------------
void
NWWriter_SUMO::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
// check whether a sumo net-file shall be generated
if (!oc.isSet("output-file")) {
return;
}
OutputDevice& device = OutputDevice::getDevice(oc.getString("output-file"));
const std::string lefthand = oc.getBool("lefthand") ? " " + toString(SUMO_ATTR_LEFTHAND) + "=\"true\"" : "";
const int cornerDetail = oc.getInt("junctions.corner-detail");
const int linkDetail = oc.getInt("junctions.internal-link-detail");
const std::string junctionCornerDetail = (cornerDetail > 0
? " " + toString(SUMO_ATTR_CORNERDETAIL) + "=\"" + toString(cornerDetail) + "\"" : "");
const std::string junctionLinkDetail = (oc.isDefault("junctions.internal-link-detail") ? "" :
" " + toString(SUMO_ATTR_LINKDETAIL) + "=\"" + toString(linkDetail) + "\"");
device.writeXMLHeader("net", NWFrame::MAJOR_VERSION + lefthand + junctionCornerDetail + junctionLinkDetail +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/net_file.xsd\""); // street names may contain non-ascii chars
device.lf();
// get involved container
const NBNodeCont& nc = nb.getNodeCont();
const NBEdgeCont& ec = nb.getEdgeCont();
const NBDistrictCont& dc = nb.getDistrictCont();
// write network offsets and projection
GeoConvHelper::writeLocation(device);
// write edge types and restrictions
nb.getTypeCont().writeTypes(device);
// write inner lanes
bool origNames = oc.getBool("output.original-names");
if (!oc.getBool("no-internal-links")) {
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalEdges(device, *(*i).second, origNames);
}
if (hadAny) {
device.lf();
}
}
// write edges with lanes and connected edges
bool noNames = !oc.getBool("output.street-names");
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
writeEdge(device, *(*i).second, noNames, origNames);
}
device.lf();
// write tls logics
writeTrafficLights(device, nb.getTLLogicCont());
// write the nodes (junctions)
std::set<NBNode*> roundaboutNodes;
const bool checkLaneFoesAll = oc.getBool("check-lane-foes.all");
const bool checkLaneFoesRoundabout = !checkLaneFoesAll && oc.getBool("check-lane-foes.roundabout");
if (checkLaneFoesRoundabout) {
const std::set<EdgeSet>& roundabouts = ec.getRoundabouts();
for (std::set<EdgeSet>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
for (EdgeSet::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
roundaboutNodes.insert((*j)->getToNode());
}
}
}
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
const bool checkLaneFoes = checkLaneFoesAll || (checkLaneFoesRoundabout && roundaboutNodes.count((*i).second) > 0);
writeJunction(device, *(*i).second, checkLaneFoes);
}
device.lf();
const bool includeInternal = !oc.getBool("no-internal-links");
if (includeInternal) {
// ... internal nodes if not unwanted
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalNodes(device, *(*i).second);
}
if (hadAny) {
device.lf();
}
}
// write the successors of lanes
unsigned int numConnections = 0;
for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.begin(); it_edge != ec.end(); it_edge++) {
NBEdge* from = it_edge->second;
from->sortOutgoingConnectionsByIndex();
const std::vector<NBEdge::Connection> connections = from->getConnections();
numConnections += (unsigned int)connections.size();
for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
writeConnection(device, *from, *it_c, includeInternal);
}
}
if (numConnections > 0) {
device.lf();
}
if (includeInternal) {
//.........这里部分代码省略.........
示例15: ProcessError
void
startComputation(RODFNet* optNet, RODFDetectorFlows& flows, RODFDetectorCon& detectors, OptionsCont& oc) {
if (oc.getBool("print-absolute-flows")) {
flows.printAbsolute();
}
// if a network was loaded... (mode1)
if (optNet != 0) {
if (oc.getBool("remove-empty-detectors")) {
PROGRESS_BEGIN_MESSAGE("Removing empty detectors");
optNet->removeEmptyDetectors(detectors, flows);
PROGRESS_DONE_MESSAGE();
} else if (oc.getBool("report-empty-detectors")) {
PROGRESS_BEGIN_MESSAGE("Scanning for empty detectors");
optNet->reportEmptyDetectors(detectors, flows);
PROGRESS_DONE_MESSAGE();
}
// compute the detector types (optionally)
if (!detectors.detectorsHaveCompleteTypes() || oc.getBool("revalidate-detectors")) {
optNet->computeTypes(detectors, oc.getBool("strict-sources"));
}
std::vector<RODFDetector*>::const_iterator i = detectors.getDetectors().begin();
for (; i != detectors.getDetectors().end(); ++i) {
if ((*i)->getType() == SOURCE_DETECTOR) {
break;
}
}
if (i == detectors.getDetectors().end() && !oc.getBool("routes-for-all")) {
throw ProcessError("No source detectors found.");
}
// compute routes between the detectors (optionally)
if (!detectors.detectorsHaveRoutes() || oc.getBool("revalidate-routes") || oc.getBool("guess-empty-flows")) {
PROGRESS_BEGIN_MESSAGE("Computing routes");
optNet->buildRoutes(detectors,
oc.getBool("all-end-follower"), oc.getBool("keep-unfinished-routes"),
oc.getBool("routes-for-all"), !oc.getBool("keep-longer-routes"),
oc.getInt("max-search-depth"));
PROGRESS_DONE_MESSAGE();
}
}
// check
// whether the detectors are valid
if (!detectors.detectorsHaveCompleteTypes()) {
throw ProcessError("The detector types are not defined; use in combination with a network");
}
// whether the detectors have routes
if (!detectors.detectorsHaveRoutes()) {
throw ProcessError("The emitters have no routes; use in combination with a network");
}
// save the detectors if wished
if (oc.isSet("detector-output")) {
detectors.save(oc.getString("detector-output"));
}
// save their positions as POIs if wished
if (oc.isSet("detectors-poi-output")) {
detectors.saveAsPOIs(oc.getString("detectors-poi-output"));
}
// save the routes file if it was changed or it's wished
if (detectors.detectorsHaveRoutes() && oc.isSet("routes-output")) {
detectors.saveRoutes(oc.getString("routes-output"));
}
// guess flows if wished
if (oc.getBool("guess-empty-flows")) {
optNet->buildDetectorDependencies(detectors);
detectors.guessEmptyFlows(flows);
}
const SUMOTime begin = string2time(oc.getString("begin"));
const SUMOTime end = string2time(oc.getString("end"));
const SUMOTime step = string2time(oc.getString("time-step"));
// save emitters if wished
if (oc.isSet("emitters-output") || oc.isSet("emitters-poi-output")) {
optNet->buildEdgeFlowMap(flows, detectors, begin, end, step); // !!!
if (oc.getBool("revalidate-flows")) {
PROGRESS_BEGIN_MESSAGE("Rechecking loaded flows");
optNet->revalidateFlows(detectors, flows, begin, end, step);
PROGRESS_DONE_MESSAGE();
}
if (oc.isSet("emitters-output")) {
PROGRESS_BEGIN_MESSAGE("Writing emitters");
detectors.writeEmitters(oc.getString("emitters-output"), flows,
begin, end, step,
*optNet,
oc.getBool("calibrator-output"),
oc.getBool("include-unused-routes"),
oc.getFloat("scale"),
// oc.getInt("max-search-depth"),
oc.getBool("emissions-only"));
PROGRESS_DONE_MESSAGE();
}
if (oc.isSet("emitters-poi-output")) {
PROGRESS_BEGIN_MESSAGE("Writing emitter pois");
detectors.writeEmitterPOIs(oc.getString("emitters-poi-output"), flows);
PROGRESS_DONE_MESSAGE();
}
//.........这里部分代码省略.........