 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
49 myAlphaIDs(
OptionsCont::getOptions().getBool(
"alphanumerical-ids")),
73 if ((*ni)->samePos(xID, yID)) {
84 for (; std::pow(26, xn) < iMax; xn++) {};
85 std::string result =
"";
86 for (
int j = 0; j < xn; j++) {
87 result = char(
'A' + (i % 26)) + result;
96 for (
int ix = 0; ix < numX; ix++) {
98 for (
int iy = 0; iy < numY; iy++) {
101 node->
setX(ix * spaceX + attachLength);
102 node->
setY(iy * spaceY + attachLength);
113 if (attachLength > 0.0) {
114 for (
int ix = 0; ix < numX; ix++) {
116 NGNode* topNode =
new NGNode(
"top" + toString<int>(ix), ix, numY);
117 NGNode* bottomNode =
new NGNode(
"bottom" + toString<int>(ix), ix, numY + 1);
118 topNode->
setX(ix * spaceX + attachLength);
119 bottomNode->
setX(ix * spaceX + attachLength);
120 topNode->
setY((numY - 1) * spaceY + 2 * attachLength);
128 for (
int iy = 0; iy < numY; iy++) {
130 NGNode* leftNode =
new NGNode(
"left" + toString<int>(iy), numX, iy);
131 NGNode* rightNode =
new NGNode(
"right" + toString<int>(iy), numX + 1, iy);
133 rightNode->
setX((numX - 1) * spaceX + 2 * attachLength);
134 leftNode->
setY(iy * spaceY + attachLength);
135 rightNode->
setY(iy * spaceY + attachLength);
148 return cos(phi) * radius;
154 return sin(phi) * radius;
163 if (numCircles < 1) {
168 double angle = (double)(2 *
M_PI / numRadDiv);
170 for (ic = 1; ic < numCircles + 1; ic++) {
172 for (ir = 1; ir < numRadDiv + 1; ir++) {
175 nodeIDStart + toString<int>(ir) :
176 toString<int>(ir) +
"/" + toString<int>(ic));
177 Node =
new NGNode(nodeID, ir, ic);
188 if (ir == numRadDiv) {
200 for (ir = 1; ir < numRadDiv + 1; ir++) {
224 result.
parse(val,
true);
234 std::vector<NBNode*> nodes;
241 nodes.push_back(node);
251 for (std::vector<NBNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
255 NBEdge* back =
new NBEdge(
"-" + e->getID(), node, e->getFromNode(),
271 for (
auto it = ec.
begin(); it != ec.
end(); ++it) {
272 allEdges.push_back(it->second);
274 for (
NBEdge* e : allEdges) {
275 if (e->getToNode()->geometryLike()) {
278 std::vector<NBEdgeCont::Split> splits;
280 for (
int i = 0; i < e->getNumLanes() + turnLanes; ++i) {
281 split.lanes.push_back(i);
283 split.pos =
MAX2(0.0, e->getLength() - turnLaneLength);
284 split.speed = e->getSpeed();
286 split.idBefore = e->getID();
288 split.offsetFactor = lefthand ? -1 : 1;
289 if (turnLaneLength <= e->getLength() / 2) {
290 split.offset = -0.5 *
split.offsetFactor * turnLanes * e->getLaneWidth(0);
291 if (e->getFromNode()->geometryLike()) {
293 NBEdge* reverse =
nullptr;
295 if (reverseCand->getFromNode() == e->getToNode()) {
296 reverse = reverseCand;
299 if (reverse !=
nullptr) {
306 splits.push_back(
split);
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double attachLength)
Creates a grid network.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void toNB() const
Converts the stored network into its netbuilder-representation.
Storage for edges, including some functionality operating on multiple edges.
Instance responsible for building networks.
double sample(std::mt19937 *which=0) const
Draw a sample of the distribution.
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
std::string getNextFreeID()
Returns the next free id.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
NGNodeList myNodeList
The list of nodes.
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
A netgen-representation of an edge.
double radialToX(double radius, double phi)
Returns the x-position resulting from the given radius and angle.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
std::string alphabeticalCode(int i, int iMax)
return a letter code for the given integer index
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
const bool myAlphaIDs
Whether to use alphanumericalIDs.
NBEdgeCont & getEdgeCont()
The representation of a single edge during network building.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter)
Creates a spider network.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
NGNode * findNode(int xPos, int yPos)
Returns the node at the given position.
int myLastID
The last ID given to node or link.
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
NGEdgeList myEdgeList
The list of links.
A point in 2D or 3D with translation and scaling methods.
int nodeNo() const
Returns the number of stored nodes.
A storage for options typed value containers)
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
static Distribution_Parameterized getDistribution(const std::string &option)
get distribution from option
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double radialToY(double radius, double phi)
Returns the y-position resulting from the given radius and angle.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
void connect(NGNode *node1, NGNode *node2)
Connects both nodes with two edges, one for each direction.
NBNetBuilder & myNetBuilder
The builder used to build NB*-structures.
NGNet(NBNetBuilder &nb)
Constructor.
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
Represents a single node (junction) during network building.
void add(NGNode *node)
Adds the given node to the network.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
void setY(double y)
Sets a new value for y-position.
A structure which describes changes of lane number or speed along the road.
const std::string & getID() const
Returns the id.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
NBNode * getFromNode() const
Returns the origin node of the edge.
A netgen-representation of a node.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
void setX(double x)
Sets a new value for x-position.