77 if ((*ni)->samePos(xID, yID)) {
87 for (
int ix = 0; ix < numX; ix++) {
88 for (
int iy = 0; iy < numY; iy++) {
90 std::string nodeID = toString<int>(ix) +
"/" + toString<int>(iy);
95 node->
setX(ix * spaceX + attachLength);
96 node->
setY(iy * spaceY + attachLength);
107 if (attachLength > 0.0) {
108 for (
int ix = 0; ix < numX; ix++) {
110 NGNode* topNode =
new NGNode(
"top" + toString<int>(ix), ix, numY);
111 NGNode* bottomNode =
new NGNode(
"bottom" + toString<int>(ix), ix, numY + 1);
112 topNode->
setX(ix * spaceX + attachLength);
113 bottomNode->
setX(ix * spaceX + attachLength);
114 topNode->
setY((numY - 1) * spaceY + 2 * attachLength);
122 for (
int iy = 0; iy < numY; iy++) {
124 NGNode* leftNode =
new NGNode(
"left" + toString<int>(iy), numX, iy);
125 NGNode* rightNode =
new NGNode(
"right" + toString<int>(iy), numX + 1, iy);
127 rightNode->
setX((numX - 1) * spaceX + 2 * attachLength);
128 leftNode->
setY(iy * spaceY + attachLength);
129 rightNode->
setY(iy * spaceY + attachLength);
142 return cos(phi) * radius;
148 return sin(phi) * radius;
157 if (numCircles < 1) {
162 double angle = (double)(2 *
M_PI / numRadDiv);
164 for (ir = 1; ir < numRadDiv + 1; ir++) {
165 for (ic = 1; ic < numCircles + 1; ic++) {
168 toString<int>(ir) +
"/" + toString<int>(ic), ir, ic);
179 if (ir == numRadDiv) {
191 for (ir = 1; ir < numRadDiv + 1; ir++) {
200 std::string id1 = node1->
getID() +
"to" + node2->
getID();
201 std::string id2 = node2->
getID() +
"to" + node1->
getID();
211 std::vector<NBNode*> nodes;
214 nodes.push_back(node);
223 for (std::vector<NBNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
226 for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
228 NBEdge* back =
new NBEdge(
"-" + (*j)->getID(), node, (*j)->getFromNode(),
NBNetBuilder & myNetBuilder
The builder used to build NB*-structures.
NGNet(NBNetBuilder &nb)
Constructor.
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
NBTypeCont & getTypeCont()
Returns a reference to the type container.
A netgen-representation of an edge.
double radialToX(double radius, double phi)
Returns the x-position resulting from the given radius and angle.
void connect(NGNode *node1, NGNode *node2)
Connects both nodes with two edges, one for each direction.
void toNB() const
Converts the stored network into its netbuilder-representation.
The representation of a single edge during network building.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
NGNode * findNode(int xPos, int yPos)
Returns the node at the given position.
int getPriority(const std::string &type) const
Returns the priority for the given type.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
double radialToY(double radius, double phi)
Returns the y-position resulting from the given radius and angle.
int nodeNo() const
Returns the number of stored nodes.
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
const std::string & getID() const
Returns the id.
NGEdgeList myEdgeList
The list of links.
static OptionsCont & getOptions()
Retrieves the options.
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
void setX(double x)
Sets a new value for x-position.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
NBEdgeCont & getEdgeCont()
std::string getNextFreeID()
Returns the next free id.
NGNodeList myNodeList
The list of nodes.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
NBNodeCont & getNodeCont()
Returns a reference to the node container.
int myLastID
The last ID given to node or link.
Instance responsible for building networks.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter)
Creates a spider network.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Represents a single node (junction) during network building.
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double attachLength, bool alphaIDs)
Creates a grid network.
A netgen-representation of a node.
void setY(double y)
Sets a new value for y-position.
void add(NGNode *node)
Adds the given node to the network.