82 const bool lefthand = oc.
getBool(
"lefthand");
90 int numRemovedEdges = 0;
93 if (mayAddOrRemove && oc.
exists(
"remove-edges.isolated") && oc.
getBool(
"remove-edges.isolated")) {
98 if (mayAddOrRemove && oc.
exists(
"keep-edges.components") && oc.
getInt(
"keep-edges.components") > 0) {
100 const bool hasStops = oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output") && !
myPTStopCont.getStops().empty();
104 if (mayAddOrRemove && oc.
exists(
"keep-edges.postload") && oc.
getBool(
"keep-edges.postload")) {
111 if (oc.
isSet(
"keep-edges.explicit") || oc.
isSet(
"keep-edges.input-file")) {
118 numRemovedEdges += removed;
123 numRemovedEdges += removed2;
127 if (mayAddOrRemove && oc.
getFloat(
"keep-lanes.min-width") > 0.) {
130 numRemovedEdges += removed;
134 if (mayAddOrRemove && oc.
exists(
"junctions.attach-removed") && oc.
getFloat(
"junctions.attach-removed") >= 0) {
143 if (!(oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output"))
144 && !oc.
getBool(
"ptstop-output.no-bidi")) {
151 if (mayAddOrRemove && oc.
exists(
"keep-edges.components") && oc.
getInt(
"keep-edges.components") > 0) {
156 if (numRemovedEdges > 0) {
172 int numAddedBidi = 0;
173 if (oc.
exists(
"railway.topology.all-bidi") && oc.
getBool(
"railway.topology.all-bidi")) {
176 }
else if (oc.
exists(
"railway.topology.repair") && oc.
getBool(
"railway.topology.repair")) {
179 oc.
getFloat(
"geometry.min-radius"),
false,
180 oc.
getBool(
"geometry.min-radius.fix.railways"),
true);
185 if (numAddedBidi > 0) {
189 if (oc.
exists(
"railway.topology.direction-priority") && oc.
getBool(
"railway.topology.direction-priority")) {
192 }
else if (oc.
exists(
"railway.topology.extend-priority")
193 && (oc.
getBool(
"railway.topology.extend-priority") || oc.
getStringVector(
"railway.topology.ptline-priority").size() > 0)) {
195 if (oc.
getStringVector(
"railway.topology.ptline-priority").size() > 0) {
201 if (oc.
exists(
"railway.topology.output") && oc.
isSet(
"railway.topology.output")) {
205 if (oc.
exists(
"railway.geometry.straighten") && oc.
getBool(
"railway.geometry.straighten")) {
211 if (mayAddOrRemove && oc.
exists(
"edges.join-tram-dist") && oc.
getFloat(
"edges.join-tram-dist") >= 0) {
216 if (numJoinedTramEdges > 0) {
220 if (oc.
getBool(
"junctions.join")
222 || oc.
getBool(
"tls.guess.joining")
223 || (oc.
exists(
"tls.guess-signals") && oc.
getBool(
"tls.guess-signals"))) {
233 if (oc.
getBool(
"roundabouts.guess")) {
236 const std::set<EdgeSet>& roundabouts =
myEdgeCont.getRoundabouts();
237 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
238 it_round != roundabouts.end(); ++it_round) {
239 std::vector<std::string> nodeIDs;
240 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
241 nodeIDs.push_back((*it_edge)->getToNode()->getID());
246 }
else if ((
myEdgeCont.hasGuessedRoundabouts() || oc.
getBool(
"crossings.guess")) && oc.
getBool(
"roundabouts.guess")) {
251 if (mayAddOrRemove && oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
255 if (mayAddOrRemove && oc.
getBool(
"junctions.join")) {
263 if (mayAddOrRemove && oc.
getFloat(
"junctions.join-same") >= 0) {
267 if (numJoined2 > 0) {
272 if (mayAddOrRemove && oc.
exists(
"join-lanes") && oc.
getBool(
"join-lanes")) {
279 if (mayAddOrRemove) {
280 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
292 for (std::map<std::string, NBNode*>::const_iterator it =
myNodeCont.begin(); it !=
myNodeCont.end(); ++it) {
293 boundary.
add(it->second->getPosition());
295 for (std::map<std::string, NBEdge*>::const_iterator it =
myEdgeCont.begin(); it !=
myEdgeCont.end(); ++it) {
296 boundary.
add(it->second->getGeometry().getBoxBoundary());
311 if (oc.
exists(
"geometry.min-dist") && !oc.
isDefault(
"geometry.min-dist")) {
318 if (mayAddOrRemove && oc.
getBool(
"edges.join")) {
320 const bool removeDuplicates = oc.
getFloat(
"junctions.join-same") >= 0;
323 if (oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove")) {
328 if (oc.
getBool(
"opposites.guess")) {
334 if (mayAddOrRemove && oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
339 if (oc.
getFloat(
"junctions.join-same") >= 0) {
341 if (numJoined3 > 0) {
351 if (oc.
exists(
"geometry.avoid-overlap") && oc.
getBool(
"geometry.avoid-overlap")) {
357 if (oc.
isSet(
"tls.set")) {
358 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
360 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
362 if (node ==
nullptr) {
363 WRITE_WARNING(
"Building a tl-logic for junction '" + *i +
"' is not possible." +
"\n The junction '" + *i +
"' is not known.");
373 const bool modifyRamps = mayAddOrRemove && (
375 || (oc.
exists(
"ramps.set") && oc.
isSet(
"ramps.set")));
376 if (modifyRamps || (oc.
exists(
"ramps.guess-acceleration-lanes") && oc.
getBool(
"ramps.guess-acceleration-lanes"))) {
390 if (mayAddOrRemove && ((oc.
getBool(
"bikelanes.guess") || oc.
getBool(
"bikelanes.guess.from-permissions")))) {
392 oc.
getFloat(
"bikelanes.guess.min-speed"),
393 oc.
getFloat(
"bikelanes.guess.max-speed"),
394 oc.
getBool(
"bikelanes.guess.from-permissions"),
395 "bikelanes.guess.exclude",
401 if (mayAddOrRemove && ((oc.
getBool(
"sidewalks.guess") || oc.
getBool(
"sidewalks.guess.from-permissions")))) {
403 oc.
getFloat(
"sidewalks.guess.min-speed"),
404 oc.
getFloat(
"sidewalks.guess.max-speed"),
405 oc.
getBool(
"sidewalks.guess.from-permissions"),
406 "sidewalks.guess.exclude",
414 if (mayAddOrRemove) {
415 const bool numericalIDs = oc.
getBool(
"numerical-ids");
416 const bool reservedIDs = oc.
isSet(
"reserved-ids");
417 const bool keptIDs = oc.
isSet(
"kept-ids");
420 if (numChangedEdges + numChangedNodes > 0) {
426 if (oc.
exists(
"geometry.max-angle")) {
429 oc.
getBool(
"geometry.max-angle.fix"),
431 oc.
getBool(
"geometry.min-radius.fix"),
432 oc.
getBool(
"geometry.min-radius.fix.railways"));
443 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
458 if (oc.
exists(
"speed.offset")) {
459 const double speedOffset = oc.
getFloat(
"speed.offset");
460 const double speedFactor = oc.
getFloat(
"speed.factor");
461 const double speedMin = oc.
getFloat(
"speed.minimum");
462 if (speedOffset != 0 || speedFactor != 1 || speedMin > 0) {
465 NBEdge*
const e = it.second;
482 if (mayAddOrRemove && oc.
getBool(
"crossings.guess")) {
485 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
486 crossings += (*i).second->guessCrossings();
491 bool haveValidCrossings =
false;
493 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
494 if (i->second->getCrossings().size() > 0) {
496 haveValidCrossings =
true;
498 }
else if (i->second->getCrossingsIncludingInvalid().size() > 0) {
505 oc.
set(
"walkingareas",
"true");
512 oc.
set(
"no-internal-links",
"false");
524 if (oc.
getBool(
"roundabouts.guess")) {
526 const int numGuessed =
myEdgeCont.guessRoundabouts();
527 if (numGuessed > 0) {
543 if (oc.
getBool(
"fringe.guess")) {
545 const int numGuessed =
myNodeCont.guessFringe();
546 if (numGuessed > 0) {
553 if (!oc.
getBool(
"no-turnarounds")) {
555 oc.
getBool(
"no-turnarounds.tls"),
556 oc.
getBool(
"no-turnarounds.fringe"),
557 oc.
getBool(
"no-turnarounds.except-deadend"),
558 oc.
getBool(
"no-turnarounds.except-turnlane"),
559 oc.
getBool(
"no-turnarounds.geometry"));
561 myEdgeCont.appendTurnarounds(explicitTurnarounds, oc.
getBool(
"no-turnarounds.tls"));
563 if (oc.
exists(
"railway.topology.repair.stop-turn") && oc.
getBool(
"railway.topology.repair.stop-turn")
575 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
576 i->second->buildCrossingsAndWalkingAreas();
579 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
582 i->second->discardWalkingareas();
584 if (oc.
getBool(
"no-internal-links")) {
585 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
586 i->second->discardAllCrossings(
false);
601 if (oc.
exists(
"opendrive-files") && oc.
isSet(
"opendrive-files")) {
602 myTLLCont.setOpenDriveSignalParameters();
612 std::pair<int, int> numbers =
myTLLCont.computeLogics(oc);
614 std::string progCount =
"";
615 if (numbers.first != numbers.second) {
616 progCount =
"(" +
toString(numbers.second) +
" programs) ";
619 if (oc.
exists(
"opendrive-files") && oc.
isSet(
"opendrive-files") && oc.
getBool(
"opendrive.signal-groups")) {
623 for (std::map<std::string, NBEdge*>::const_iterator i =
myEdgeCont.begin(); i !=
myEdgeCont.end(); ++i) {
624 (*i).second->sortOutgoingConnectionsByIndex();
627 std::set<NBTrafficLightDefinition*> largeNodeTLS;
628 if (!oc.
getBool(
"no-internal-links")) {
633 const std::set<NBTrafficLightDefinition*>& tlDefs = item.second->getControllingTLS();
634 largeNodeTLS.insert(tlDefs.begin(), tlDefs.end());
640 if (oc.
getFloat(
"junctions.scurve-stretch") > 0) {
647 item.second->buildInnerEdges();
670 if (oc.
isSet(
"street-sign-output")) {
677 if (lefthand != oc.
getBool(
"flip-y-axis")) {
681 if (oc.
exists(
"geometry.check-overlap") && oc.
getFloat(
"geometry.check-overlap") > 0) {
698 int numBidiStops = 0;
699 if (!oc.
getBool(
"ptstop-output.no-bidi")) {
705 double maxRadius = oc.
getFloat(
"railway.access-distance");
706 double accessFactor = oc.
getFloat(
"railway.access-factor");
707 int maxCount = oc.
getInt(
"railway.max-accesses");
710 if (numBidiStops > 0) {
717 if (oc.
exists(
"ptline-clean-up") && oc.
getBool(
"ptline-clean-up")) {
719 std::set<std::string> usedStops =
myPTLineCont.getServedPTStops();
724 if (numDeletedStops > 0) {
725 WRITE_WARNINGF(
TL(
"Removed % pt stops because they could not be assigned to the network"),
toString(numDeletedStops));
729 if (oc.
exists(
"ignore-change-restrictions") && !oc.
isDefault(
"ignore-change-restrictions")) {
731 myEdgeCont.updateAllChangeRestrictions(ignoring);
738 WRITE_WARNING(
TL(
"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"));
742 if (oc.
exists(
"osm-files") && oc.
isSet(
"osm-files")) {
754 const double x = -boundary.
xmin();
755 const double y = -(lefthand ? boundary.
ymax() : boundary.
ymin());
759 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
760 (*i).second->reshiftPosition(x, y);
762 for (std::map<std::string, NBEdge*>::const_iterator i =
myEdgeCont.begin(); i !=
myEdgeCont.end(); ++i) {
763 (*i).second->reshiftPosition(x, y);
766 (*i).second->reshiftPosition(x, y);
769 stopIt.second->reshiftPosition(x, y);
780 item.second->roundSpeed();
784 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
785 (*i).second->roundGeometry();
787 for (std::map<std::string, NBEdge*>::const_iterator i =
myEdgeCont.begin(); i !=
myEdgeCont.end(); ++i) {
788 (*i).second->roundGeometry();
796 for (std::map<std::string, NBNode*>::const_iterator i =
myNodeCont.begin(); i !=
myNodeCont.end(); ++i) {
797 (*i).second->mirrorX();
799 for (std::map<std::string, NBEdge*>::const_iterator i =
myEdgeCont.begin(); i !=
myEdgeCont.end(); ++i) {
800 (*i).second->mirrorX();
803 (*i).second->mirrorX();
806 stopIt.second->mirrorX();
817 && from_srs !=
nullptr
843 const double eps = 1e-6;
844 from.
set(std::round(from.
x() / eps) * eps, std::round(from.
y() / eps) * eps, std::round(from.
z() / eps) * eps);
852 if (maxLength > 0 && from.size() > 1) {
855 for (
int i = 0; i < (int) from.size(); i++) {
861 for (
int i = 0; i < (int) from.size(); i++) {
873 for (
int i = 0; i < (int)cartesian.size() - 1; i++) {
874 Position start = from[i + inserted];
875 Position end = from[i + inserted + 1];
876 double length = cartesian[i].distanceTo(cartesian[i + 1]);
877 const Position step = (end - start) * (maxLength / length);
879 while (length > maxLength) {
882 from.insert(from.begin() + i + inserted + 1, start + (step * steps));
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#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...
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ 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
const Position getOffset() const
Returns the network offset.
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.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
static int getNumLoaded()
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.
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
The representation of a single edge during network building.
double getLaneSpeed(int lane) const
get lane speed
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
int getNumLanes() const
Returns the number of lanes.
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
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
void roundInputs()
ensure consistency between input and output geometries and speeds
void mirrorX()
mirror the network along the X-axis
NBNetBuilder()
Constructor.
NBTrafficLightLogicCont myTLLCont
The used container for traffic light logics.
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.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
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
Represents a single node (junction) during network building.
static void initRailSignalClasses(const NBNodeCont &nc)
initialize signalized rail classes
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.
static int straigthenCorrdidor(NBEdgeCont &ec, double maxAngle)
static int guessRailSignals(NBNodeCont &nc, NBEdgeCont &ec, NBPTStopCont &sc, NBDistrictCont &dc)
static int repairTopology(NBEdgeCont &ec, NBPTStopCont &sc, NBPTLineCont &lc)
static void extendDirectionPriority(NBEdgeCont &ec, bool fromUniDir)
static void analyzeTopology(NBEdgeCont &ec)
static void setPTLinePriority(NBEdgeCont &ec, NBPTLineCont &lc, SVCPermissions vClasses)
static int makeAllBidi(NBEdgeCont &ec)
void computeRamps(NBNetBuilder &nb, OptionsCont &oc, bool mayAddOrRemove)
static void reportWarnings()
reports warnings if any occurred
The base class for traffic light logic definitions.
static const std::string OSM_DIRECTION
processing parameter for rail signal edges and nodes
static const int MIN_YELLOW_SECONDS
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist).
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).
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 set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
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 set(double x, double y)
set positions x and y
double x() const
Returns the x-position.
void setz(double z)
set position z
double z() const
Returns the z-position.
double y() const
Returns the y-position.
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static long getCurrentMillis()
Returns the current time in milliseconds.