48 myAlphaIDs(
OptionsCont::getOptions().getBool(
"alphanumerical-ids")),
72 if ((*ni)->samePos(xID, yID)) {
83 for (; std::pow(26, xn) < iMax; xn++) {};
84 std::string result =
"";
85 for (
int j = 0; j < xn; j++) {
86 result = char(
'A' + (i % 26)) + result;
95 for (
int ix = 0; ix < numX; ix++) {
97 for (
int iy = 0; iy < numY; iy++) {
100 node->
setX(ix * spaceX + xAttachLength);
101 node->
setY(iy * spaceY + yAttachLength);
112 if (yAttachLength > 0.0) {
113 for (
int ix = 0; ix < numX; ix++) {
115 NGNode* topNode =
new NGNode(
"top" + toString<int>(ix), ix, numY);
116 NGNode* bottomNode =
new NGNode(
"bottom" + toString<int>(ix), ix, numY + 1);
117 topNode->
setX(ix * spaceX + xAttachLength);
118 bottomNode->
setX(ix * spaceX + xAttachLength);
119 topNode->
setY((numY - 1) * spaceY + 2 * yAttachLength);
130 if (xAttachLength > 0.0) {
131 for (
int iy = 0; iy < numY; iy++) {
133 NGNode* leftNode =
new NGNode(
"left" + toString<int>(iy), numX, iy);
134 NGNode* rightNode =
new NGNode(
"right" + toString<int>(iy), numX + 1, iy);
136 rightNode->
setX((numX - 1) * spaceX + 2 * xAttachLength);
137 leftNode->
setY(iy * spaceY + yAttachLength);
138 rightNode->
setY(iy * spaceY + yAttachLength);
153 return cos(phi) * radius;
159 return sin(phi) * radius;
168 if (numCircles < 1) {
173 double angle = (double)(2 *
M_PI / numRadDiv);
175 int attachCircle = -1;
176 if (attachLength > 0) {
178 attachCircle = numCircles;
180 for (ic = 1; ic < numCircles + 1; ic++) {
182 if (ic == attachCircle) {
183 spaceRad = attachLength;
185 for (ir = 1; ir < numRadDiv + 1; ir++) {
188 nodeIDStart + toString<int>(ir) :
189 toString<int>(ir) +
"/" + toString<int>(ic));
190 node =
new NGNode(nodeID, ir, ic);
195 if (ir > 1 && ic != attachCircle) {
201 if (ir == numRadDiv && ic != attachCircle) {
213 for (ir = 1; ir < numRadDiv + 1; ir++) {
256 if (!ngEdge->getEndNode()->connected(ngEdge->getStartNode(),
true) &&
RandHelper::rand() <= bidiProb) {
267 for (
auto it = ec.
begin(); it != ec.
end(); ++it) {
268 allEdges.push_back(it->second);
270 for (
NBEdge* e : allEdges) {
271 if (e->getToNode()->geometryLike()) {
274 std::vector<NBEdgeCont::Split> splits;
276 for (
int i = 0; i < e->getNumLanes() + turnLanes; ++i) {
279 split.pos =
MAX2(0.0, e->getLength() - turnLaneLength);
280 split.speed = e->getSpeed();
282 split.idBefore = e->getID();
284 split.offsetFactor = lefthand ? -1 : 1;
285 if (turnLaneLength <= e->getLength() / 2) {
286 split.offset = -0.5 *
split.offsetFactor * turnLanes * e->getLaneWidth(0);
287 if (e->getFromNode()->geometryLike()) {
289 NBEdge* reverse =
nullptr;
290 for (
NBEdge* reverseCand : e->getFromNode()->getIncomingEdges()) {
291 if (reverseCand->getFromNode() == e->getToNode()) {
292 reverse = reverseCand;
295 if (reverse !=
nullptr) {
302 splits.push_back(
split);
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double sample(SumoRNG *which=0) const
Draw a sample of the distribution.
Storage for edges, including some functionality operating on multiple edges.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
process splits
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
The representation of a single edge during network building.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
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.
A netgen-representation of an edge.
double radialToX(double radius, double phi)
Returns the x-position resulting from the given radius and angle.
int myLastID
The last ID given to node or link.
void toNB() const
Converts the stored network into its netbuilder-representation.
void connect(NGNode *node1, NGNode *node2)
Connects both nodes with two edges, one for each direction.
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double xAttachLength, double yAttachLength)
Creates a grid network.
void add(NGNode *node)
Adds the given node to the network.
NGNet(NBNetBuilder &nb)
Constructor.
int nodeNo() const
Returns the number of stored nodes.
void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter, double attachLength)
Creates a spider network.
double radialToY(double radius, double phi)
Returns the y-position resulting from the given radius and angle.
NGNode * findNode(int xPos, int yPos)
Returns the node at the given position.
std::string alphabeticalCode(int i, int iMax)
return a letter code for the given integer index
std::string getNextFreeID()
Returns the next free id.
static Distribution_Parameterized getDistribution(const std::string &option)
get distribution from option
NGNodeList myNodeList
The list of nodes.
const bool myAlphaIDs
Whether to use alphanumericalIDs.
NBNetBuilder & myNetBuilder
The builder used to build NB*-structures.
NGEdgeList myEdgeList
The list of links.
A netgen-representation of a node.
void setFringe()
mark node as fringe
void setY(double y)
Sets a new value for y-position.
void setX(double x)
Sets a new value for x-position.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
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.
A point in 2D or 3D with translation and scaling methods.
void setz(double z)
set position z
void sety(double y)
set position y
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
A structure which describes changes of lane number or speed along the road.
std::vector< int > lanes
The lanes after this change.