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 + attachLength);
101 node->
setY(iy * spaceY + attachLength);
112 if (attachLength > 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 + attachLength);
118 bottomNode->
setX(ix * spaceX + attachLength);
119 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);
151 return cos(phi) * radius;
157 return sin(phi) * radius;
166 if (numCircles < 1) {
171 double angle = (double)(2 *
M_PI / numRadDiv);
173 for (ic = 1; ic < numCircles + 1; ic++) {
175 for (ir = 1; ir < numRadDiv + 1; ir++) {
178 nodeIDStart + toString<int>(ir) :
179 toString<int>(ir) +
"/" + toString<int>(ic));
191 if (ir == numRadDiv) {
203 for (ir = 1; ir < numRadDiv + 1; ir++) {
227 result.
parse(val,
true);
237 std::vector<NBNode*> nodes;
244 nodes.push_back(node);
254 for (std::vector<NBNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
258 NBEdge* back =
new NBEdge(
"-" + e->getID(), node, e->getFromNode(),
274 for (
auto it = ec.
begin(); it != ec.
end(); ++it) {
275 allEdges.push_back(it->second);
277 for (
NBEdge* e : allEdges) {
278 if (e->getToNode()->geometryLike()) {
281 std::vector<NBEdgeCont::Split> splits;
283 for (
int i = 0; i < e->getNumLanes() + turnLanes; ++i) {
284 split.lanes.push_back(i);
286 split.pos =
MAX2(0.0, e->getLength() - turnLaneLength);
287 split.speed = e->getSpeed();
289 split.idBefore = e->getID();
291 split.offsetFactor = lefthand ? -1 : 1;
292 if (turnLaneLength <= e->getLength() / 2) {
293 split.offset = -0.5 *
split.offsetFactor * turnLanes * e->getLaneWidth(0);
294 if (e->getFromNode()->geometryLike()) {
296 NBEdge* reverse =
nullptr;
298 if (reverseCand->getFromNode() == e->getToNode()) {
299 reverse = reverseCand;
302 if (reverse !=
nullptr) {
309 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)
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
double sample(std::mt19937 *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.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
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.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
NBNode * getFromNode() const
Returns the origin node of the edge.
Instance responsible for building networks.
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBEdgeCont & getEdgeCont()
NBNodeCont & getNodeCont()
Returns a reference to the node 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.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
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 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)
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.
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double attachLength)
Creates a grid network.
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 move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
static double rand(std::mt19937 *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.