void NIVissimNodeDef_Edges::searchAndSetConnections() { std::vector<int> connections; std::vector<int> edges; Boundary boundary; for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) { NIVissimNodeParticipatingEdge* edge = *i; NIVissimConnection* c = NIVissimConnection::dictionary(edge->getID()); NIVissimEdge* e = NIVissimEdge::dictionary(edge->getID()); if (c != 0) { connections.push_back(edge->getID()); boundary.add(c->getFromGeomPosition()); boundary.add(c->getToGeomPosition()); c->setNodeCluster(myID); } if (e != 0) { edges.push_back(edge->getID()); boundary.add(e->getGeomPosition(edge->getFromPos())); boundary.add(e->getGeomPosition(edge->getToPos())); } } NIVissimConnectionCluster* c = new NIVissimConnectionCluster(connections, boundary, myID, edges); for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) { NIVissimEdge* edge = NIVissimEdge::dictionary(*j); edge->myConnectionClusters.push_back(c); } }
Boundary GUIEdge::getBoundary() const { Boundary ret; if (getPurpose() != MSEdge::EDGEFUNCTION_DISTRICT) { for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { ret.add((*i)->getShape().getBoxBoundary()); } } else { // take the starting coordinates of all follower edges and the endpoints // of all successor edges for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) { const std::vector<MSLane*>& lanes = (*it)->getLanes(); for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) { ret.add((*it_lane)->getShape().front()); } } for (MSEdgeVector::const_iterator it = myPredecessors.begin(); it != myPredecessors.end(); ++it) { const std::vector<MSLane*>& lanes = (*it)->getLanes(); for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) { ret.add((*it_lane)->getShape().back()); } } } ret.grow(10); return ret; }
Boundary GUILane::getCenteringBoundary() const { Boundary b; b.add(myShape[0]); b.add(myShape[-1]); b.grow(20); return b; }
Boundary GUILaneWrapper::getCenteringBoundary() const throw() { Boundary b; b.add(myShape[0]); b.add(myShape[-1]); b.grow(20); return b; }
void NIVissimConnection::computeBounding() { Boundary *bound = new Boundary(); bound->add(myFromDef.getGeomPosition()); bound->add(myToDef.getGeomPosition()); assert(myBoundary==0); myBoundary = bound; }
/* Test the method 'add' with multiple calls*/ TEST(Boundary, test_method_add_multiple) { Boundary *bound = new Boundary(); bound->add(-1,-2); bound->add(3,5); bound->add(5,8); EXPECT_DOUBLE_EQ(bound->xmax(), 5); EXPECT_DOUBLE_EQ(bound->xmin(), -1); EXPECT_DOUBLE_EQ(bound->ymax(), 8); EXPECT_DOUBLE_EQ(bound->ymin(), -2); }
/* Test the method 'add' with multiple calls*/ TEST(Boundary, test_method_add_multiple) { Boundary bound; bound.add(-1,-2); bound.add(3,5); bound.add(5,8); EXPECT_DOUBLE_EQ(bound.xmax(), 5); EXPECT_DOUBLE_EQ(bound.xmin(), -1); EXPECT_DOUBLE_EQ(bound.ymax(), 8); EXPECT_DOUBLE_EQ(bound.ymin(), -2); }
void NIVissimDisturbance::computeBounding() { assert(myBoundary == 0); Boundary* bound = new Boundary(); if (NIVissimAbstractEdge::dictionary(myEdge.getEdgeID()) != nullptr) { bound->add(myEdge.getGeomPosition()); } if (NIVissimAbstractEdge::dictionary(myDisturbance.getEdgeID()) != nullptr) { bound->add(myDisturbance.getGeomPosition()); } myBoundary = bound; assert(myBoundary != 0 && myBoundary->xmax() >= myBoundary->xmin()); }
std::vector<GUIGlID> GUISUMOAbstractView::getObjectsAtPosition(Position pos, SUMOReal radius) { Boundary selection; selection.add(pos); selection.grow(radius); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); std::vector<GUIGlID> result; // Interpret results for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { result.push_back(id); } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return result; }
Boundary GUIPolygon::getCenteringBoundary() const { Boundary b; b.add(myShape.getBoxBoundary()); b.grow(10); return b; }
/* Test the method 'add'*/ TEST(Boundary, test_method_add) { Boundary *bound = new Boundary(); bound->add(1,2); EXPECT_DOUBLE_EQ(bound->xmax(), 1); EXPECT_DOUBLE_EQ(bound->xmin(), 1); EXPECT_DOUBLE_EQ(bound->ymax(), 2); EXPECT_DOUBLE_EQ(bound->ymin(), 2); }
Boundary PositionVector::getBoxBoundary() const { Boundary ret; for (const_iterator i = begin(); i != end(); i++) { ret.add(*i); } return ret; }
Boundary GUIPerson::getCenteringBoundary() const { Boundary b; // ensure that the vehicle is drawn, otherwise myPositionInVehicle will not be updated b.add(getPosition()); b.grow(MAX2(getVehicleType().getWidth(), getVehicleType().getLength())); return b; }
Boundary GUIPointOfInterest::getCenteringBoundary() const { Boundary b; b.add(x(), y()); b.growWidth(myHalfImgWidth); b.growHeight(myHalfImgHeight); return b; }
/* Test the method 'add'*/ TEST(Boundary, test_method_add) { Boundary bound; bound.add(1,2); EXPECT_DOUBLE_EQ(bound.xmax(), 1); EXPECT_DOUBLE_EQ(bound.xmin(), 1); EXPECT_DOUBLE_EQ(bound.ymax(), 2); EXPECT_DOUBLE_EQ(bound.ymin(), 2); }
void GUINet::initGUIStructures() { // initialise detector storage for gui initDetectors(); // initialise the tl-map initTLMap(); // initialise edge storage for gui GUIEdge::fill(myEdgeWrapper); // initialise junction storage for gui size_t size = myJunctions->size(); myJunctionWrapper.reserve(size); const std::map<std::string, MSJunction*> &junctions = myJunctions->getMyMap(); for (std::map<std::string, MSJunction*>::const_iterator i=junctions.begin(); i!=junctions.end(); ++i) { myJunctionWrapper.push_back(new GUIJunctionWrapper(GUIGlObjectStorage::gIDStorage, *(*i).second)); } // build the visualization tree float *cmin = new float[2]; float *cmax = new float[2]; for (std::vector<GUIEdge*>::iterator i=myEdgeWrapper.begin(); i!=myEdgeWrapper.end(); ++i) { GUIEdge *edge = *i; Boundary b; const std::vector<MSLane*> &lanes = edge->getLanes(); for (std::vector<MSLane*>::const_iterator j=lanes.begin(); j!=lanes.end(); ++j) { b.add((*j)->getShape().getBoxBoundary()); } b.grow(2.); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid->Insert(cmin, cmax, edge); myBoundary.add(b); } for (std::vector<GUIJunctionWrapper*>::iterator i=myJunctionWrapper.begin(); i!=myJunctionWrapper.end(); ++i) { GUIJunctionWrapper *junction = *i; Boundary b = junction->getBoundary(); b.grow(2.); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid->Insert(cmin, cmax, junction); myBoundary.add(b); } const std::vector<GUIGlObject_AbstractAdd*> &a = GUIGlObject_AbstractAdd::getObjectList(); for (std::vector<GUIGlObject_AbstractAdd*>::const_iterator i=a.begin(); i!=a.end(); ++i) { GUIGlObject_AbstractAdd *o = *i; Boundary b = o->getCenteringBoundary(); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid->Insert(cmin, cmax, o); } delete[] cmin; delete[] cmax; myGrid->add(myBoundary); }
Boundary GUIEdge::getBoundary() const { Boundary ret; for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { ret.add((*i)->getShape().getBoxBoundary()); } ret.grow(10); return ret; }
Boundary GUIParkingArea::getCenteringBoundary() const { Boundary b = myShape.getBoxBoundary(); for (std::map<unsigned int, LotSpaceDefinition >::const_iterator i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) { b.add((*i).second.myPosition); } b.grow(20); return b; }
GUIGlID GUISUMOAbstractView::getObjectAtPosition(Position pos) { const SUMOReal SENSITIVITY = 0.1; // meters Boundary selection; selection.add(pos); selection.grow(SENSITIVITY); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); // Interpret results unsigned int idMax = 0; int prevLayer = -1000; for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { int clayer = (int) type; // determine an "abstract" layer for shapes // this "layer" resembles the layer of the shape // taking into account the stac of other objects if (type == GLO_SHAPE) { if (dynamic_cast<GUIPolygon*>(o) != 0) { if (dynamic_cast<GUIPolygon*>(o)->getLayer() > 0) { clayer = GLO_MAX + dynamic_cast<GUIPolygon*>(o)->getLayer(); } if (dynamic_cast<GUIPolygon*>(o)->getLayer() < 0) { clayer = dynamic_cast<GUIPolygon*>(o)->getLayer(); } } if (dynamic_cast<GUIPointOfInterest*>(o) != 0) { if (dynamic_cast<GUIPointOfInterest*>(o)->getLayer() > 0) { clayer = GLO_MAX + dynamic_cast<GUIPointOfInterest*>(o)->getLayer(); } if (dynamic_cast<GUIPointOfInterest*>(o)->getLayer() < 0) { clayer = dynamic_cast<GUIPointOfInterest*>(o)->getLayer(); } } } // check whether the current object is above a previous one if (prevLayer == -1000 || prevLayer < clayer) { idMax = id; prevLayer = clayer; } } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return idMax; }
Boundary GUIEdge::getBoundary() const { Boundary ret; for (LaneWrapperVector::const_iterator i = myLaneGeoms.begin(); i != myLaneGeoms.end(); ++i) { const PositionVector& g = (*i)->getShape(); for (unsigned int j = 0; j < g.size(); j++) { ret.add(g[j]); } } ret.grow(10); return ret; }
Boundary GUITrafficLightLogicWrapper::getCenteringBoundary() const { Boundary ret; const MSTrafficLightLogic::LaneVectorVector& lanes = myTLLogic.getLaneVectors(); for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) { const MSTrafficLightLogic::LaneVector& lanes2 = (*i); for (MSTrafficLightLogic::LaneVector::const_iterator j = lanes2.begin(); j != lanes2.end(); ++j) { ret.add((*j)->getShape()[-1]); } } ret.grow(20); return ret; }
GUIGlID GUISUMOAbstractView::getObjectAtPosition(Position pos) { const SUMOReal SENSITIVITY = 0.1; // meters Boundary selection; selection.add(pos); selection.grow(SENSITIVITY); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); // Interpret results unsigned int idMax = 0; SUMOReal maxLayer = -std::numeric_limits<SUMOReal>::max(); for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { SUMOReal layer = (SUMOReal)type; // determine an "abstract" layer for shapes // this "layer" resembles the layer of the shape // taking into account the stac of other objects if (type == GLO_POI || type == GLO_POLYGON) { layer = dynamic_cast<Shape*>(o)->getLayer(); } #ifdef HAVE_INTERNAL if (type == GLO_LANE && GUIVisualizationSettings::UseMesoSim) { // do not select lanes in meso mode continue; } #endif // check whether the current object is above a previous one if (layer > maxLayer) { idMax = id; maxLayer = layer; } } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return idMax; }
void NBNetBuilder::compute(OptionsCont& oc, const std::set<std::string>& explicitTurnarounds, bool removeElements) { GeoConvHelper& geoConvHelper = GeoConvHelper::getProcessing(); const bool lefthand = oc.getBool("lefthand"); if (lefthand) { mirrorX(); }; // MODIFYING THE SETS OF NODES AND EDGES // Removes edges that are connecting the same node long before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Removing self-loops"); myNodeCont.removeSelfLoops(myDistrictCont, myEdgeCont, myTLLCont); PROGRESS_TIME_MESSAGE(before); // if (oc.exists("remove-edges.isolated") && oc.getBool("remove-edges.isolated")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Finding isolated roads"); myNodeCont.removeIsolatedRoads(myDistrictCont, myEdgeCont, myTLLCont); PROGRESS_TIME_MESSAGE(before); } // if (oc.exists("keep-edges.postload") && oc.getBool("keep-edges.postload")) { if (oc.isSet("keep-edges.explicit") || oc.isSet("keep-edges.input-file")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Removing unwished edges"); myEdgeCont.removeUnwishedEdges(myDistrictCont); PROGRESS_TIME_MESSAGE(before); } } if (oc.getBool("junctions.join") || (oc.exists("ramps.guess") && oc.getBool("ramps.guess"))) { // preliminary geometry computations to determine the length of edges // This depends on turning directions and sorting of edge list // in case junctions are joined geometry computations have to be repeated // preliminary roundabout computations to avoid damaging roundabouts via junctions.join or ramps.guess NBTurningDirectionsComputer::computeTurnDirections(myNodeCont, false); NBNodesEdgesSorter::sortNodesEdges(myNodeCont); myEdgeCont.computeLaneShapes(); myNodeCont.computeNodeShapes(); myEdgeCont.computeEdgeShapes(); if (oc.getBool("roundabouts.guess")) { myEdgeCont.guessRoundabouts(); } const std::set<EdgeSet>& roundabouts = myEdgeCont.getRoundabouts(); for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin(); it_round != roundabouts.end(); ++it_round) { std::vector<std::string> nodeIDs; for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) { nodeIDs.push_back((*it_edge)->getToNode()->getID()); } myNodeCont.addJoinExclusion(nodeIDs); } } // join junctions (may create new "geometry"-nodes so it needs to come before removing these if (oc.exists("junctions.join-exclude") && oc.isSet("junctions.join-exclude")) { myNodeCont.addJoinExclusion(oc.getStringVector("junctions.join-exclude")); } unsigned int numJoined = myNodeCont.joinLoadedClusters(myDistrictCont, myEdgeCont, myTLLCont); if (oc.getBool("junctions.join")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Joining junction clusters"); numJoined += myNodeCont.joinJunctions(oc.getFloat("junctions.join-dist"), myDistrictCont, myEdgeCont, myTLLCont); PROGRESS_TIME_MESSAGE(before); } if (oc.getBool("junctions.join") || (oc.exists("ramps.guess") && oc.getBool("ramps.guess"))) { // reset geometry to avoid influencing subsequent steps (ramps.guess) myEdgeCont.computeLaneShapes(); } if (numJoined > 0) { // bit of a misnomer since we're already done WRITE_MESSAGE(" Joined " + toString(numJoined) + " junction cluster(s)."); } // if (removeElements) { unsigned int no = 0; const bool removeGeometryNodes = oc.exists("geometry.remove") && oc.getBool("geometry.remove"); before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Removing empty nodes" + std::string(removeGeometryNodes ? " and geometry nodes" : "")); // removeUnwishedNodes needs turnDirections. @todo: try to call this less often NBTurningDirectionsComputer::computeTurnDirections(myNodeCont, false); no = myNodeCont.removeUnwishedNodes(myDistrictCont, myEdgeCont, myTLLCont, removeGeometryNodes); PROGRESS_TIME_MESSAGE(before); WRITE_MESSAGE(" " + toString(no) + " nodes removed."); } // MOVE TO ORIGIN // compute new boundary after network modifications have taken place Boundary boundary; for (std::map<std::string, NBNode*>::const_iterator it = myNodeCont.begin(); it != myNodeCont.end(); ++it) { boundary.add(it->second->getPosition()); } for (std::map<std::string, NBEdge*>::const_iterator it = myEdgeCont.begin(); it != myEdgeCont.end(); ++it) { boundary.add(it->second->getGeometry().getBoxBoundary()); } geoConvHelper.setConvBoundary(boundary); if (!oc.getBool("offset.disable-normalization") && oc.isDefault("offset.x") && oc.isDefault("offset.y")) { moveToOrigin(geoConvHelper, lefthand); } geoConvHelper.computeFinal(lefthand); // information needed for location element fixed at this point if (oc.exists("geometry.min-dist") && oc.isSet("geometry.min-dist")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Reducing geometries"); myEdgeCont.reduceGeometries(oc.getFloat("geometry.min-dist")); PROGRESS_TIME_MESSAGE(before); } // @note: removing geometry can create similar edges so joinSimilarEdges must come afterwards // @note: likewise splitting can destroy similarities so joinSimilarEdges must come before if (removeElements && oc.getBool("edges.join")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Joining similar edges"); myNodeCont.joinSimilarEdges(myDistrictCont, myEdgeCont, myTLLCont); PROGRESS_TIME_MESSAGE(before); } if (oc.getBool("opposites.guess")) { PROGRESS_BEGIN_MESSAGE("guessing opposite direction edges"); myEdgeCont.guessOpposites(); PROGRESS_DONE_MESSAGE(); } // if (oc.exists("geometry.split") && oc.getBool("geometry.split")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Splitting geometry edges"); myEdgeCont.splitGeometry(myNodeCont); PROGRESS_TIME_MESSAGE(before); } // turning direction before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing turning directions"); NBTurningDirectionsComputer::computeTurnDirections(myNodeCont); PROGRESS_TIME_MESSAGE(before); // correct edge geometries to avoid overlap myNodeCont.avoidOverlap(); // guess ramps if ((oc.exists("ramps.guess") && oc.getBool("ramps.guess")) || (oc.exists("ramps.set") && oc.isSet("ramps.set"))) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Guessing and setting on-/off-ramps"); NBNodesEdgesSorter::sortNodesEdges(myNodeCont); NBRampsComputer::computeRamps(*this, oc); PROGRESS_TIME_MESSAGE(before); } // guess sidewalks if (oc.getBool("sidewalks.guess") || oc.getBool("sidewalks.guess.from-permissions")) { const int sidewalks = myEdgeCont.guessSidewalks(oc.getFloat("default.sidewalk-width"), oc.getFloat("sidewalks.guess.min-speed"), oc.getFloat("sidewalks.guess.max-speed"), oc.getBool("sidewalks.guess.from-permissions")); WRITE_MESSAGE("Guessed " + toString(sidewalks) + " sidewalks."); } // check whether any not previously setable connections may be set now myEdgeCont.recheckPostProcessConnections(); // remap ids if wished if (oc.getBool("numerical-ids")) { int numChangedEdges = myEdgeCont.mapToNumericalIDs(); int numChangedNodes = myNodeCont.mapToNumericalIDs(); if (numChangedEdges + numChangedNodes > 0) { WRITE_MESSAGE("Remapped " + toString(numChangedEdges) + " edge IDs and " + toString(numChangedNodes) + " node IDs."); } } // if (oc.exists("geometry.max-angle")) { myEdgeCont.checkGeometries( DEG2RAD(oc.getFloat("geometry.max-angle")), oc.getFloat("geometry.min-radius"), oc.getBool("geometry.min-radius.fix")); } // GEOMETRY COMPUTATION // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Sorting nodes' edges"); NBNodesEdgesSorter::sortNodesEdges(myNodeCont); PROGRESS_TIME_MESSAGE(before); myEdgeCont.computeLaneShapes(); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing node shapes"); if (oc.exists("geometry.junction-mismatch-threshold")) { myNodeCont.computeNodeShapes(oc.getFloat("geometry.junction-mismatch-threshold")); } else { myNodeCont.computeNodeShapes(); } PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing edge shapes"); myEdgeCont.computeEdgeShapes(); PROGRESS_TIME_MESSAGE(before); // resort edges based on the node and edge shapes NBNodesEdgesSorter::sortNodesEdges(myNodeCont, true); NBTurningDirectionsComputer::computeTurnDirections(myNodeCont, false); // APPLY SPEED MODIFICATIONS if (oc.exists("speed.offset")) { const SUMOReal speedOffset = oc.getFloat("speed.offset"); const SUMOReal speedFactor = oc.getFloat("speed.factor"); if (speedOffset != 0 || speedFactor != 1 || oc.isSet("speed.minimum")) { const SUMOReal speedMin = oc.isSet("speed.minimum") ? oc.getFloat("speed.minimum") : -std::numeric_limits<SUMOReal>::infinity(); before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Applying speed modifications"); for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) { (*i).second->setSpeed(-1, MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin)); } PROGRESS_TIME_MESSAGE(before); } } // CONNECTIONS COMPUTATION // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing node types"); NBNodeTypeComputer::computeNodeTypes(myNodeCont); PROGRESS_TIME_MESSAGE(before); // bool haveCrossings = false; if (oc.getBool("crossings.guess")) { haveCrossings = true; int crossings = 0; for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) { crossings += (*i).second->guessCrossings(); } WRITE_MESSAGE("Guessed " + toString(crossings) + " pedestrian crossings."); } if (!haveCrossings) { // recheck whether we had crossings in the input for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) { if (i->second->getCrossings().size() > 0) { haveCrossings = true; break; } } } if (oc.isDefault("no-internal-links") && !haveCrossings && myHaveLoadedNetworkWithoutInternalEdges) { oc.set("no-internal-links", "true"); } // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing priorities"); NBEdgePriorityComputer::computeEdgePriorities(myNodeCont); PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing approached edges"); myEdgeCont.computeEdge2Edges(oc.getBool("no-left-connections")); PROGRESS_TIME_MESSAGE(before); // if (oc.getBool("roundabouts.guess")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Guessing and setting roundabouts"); const int numGuessed = myEdgeCont.guessRoundabouts(); if (numGuessed > 0) { WRITE_MESSAGE(" Guessed " + toString(numGuessed) + " roundabout(s)."); } PROGRESS_TIME_MESSAGE(before); } myEdgeCont.markRoundabouts(); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing approaching lanes"); myEdgeCont.computeLanes2Edges(); PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Dividing of lanes on approached lanes"); myNodeCont.computeLanes2Lanes(); myEdgeCont.sortOutgoingLanesConnections(); PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Processing turnarounds"); if (!oc.getBool("no-turnarounds")) { myEdgeCont.appendTurnarounds(oc.getBool("no-turnarounds.tls")); } else { myEdgeCont.appendTurnarounds(explicitTurnarounds, oc.getBool("no-turnarounds.tls")); } PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Rechecking of lane endings"); myEdgeCont.recheckLanes(); PROGRESS_TIME_MESSAGE(before); if (haveCrossings && !oc.getBool("no-internal-links")) { for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) { i->second->buildCrossingsAndWalkingAreas(); } } // GUESS TLS POSITIONS before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Assigning nodes to traffic lights"); if (oc.isSet("tls.set")) { std::vector<std::string> tlControlledNodes = oc.getStringVector("tls.set"); TrafficLightType type = SUMOXMLDefinitions::TrafficLightTypes.get(oc.getString("tls.default-type")); for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) { NBNode* node = myNodeCont.retrieve(*i); if (node == 0) { WRITE_WARNING("Building a tl-logic for junction '" + *i + "' is not possible." + "\n The junction '" + *i + "' is not known."); } else { myNodeCont.setAsTLControlled(node, myTLLCont, type); } } } myNodeCont.guessTLs(oc, myTLLCont); PROGRESS_TIME_MESSAGE(before); // if (oc.getBool("tls.join")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Joining traffic light nodes"); myNodeCont.joinTLS(myTLLCont, oc.getFloat("tls.join-dist")); PROGRESS_TIME_MESSAGE(before); } // COMPUTING RIGHT-OF-WAY AND TRAFFIC LIGHT PROGRAMS // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing traffic light control information"); myTLLCont.setTLControllingInformation(myEdgeCont, myNodeCont); PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing node logics"); myNodeCont.computeLogics(myEdgeCont, oc); PROGRESS_TIME_MESSAGE(before); // before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Computing traffic light logics"); std::pair<unsigned int, unsigned int> numbers = myTLLCont.computeLogics(oc); PROGRESS_TIME_MESSAGE(before); std::string progCount = ""; if (numbers.first != numbers.second) { progCount = "(" + toString(numbers.second) + " programs) "; } WRITE_MESSAGE(" " + toString(numbers.first) + " traffic light(s) " + progCount + "computed."); // if (oc.isSet("street-sign-output")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Generating street signs"); myEdgeCont.generateStreetSigns(); PROGRESS_TIME_MESSAGE(before); } // FINISHING INNER EDGES if (!oc.getBool("no-internal-links")) { before = SysUtils::getCurrentMillis(); PROGRESS_BEGIN_MESSAGE("Building inner edges"); for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) { (*i).second->sortOutgoingConnectionsByIndex(); } // walking areas shall only be built if crossings are wished as well for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) { (*i).second->buildInnerEdges(); } PROGRESS_TIME_MESSAGE(before); } if (lefthand) { mirrorX(); }; // report WRITE_MESSAGE("-----------------------------------------------------"); WRITE_MESSAGE("Summary:"); myNodeCont.printBuiltNodesStatistics(); WRITE_MESSAGE(" Network boundaries:"); WRITE_MESSAGE(" Original boundary : " + toString(geoConvHelper.getOrigBoundary())); WRITE_MESSAGE(" Applied offset : " + toString(geoConvHelper.getOffsetBase())); WRITE_MESSAGE(" Converted boundary : " + toString(geoConvHelper.getConvBoundary())); WRITE_MESSAGE("-----------------------------------------------------"); NBRequest::reportWarnings(); // report on very large networks if (MAX2(geoConvHelper.getConvBoundary().xmax(), geoConvHelper.getConvBoundary().ymax()) > 1000000 || MIN2(geoConvHelper.getConvBoundary().xmin(), geoConvHelper.getConvBoundary().ymin()) < -1000000) { WRITE_WARNING("Network contains very large coordinates and will probably flicker in the GUI. Check for outlying nodes and make sure the network is shifted to the coordinate origin"); } }
void GUINet::initGUIStructures() { // initialise detector storage for gui const std::vector<SumoXMLTag> types = myDetectorControl->getAvailableTypes(); for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) { const std::map<std::string, MSDetectorFileOutput*>& dets = myDetectorControl->getTypedDetectors(*i).getMyMap(); for (std::map<std::string, MSDetectorFileOutput*>::const_iterator j = dets.begin(); j != dets.end(); ++j) { GUIDetectorWrapper* wrapper = (*j).second->buildDetectorGUIRepresentation(); if (wrapper != 0) { myDetectorDict.push_back(wrapper); myGrid.addAdditionalGLObject(wrapper); } } } // initialise the tl-map initTLMap(); // initialise edge storage for gui GUIEdge::fill(myEdgeWrapper); // initialise junction storage for gui size_t size = myJunctions->size(); myJunctionWrapper.reserve(size); const std::map<std::string, MSJunction*>& junctions = myJunctions->getMyMap(); for (std::map<std::string, MSJunction*>::const_iterator i = junctions.begin(); i != junctions.end(); ++i) { myJunctionWrapper.push_back(new GUIJunctionWrapper(*(*i).second)); } // build the visualization tree float* cmin = new float[2]; float* cmax = new float[2]; for (std::vector<GUIEdge*>::iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) { GUIEdge* edge = *i; Boundary b; const std::vector<MSLane*>& lanes = edge->getLanes(); for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) { b.add((*j)->getShape().getBoxBoundary()); } // make sure persons are always drawn and selectable since they depend on their edge being drawn b.grow(MSPModel::SIDEWALK_OFFSET + 1); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid.Insert(cmin, cmax, edge); myBoundary.add(b); if (myBoundary.getWidth() > 10e16 || myBoundary.getHeight() > 10e16) { throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n"); } } for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) { GUIJunctionWrapper* junction = *i; Boundary b = junction->getBoundary(); b.grow(2.); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid.Insert(cmin, cmax, junction); myBoundary.add(b); } delete[] cmin; delete[] cmax; myGrid.add(myBoundary); }