63 myEdgeCont(myTypeCont),
64 myHaveLoadedNetworkWithoutInternalEdges(false),
65 myNetworkHaveCrossings(false) {
88 const bool lefthand = oc.
getBool(
"lefthand");
100 if (mayAddOrRemove && oc.
exists(
"remove-edges.isolated") && oc.
getBool(
"remove-edges.isolated")) {
106 if (mayAddOrRemove && oc.
exists(
"keep-edges.components") && oc.
getInt(
"keep-edges.components") > 0) {
112 if (mayAddOrRemove && oc.
exists(
"keep-edges.postload") && oc.
getBool(
"keep-edges.postload")) {
113 if (oc.
isSet(
"keep-edges.explicit") || oc.
isSet(
"keep-edges.input-file")) {
130 if (oc.
getBool(
"roundabouts.guess")) {
134 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
135 it_round != roundabouts.end(); ++it_round) {
136 std::vector<std::string> nodeIDs;
137 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
138 nodeIDs.push_back((*it_edge)->getToNode()->getID());
144 if (mayAddOrRemove && oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
148 if (mayAddOrRemove && oc.
getBool(
"junctions.join")) {
163 if (mayAddOrRemove) {
165 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
167 PROGRESS_BEGIN_MESSAGE(
"Removing empty nodes" + std::string(removeGeometryNodes ?
" and geometry nodes" :
""));
179 boundary.
add(it->second->getPosition());
182 boundary.
add(it->second->getGeometry().getBoxBoundary());
191 if (oc.
exists(
"geometry.min-dist") && !oc.
isDefault(
"geometry.min-dist")) {
199 if (mayAddOrRemove && oc.
getBool(
"edges.join")) {
205 if (oc.
getBool(
"opposites.guess")) {
211 if (mayAddOrRemove && oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
225 if (mayAddOrRemove) {
235 if (mayAddOrRemove && ((oc.
getBool(
"sidewalks.guess") || oc.
getBool(
"sidewalks.guess.from-permissions")))) {
237 oc.
getFloat(
"sidewalks.guess.min-speed"),
238 oc.
getFloat(
"sidewalks.guess.max-speed"),
239 oc.
getBool(
"sidewalks.guess.from-permissions"));
249 if (numChangedEdges + numChangedNodes > 0) {
254 if (oc.
exists(
"geometry.max-angle")) {
258 oc.
getBool(
"geometry.min-radius.fix"));
271 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
287 if (oc.
exists(
"speed.offset")) {
288 const double speedOffset = oc.
getFloat(
"speed.offset");
289 const double speedFactor = oc.
getFloat(
"speed.factor");
290 if (speedOffset != 0 || speedFactor != 1) {
291 const double speedMin = oc.
getFloat(
"speed.minimum");
295 (*i).second->setSpeed(-1,
MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
309 if (mayAddOrRemove && oc.
getBool(
"crossings.guess")) {
313 crossings += (*i).second->guessCrossings();
320 if (i->second->getCrossingsIncludingInvalid().size() > 0) {
328 oc.
set(
"no-internal-links",
"true");
332 oc.
set(
"no-internal-links",
"false");
346 if (mayAddOrRemove && oc.
getBool(
"roundabouts.guess")) {
350 if (numGuessed > 0) {
370 if (!oc.
getBool(
"no-turnarounds")) {
384 i->second->buildCrossingsAndWalkingAreas();
386 }
else if (oc.
getBool(
"no-internal-links")) {
388 i->second->discardAllCrossings(
false);
395 if (oc.
isSet(
"tls.set")) {
396 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
398 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
401 WRITE_WARNING(
"Building a tl-logic for junction '" + *i +
"' is not possible." +
"\n The junction '" + *i +
"' is not known.");
434 std::string progCount =
"";
435 if (numbers.first != numbers.second) {
436 progCount =
"(" +
toString(numbers.second) +
" programs) ";
440 if (oc.
isSet(
"street-sign-output")) {
448 (*i).second->sortOutgoingConnectionsByIndex();
451 if (!oc.
getBool(
"no-internal-links")) {
456 (*i).second->buildInnerEdges();
461 if (oc.
getFloat(
"junctions.scurve-stretch") > 0) {
469 (*i).second->buildInnerEdges();
477 if (oc.
exists(
"geometry.check-overlap") && oc.
getFloat(
"geometry.check-overlap") > 0) {
490 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
497 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
505 WRITE_MESSAGE(
"-----------------------------------------------------");
512 WRITE_MESSAGE(
"-----------------------------------------------------");
517 WRITE_WARNING(
"Network contains very large coordinates and will probably flicker in the GUI. Check for outlying nodes and make sure the network is shifted to the coordinate origin");
539 const double x = -boundary.
xmin();
540 const double y = -(lefthand ? boundary.
ymax() : boundary.
ymin());
545 (*i).second->reshiftPosition(x, y);
548 (*i).second->reshiftPosition(x, y);
551 (*i).second->reshiftPosition(x, y);
554 (*i).second->reshiftPostion(x, y);
565 (*i).second->mirrorX();
568 (*i).second->mirrorX();
571 (*i).second->mirrorX();
586 double z = hm.
getZ(orig);
597 if (maxLength > 0 && from.size() > 1) {
600 for (
int i = 0; i < (int) from.size(); i++) {
606 for (
int i = 0; i < (int)copy.size() - 1; i++) {
607 Position start = from[i + inserted];
608 Position end = from[i + inserted + 1];
609 double length = copy[i].distanceTo(copy[i + 1]);
610 const Position step = (end - start) * (maxLength / length);
612 while (length > maxLength) {
615 from.insert(from.begin() + i + inserted + 1, start + (step * steps));
623 for (
int i = 0; i < (int) from.size(); i++) {
NBNetBuilder()
Constructor.
NBTypeCont myTypeCont
The used container for street types.
double xmax() const
Returns maximum x-coordinate.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
NBPTStopCont myPTStopCont
The used container for pt stops.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same) ...
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
void resetWritable()
Resets all options to be writeable.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
void reduceGeometries(const double minDist)
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
bool ready() const
returns whether the NBHeightMapper has data
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
Removes "unwished" nodes.
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
void mirrorX()
mirror the network along the X-axis
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
void joinTLS(NBTrafficLightLogicCont &tlc, double maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data...
double ymax() const
Returns maximum y-coordinate.
~NBNetBuilder()
Destructor.
double x() const
Returns the x-position.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool x2cartesian(Position &from, bool includeInBoundary=true)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void guessOpposites()
Sets opposite lane information for geometrically close edges.
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
std::map< std::string, NBPTStop * >::const_iterator begin() const
Returns the pointer to the begin of the stored pt stops.
void generateStreetSigns()
assigns street signs to edges based on toNode types
void recheckPostProcessConnections()
Try to set any stored connections.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
void avoidOverlap()
fix overlap
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
void moveConvertedBy(double x, double y)
Shifts the converted boundary by the given amounts.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
void checkGeometries(const double maxAngle, const double minRadius, bool fix)
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void computeLogics(const NBEdgeCont &ec, OptionsCont &oc)
build the list of outgoing edges and lanes
static const NBHeightMapper & get()
return the singleton instance (maybe 0)
void process(NBEdgeCont &cont)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void reportWarnings()
reports warnings if any occured
#define PROGRESS_TIME_MESSAGE(before)
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static methods for processing the coordinates conversion for the current net
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
A point in 2D or 3D with translation and scaling methods.
void setDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
NBEdgeCont myEdgeCont
The used container for edges.
double y() const
Returns the y-position.
bool myNetworkHaveCrossings
flag to indicate that network has crossings
std::map< std::string, NBPTStop * >::const_iterator end() const
Returns the pointer to the end of the stored pt stops.
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
NBTrafficLightLogicCont myTLLCont
The used container for traffic light logics.
void computeNodeShapes(double mismatchThreshold=-1)
Compute the junction shape for this node.
#define PROGRESS_BEGIN_MESSAGE(msg)
void splitGeometry(NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
const Position getOffsetBase() const
Returns the network base.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
int joinJunctions(double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins junctions that are very close together.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
const Boundary & getConvBoundary() const
Returns the converted boundary.
void process(NBEdgeCont &cont)
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
int guessSidewalks(double width, double minSpeed, double maxSpeed, bool fromPermissions)
add sidwalks to edges within the given limits or permissions and return the number of edges affected ...
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc)
Computes highway on-/off-ramps (if wished)
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
void appendTurnarounds(bool noTLSControlled)
Appends turnarounds to all edges stored in the container.
int remapIDs(bool numericaIDs, bool reservedIDs)
remap node IDs accoring to options –numerical-ids and –reserved-ids
static void computeNodeTypes(NBNodeCont &nc)
Computes node types.
void moveToOrigin(GeoConvHelper &geoConvHelper, bool lefthand)
shift network so its lower left corner is at 0,0
double xmin() const
Returns minimum x-coordinate.
A storage for options typed value containers)
double ymin() const
Returns minimum y-coordinate.
void computeEdgeShapes()
Computes the shapes of all edges stored in the container.
Represents a single node (junction) during network building.
T get(const std::string &str) const
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
NBDistrictCont myDistrictCont
The used container for districts.
double getZ(const Position &geo) const
returns height for the given geo coordinate (WGS84)
const Boundary & getOrigBoundary() const
Returns the original boundary.
void checkGrade(double threshold) const
check whether edges are to steep
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
static long getCurrentMillis()
Returns the current time in milliseconds.
#define PROGRESS_DONE_MESSAGE()
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
bool myHaveLoadedNetworkWithoutInternalEdges
whether a .net.xml without internal edges was loaded
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
#define WRITE_MESSAGE(msg)
int remapIDs(bool numericaIDs, bool reservedIDs)
remap node IDs accoring to options –numerical-ids and –reserved-ids
NBNodeCont myNodeCont
The used container for nodes.
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Set z-values for all network positions based on data from a height map.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
NBPTLineCont myPTLineCont
The used container for pt stops.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void removeComponents(NBDistrictCont &dc, NBEdgeCont &ec, const int numKeep)
Checks the network for weak connectivity and removes all but the largest components. The connectivity check is done regardless of edge direction and vclass.