50 myAlphaIDs(
OptionsCont::getOptions().getBool(
"alphanumerical-ids")),
74 if ((*ni)->samePos(xID, yID)) {
85 for (; std::pow(26, xn) < iMax; xn++) {};
86 std::string result =
"";
87 for (
int j = 0; j < xn; j++) {
88 result = char(
'A' + (i % 26)) + result;
97 for (
int ix = 0; ix < numX; ix++) {
99 for (
int iy = 0; iy < numY; iy++) {
102 node->
setX(ix * spaceX + attachLength);
103 node->
setY(iy * spaceY + attachLength);
114 if (attachLength > 0.0) {
115 for (
int ix = 0; ix < numX; ix++) {
117 NGNode* topNode =
new NGNode(
"top" + toString<int>(ix), ix, numY);
118 NGNode* bottomNode =
new NGNode(
"bottom" + toString<int>(ix), ix, numY + 1);
119 topNode->
setX(ix * spaceX + attachLength);
120 bottomNode->
setX(ix * spaceX + attachLength);
121 topNode->
setY((numY - 1) * spaceY + 2 * attachLength);
129 for (
int iy = 0; iy < numY; iy++) {
131 NGNode* leftNode =
new NGNode(
"left" + toString<int>(iy), numX, iy);
132 NGNode* rightNode =
new NGNode(
"right" + toString<int>(iy), numX + 1, iy);
134 rightNode->
setX((numX - 1) * spaceX + 2 * attachLength);
135 leftNode->
setY(iy * spaceY + attachLength);
136 rightNode->
setY(iy * spaceY + attachLength);
149 return cos(phi) * radius;
155 return sin(phi) * radius;
164 if (numCircles < 1) {
169 double angle = (double)(2 *
M_PI / numRadDiv);
171 for (ic = 1; ic < numCircles + 1; ic++) {
173 for (ir = 1; ir < numRadDiv + 1; ir++) {
176 nodeIDStart + toString<int>(ir) :
177 toString<int>(ir) +
"/" + toString<int>(ic));
178 Node =
new NGNode(nodeID, ir, ic);
189 if (ir == numRadDiv) {
201 for (ir = 1; ir < numRadDiv + 1; ir++) {
225 result.
parse(val,
true);
235 std::vector<NBNode*> nodes;
242 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();
289 if (turnLaneLength <= e->getLength() / 2) {
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);
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].
std::string alphabeticalCode(int i, int iMax)
return a letter code for the given integer index
NBTypeCont & getTypeCont()
Returns a reference to the type container.
A netgen-representation of an edge.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
A structure which describes changes of lane number or speed along the road.
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
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.
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.
std::string idAfter
The id for the edge after the split.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
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].
double pos
The position of this change.
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
NBNode * node
The new node that is created for this split.
void setX(double x)
Sets a new value for x-position.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
int offsetFactor
direction in which to apply the offset (used by netgenerate for lefthand networks) ...
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
std::string getNextFreeID()
Returns the next free id.
NGNodeList myNodeList
The list of nodes.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Storage for edges, including some functionality operating on multiple edges.
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
std::vector< int > lanes
The lanes after this change.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
static Distribution_Parameterized getDistribution(const std::string &option)
get distribution from option
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.
A storage for options typed value containers)
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
double speed
The speed after this change.
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double attachLength)
Creates a grid network.
Represents a single node (junction) during network building.
double sample(std::mt19937 *which=0) const
Draw a sample of the distribution.
NBNode * getFromNode() const
Returns the origin node of the edge.
A netgen-representation of a node.
void setY(double y)
Sets a new value for y-position.
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
const bool myAlphaIDs
Whether to use alphanumericalIDs.
std::string idBefore
The id for the edge before the split.
void add(NGNode *node)
Adds the given node to the network.
double offset
lateral offset to edge geometry