55 myEdgeCont(myTypeCont),
56 myNetworkHaveCrossings(false) {
80 const bool lefthand = oc.
getBool(
"lefthand");
90 if (mayAddOrRemove && oc.
exists(
"remove-edges.isolated") && oc.
getBool(
"remove-edges.isolated")) {
95 if (mayAddOrRemove && oc.
exists(
"keep-edges.components") && oc.
getInt(
"keep-edges.components") > 0) {
100 if (mayAddOrRemove && oc.
exists(
"keep-edges.postload") && oc.
getBool(
"keep-edges.postload")) {
101 if (oc.
isSet(
"keep-edges.explicit") || oc.
isSet(
"keep-edges.input-file")) {
108 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
110 if (!(oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output"))
111 && !oc.
getBool(
"ptstop-output.no-bidi")) {
118 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
124 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
125 if (oc.
exists(
"ptline-clean-up") && oc.
getBool(
"ptline-clean-up")) {
131 if (numDeletedStops > 0) {
132 WRITE_WARNING(
"Removed " +
toString(numDeletedStops) +
" pt stops because they could not be assigned to the network");
137 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output") && !oc.
getBool(
"ptstop-output.no-bidi")) {
144 if (oc.
exists(
"railway.topology.all-bidi") && oc.
getBool(
"railway.topology.all-bidi")) {
147 }
else if (oc.
exists(
"railway.topology.repair") && oc.
getBool(
"railway.topology.repair")) {
150 oc.
getFloat(
"geometry.min-radius"),
false,
151 oc.
getBool(
"geometry.min-radius.fix.railways"),
true);
155 if (oc.
exists(
"railway.topology.direction-priority") && oc.
getBool(
"railway.topology.direction-priority")) {
159 if (oc.
exists(
"railway.topology.output") && oc.
isSet(
"railway.topology.output")) {
165 if (mayAddOrRemove && oc.
exists(
"edges.join-tram-dist") && oc.
getFloat(
"edges.join-tram-dist") >= 0) {
170 if (numJoinedTramEdges > 0) {
174 if (oc.
getBool(
"junctions.join")
176 || oc.
getBool(
"tls.guess.joining")
177 || (oc.
exists(
"tls.guess-signals") && oc.
getBool(
"tls.guess-signals"))) {
187 if (oc.
getBool(
"roundabouts.guess")) {
191 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
192 it_round != roundabouts.end(); ++it_round) {
193 std::vector<std::string> nodeIDs;
194 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
195 nodeIDs.push_back((*it_edge)->getToNode()->getID());
202 if (mayAddOrRemove && oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
206 if (mayAddOrRemove && oc.
getBool(
"junctions.join")) {
214 if (mayAddOrRemove && oc.
exists(
"junctions.join-same") && oc.
getBool(
"junctions.join-same")) {
218 if (numJoined2 > 0) {
223 if (mayAddOrRemove && oc.
exists(
"join-lanes") && oc.
getBool(
"join-lanes")) {
230 if (mayAddOrRemove) {
232 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
245 boundary.
add(it->second->getPosition());
248 boundary.
add(it->second->getGeometry().getBoxBoundary());
257 if (oc.
exists(
"geometry.min-dist") && !oc.
isDefault(
"geometry.min-dist")) {
264 if (mayAddOrRemove && oc.
getBool(
"edges.join")) {
269 if (oc.
getBool(
"opposites.guess")) {
275 if (mayAddOrRemove && oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
285 if (oc.
exists(
"geometry.avoid-overlap") && oc.
getBool(
"geometry.avoid-overlap")) {
291 if (oc.
isSet(
"tls.set")) {
292 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
294 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
296 if (node ==
nullptr) {
297 WRITE_WARNING(
"Building a tl-logic for junction '" + *i +
"' is not possible." +
"\n The junction '" + *i +
"' is not known.");
307 const bool modifyRamps = mayAddOrRemove && (
309 || (oc.
exists(
"ramps.set") && oc.
isSet(
"ramps.set")));
310 if (modifyRamps || (oc.
exists(
"ramps.guess-acceleration-lanes") && oc.
getBool(
"ramps.guess-acceleration-lanes"))) {
323 if (mayAddOrRemove && ((oc.
getBool(
"bikelanes.guess") || oc.
getBool(
"bikelanes.guess.from-permissions")))) {
325 oc.
getFloat(
"bikelanes.guess.min-speed"),
326 oc.
getFloat(
"bikelanes.guess.max-speed"),
327 oc.
getBool(
"bikelanes.guess.from-permissions"),
328 "bikelanes.guess.exclude");
330 addedLanes += bikelanes;
334 if (mayAddOrRemove && ((oc.
getBool(
"sidewalks.guess") || oc.
getBool(
"sidewalks.guess.from-permissions")))) {
336 oc.
getFloat(
"sidewalks.guess.min-speed"),
337 oc.
getFloat(
"sidewalks.guess.max-speed"),
338 oc.
getBool(
"sidewalks.guess.from-permissions"),
339 "sidewalks.guess.exclude");
341 addedLanes += sidewalks;
344 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output") && addedLanes > 0) {
354 if (numChangedEdges + numChangedNodes > 0) {
359 if (oc.
exists(
"geometry.max-angle")) {
363 oc.
getBool(
"geometry.min-radius.fix"),
364 oc.
getBool(
"geometry.min-radius.fix.railways"));
375 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
390 if (oc.
exists(
"speed.offset")) {
391 const double speedOffset = oc.
getFloat(
"speed.offset");
392 const double speedFactor = oc.
getFloat(
"speed.factor");
393 const double speedMin = oc.
getFloat(
"speed.minimum");
394 if (speedOffset != 0 || speedFactor != 1 || speedMin > 0) {
397 (*i).second->setSpeed(-1,
MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
410 if (mayAddOrRemove && oc.
getBool(
"crossings.guess")) {
414 crossings += (*i).second->guessCrossings();
421 if (i->second->getCrossingsIncludingInvalid().size() > 0) {
431 oc.
set(
"no-internal-links",
"false");
443 if (oc.
getBool(
"roundabouts.guess")) {
446 if (numGuessed > 0) {
462 if (oc.
getBool(
"fringe.guess")) {
465 if (numGuessed > 0) {
472 if (!oc.
getBool(
"no-turnarounds")) {
474 oc.
getBool(
"no-turnarounds.tls"),
475 oc.
getBool(
"no-turnarounds.fringe"),
476 oc.
getBool(
"no-turnarounds.except-deadend"),
477 oc.
getBool(
"no-turnarounds.except-turnlane"),
478 oc.
getBool(
"no-turnarounds.geometry"));
482 if (oc.
exists(
"railway.topology.repair.stop-turn") && oc.
getBool(
"railway.topology.repair.stop-turn")
495 i->second->buildCrossingsAndWalkingAreas();
501 i->second->discardWalkingareas();
503 if (oc.
getBool(
"no-internal-links")) {
505 i->second->discardAllCrossings(
false);
520 if (oc.
exists(
"opendrive-files") && oc.
isSet(
"opendrive-files")) {
533 std::string progCount =
"";
534 if (numbers.first != numbers.second) {
535 progCount =
"(" +
toString(numbers.second) +
" programs) ";
540 (*i).second->sortOutgoingConnectionsByIndex();
543 if (!oc.
getBool(
"no-internal-links")) {
547 (*i).second->buildInnerEdges();
552 if (oc.
getFloat(
"junctions.scurve-stretch") > 0) {
559 (*i).second->buildInnerEdges();
573 if (oc.
isSet(
"street-sign-output")) {
580 if (lefthand != oc.
getBool(
"flip-y-axis")) {
584 if (oc.
exists(
"geometry.check-overlap") && oc.
getFloat(
"geometry.check-overlap") > 0) {
597 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
599 int numBidiStops = 0;
600 if (!oc.
getBool(
"ptstop-output.no-bidi")) {
604 double maxRadius = oc.
getFloat(
"railway.access-distance");
605 double accessFactor = oc.
getFloat(
"railway.access-factor");
606 int maxCount = oc.
getInt(
"railway.max-accesses");
609 if (numBidiStops > 0) {
610 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
617 WRITE_MESSAGE(
"-----------------------------------------------------");
624 WRITE_MESSAGE(
"-----------------------------------------------------");
629 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");
650 const double x = -boundary.
xmin();
651 const double y = -(lefthand ? boundary.
ymax() : boundary.
ymin());
656 (*i).second->reshiftPosition(x, y);
659 (*i).second->reshiftPosition(x, y);
662 (*i).second->reshiftPosition(x, y);
665 (*i).second->reshiftPosition(x, y);
676 (*i).second->mirrorX();
679 (*i).second->mirrorX();
682 (*i).second->mirrorX();
685 (*i).second->mirrorX();
696 && from_srs !=
nullptr
719 if (maxLength > 0 && from.size() > 1) {
722 for (
int i = 0; i < (int) from.size(); i++) {
728 for (
int i = 0; i < (int) from.size(); i++) {
739 for (
int i = 0; i < (int)cartesian.size() - 1; i++) {
740 Position start = from[i + inserted];
741 Position end = from[i + inserted + 1];
742 double length = cartesian[i].distanceTo(cartesian[i + 1]);
743 const Position step = (end - start) * (maxLength / length);
745 while (length > maxLength) {
748 from.insert(from.begin() + i + inserted + 1, start + (step * steps));
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
#define PROGRESS_TIME_MESSAGE(before)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_PEDESTRIAN
pedestrian
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
double getZRange() const
Returns the elevation range of the boundary (z-axis)
static methods for processing the coordinates conversion for the current net
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void moveConvertedBy(double x, double y)
Shifts the converted boundary by the given amounts.
const Boundary & getOrigBoundary() const
Returns the original boundary.
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
static int getNumLoaded()
const Position getOffsetBase() const
Returns the network base.
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data,...
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
void computeEdgeShapes(double smoothElevationThreshold=-1)
Computes the shapes of all edges stored in the container.
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
void appendRailwayTurnarounds(const NBPTStopCont &sc)
Appends turnarounds to all bidiRail edges with stops.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
void recheckPostProcessConnections()
Try to set any stored connections.
void checkGeometries(const double maxAngle, const double minRadius, bool fix, bool fixRailways, bool silent=false)
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
void reduceGeometries(const double minDist)
void splitGeometry(NBDistrictCont &dc, NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
void generateStreetSigns()
assigns street signs to edges based on toNode types
void guessOpposites()
Sets opposite lane information for geometrically close edges.
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
int joinLanes(SVCPermissions perms)
join adjacent lanes with the given permissions
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
void appendTurnarounds(bool noTLSControlled, bool noFringe, bool onlyDeadends, bool onlyTurnlane, bool noGeometryLike)
Appends turnarounds to all edges stored in the container.
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
int joinTramEdges(NBDistrictCont &dc, NBPTLineCont &lc, double maxDist)
join tram edges into adjacent lanes
int guessSpecialLanes(SUMOVehicleClass svc, double width, double minSpeed, double maxSpeed, bool fromPermissions, const std::string &excludeOpt)
add sidwalks to edges within the given limits or permissions and return the number of edges affected
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix, NBPTStopCont &sc)
remap node IDs accoring to options –numerical-ids and –reserved-ids
void checkGrade(double threshold) const
check whether edges are to steep
static void setDefaultConnectionLength(double length)
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
Set z-values for all network positions based on data from a height map.
double getZ(const Position &geo) const
returns height for the given geo coordinate (WGS84)
static const NBHeightMapper & get()
return the singleton instance (maybe 0)
bool ready() const
returns whether the NBHeightMapper has data
void mirrorX()
mirror the network along the X-axis
NBNetBuilder()
Constructor.
NBTrafficLightLogicCont myTLLCont
The used container for traffic light logics.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
void moveToOrigin(GeoConvHelper &geoConvHelper, bool lefthand)
shift network so its lower left corner is at 0,0
bool myNetworkHaveCrossings
flag to indicate that network has crossings
NBDistrictCont myDistrictCont
The used container for districts.
static int addGeometrySegments(PositionVector &from, const PositionVector &cartesian, const double maxLength)
insertion geometry points to ensure maximum segment length between points
NBPTLineCont myPTLineCont
The used container for pt stops.
NBEdgeCont myEdgeCont
The used container for edges.
NBParkingCont myParkingCont
~NBNetBuilder()
Destructor.
NBTypeCont myTypeCont
The used container for street types.
NBPTStopCont myPTStopCont
The used container for pt stops.
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 applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
NBNodeCont myNodeCont
The used container for nodes.
static bool runningNetedit()
whether netbuilding takes place in the context of NETEDIT
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
void avoidOverlap()
fix overlap
void recheckGuessedTLS(NBTrafficLightLogicCont &tlc)
recheck myGuessedTLS after node logics are computed
void computeKeepClear()
compute keepClear status for all connections
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
void joinTLS(NBTrafficLightLogicCont &tlc, double maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc, NBPTLineCont &lc, NBParkingCont &pc, bool removeGeometryNodes)
Removes "unwished" nodes.
void removeComponents(NBDistrictCont &dc, NBEdgeCont &ec, const int numKeep)
Checks the network for weak connectivity and removes all but the largest components....
void computeLogics2(const NBEdgeCont &ec, OptionsCont &oc)
compute right-of-way logic for all lane-to-lane connections
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
void computeLogics(const NBEdgeCont &ec)
build the list of outgoing edges and lanes
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
void computeNodeShapes(double mismatchThreshold=-1)
Compute the junction shape for this node.
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
int guessFringe()
guess and mark fringe nodes
int joinJunctions(double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc)
Joins junctions that are very close together.
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same)
int joinSameJunctions(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins junctions with the same coordinates regardless of topology.
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix)
remap node IDs accoring to options –numerical-ids and –reserved-ids
Represents a single node (junction) during network building.
static void computeNodeTypes(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Computes node types.
static void validateRailCrossings(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Checks rail_crossing for validity.
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
std::set< std::string > & getServedPTStops()
void process(NBEdgeCont &ec, NBPTStopCont &sc)
void fixBidiStops(const NBEdgeCont &ec)
select the correct stop on superposed rail edges
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
const std::map< std::string, NBPTStop * > & getStops() const
void postprocess(std::set< std::string > &usedStops)
std::map< std::string, NBPTStop * >::const_iterator begin() const
Returns the pointer to the begin of the stored pt stops.
void localizePTStops(NBEdgeCont &cont)
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops
void assignLanes(NBEdgeCont &cont)
std::map< std::string, NBPTStop * >::const_iterator end() const
Returns the pointer to the end of the stored pt stops.
static void analyzeTopology(NBNetBuilder &nb)
Computes highway on-/off-ramps (if wished)
static void repairTopology(NBNetBuilder &nb)
static void assignDirectionPriority(NBNetBuilder &nb)
static void makeAllBidi(NBNetBuilder &nb)
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc, bool mayAddOrRemove)
Computes highway on-/off-ramps (if wished)
static void reportWarnings()
reports warnings if any occurred
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void setOpenDriveSignalParameters()
set OpenDRIVE signal reference parameters after all link indices are known
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
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 isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
void resetWritable()
Resets all options to be writeable.
static OptionsCont & getOptions()
Retrieves the options.
A point in 2D or 3D with translation and scaling methods.
void setz(double z)
set position z
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(const std::string &str) const
static long getCurrentMillis()
Returns the current time in milliseconds.