 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
56 myEdgeCont(myTypeCont),
57 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"))) {
117 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
123 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
124 if (oc.
exists(
"ptline-clean-up") && oc.
getBool(
"ptline-clean-up")) {
130 if (numDeletedStops > 0) {
131 WRITE_WARNING(
"Removed " +
toString(numDeletedStops) +
" pt stops because they could not be assigned to the network");
136 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
143 if (oc.
exists(
"railway.topology.all-bidi") && oc.
getBool(
"railway.topology.all-bidi")) {
146 }
else if (oc.
exists(
"railway.topology.repair") && oc.
getBool(
"railway.topology.repair")) {
149 oc.
getFloat(
"geometry.min-radius"),
false,
150 oc.
getBool(
"geometry.min-radius.fix.railways"),
true);
154 if (oc.
exists(
"railway.topology.output") && oc.
isSet(
"railway.topology.output")) {
169 if (oc.
getBool(
"roundabouts.guess")) {
173 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
174 it_round != roundabouts.end(); ++it_round) {
175 std::vector<std::string> nodeIDs;
176 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
177 nodeIDs.push_back((*it_edge)->getToNode()->getID());
184 if (mayAddOrRemove && oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
188 if (mayAddOrRemove && oc.
getBool(
"junctions.join")) {
202 if (mayAddOrRemove && oc.
exists(
"join-lanes") && oc.
getBool(
"join-lanes")) {
209 if (mayAddOrRemove) {
211 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
224 boundary.
add(it->second->getPosition());
227 boundary.
add(it->second->getGeometry().getBoxBoundary());
236 if (oc.
exists(
"geometry.min-dist") && !oc.
isDefault(
"geometry.min-dist")) {
243 if (mayAddOrRemove && oc.
getBool(
"edges.join")) {
248 if (oc.
getBool(
"opposites.guess")) {
254 if (mayAddOrRemove && oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
264 if (oc.
exists(
"geometry.avoid-overlap") && oc.
getBool(
"geometry.avoid-overlap")) {
270 if (oc.
isSet(
"tls.set")) {
271 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
273 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
275 if (node ==
nullptr) {
276 WRITE_WARNING(
"Building a tl-logic for junction '" + *i +
"' is not possible." +
"\n The junction '" + *i +
"' is not known.");
286 if (mayAddOrRemove) {
287 const bool modifyRamps = (oc.
exists(
"ramps.guess") && oc.
getBool(
"ramps.guess"))
288 || (oc.
exists(
"ramps.set") && oc.
isSet(
"ramps.set"));
290 || (oc.
exists(
"ramps.guess-acceleration-lanes") && oc.
getBool(
"ramps.guess-acceleration-lanes"))) {
303 if (mayAddOrRemove && ((oc.
getBool(
"bikelanes.guess") || oc.
getBool(
"bikelanes.guess.from-permissions")))) {
305 oc.
getFloat(
"bikelanes.guess.min-speed"),
306 oc.
getFloat(
"bikelanes.guess.max-speed"),
307 oc.
getBool(
"bikelanes.guess.from-permissions"),
308 "bikelanes.guess.exclude");
313 if (mayAddOrRemove && ((oc.
getBool(
"sidewalks.guess") || oc.
getBool(
"sidewalks.guess.from-permissions")))) {
315 oc.
getFloat(
"sidewalks.guess.min-speed"),
316 oc.
getFloat(
"sidewalks.guess.max-speed"),
317 oc.
getBool(
"sidewalks.guess.from-permissions"),
318 "sidewalks.guess.exclude");
328 if (numChangedEdges + numChangedNodes > 0) {
333 if (oc.
exists(
"geometry.max-angle")) {
337 oc.
getBool(
"geometry.min-radius.fix"),
338 oc.
getBool(
"geometry.min-radius.fix.railways"));
349 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
364 if (oc.
exists(
"speed.offset")) {
365 const double speedOffset = oc.
getFloat(
"speed.offset");
366 const double speedFactor = oc.
getFloat(
"speed.factor");
367 const double speedMin = oc.
getFloat(
"speed.minimum");
368 if (speedOffset != 0 || speedFactor != 1 || speedMin > 0) {
371 (*i).second->setSpeed(-1,
MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
384 if (mayAddOrRemove && oc.
getBool(
"crossings.guess")) {
388 crossings += (*i).second->guessCrossings();
395 if (i->second->getCrossingsIncludingInvalid().size() > 0) {
405 oc.
set(
"no-internal-links",
"false");
417 if (oc.
getBool(
"roundabouts.guess")) {
420 if (numGuessed > 0) {
437 if (!oc.
getBool(
"no-turnarounds")) {
442 if (oc.
exists(
"railway.topology.repair") && oc.
getBool(
"railway.topology.repair")
455 i->second->buildCrossingsAndWalkingAreas();
461 i->second->discardWalkingareas();
463 if (oc.
getBool(
"no-internal-links")) {
465 i->second->discardAllCrossings(
false);
489 std::string progCount =
"";
490 if (numbers.first != numbers.second) {
491 progCount =
"(" +
toString(numbers.second) +
" programs) ";
495 if (oc.
isSet(
"street-sign-output")) {
502 (*i).second->sortOutgoingConnectionsByIndex();
505 if (!oc.
getBool(
"no-internal-links")) {
509 (*i).second->buildInnerEdges();
514 if (oc.
getFloat(
"junctions.scurve-stretch") > 0) {
521 (*i).second->buildInnerEdges();
532 if (oc.
exists(
"geometry.check-overlap") && oc.
getFloat(
"geometry.check-overlap") > 0) {
545 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
549 double maxRadius = oc.
getFloat(
"railway.access-distance");
550 double accessFactor = oc.
getFloat(
"railway.access-factor");
551 int maxCount = oc.
getInt(
"railway.max-accesses");
554 if (numBidiStops > 0) {
555 if (oc.
exists(
"ptline-output") && oc.
isSet(
"ptline-output")) {
562 WRITE_MESSAGE(
"-----------------------------------------------------");
569 WRITE_MESSAGE(
"-----------------------------------------------------");
574 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");
595 const double x = -boundary.
xmin();
596 const double y = -(lefthand ? boundary.
ymax() : boundary.
ymin());
601 (*i).second->reshiftPosition(x, y);
604 (*i).second->reshiftPosition(x, y);
607 (*i).second->reshiftPosition(x, y);
610 (*i).second->reshiftPosition(x, y);
621 (*i).second->mirrorX();
624 (*i).second->mirrorX();
627 (*i).second->mirrorX();
638 && from_srs !=
nullptr
651 double z = hm.
getZ(orig);
662 if (maxLength > 0 && from.size() > 1) {
665 for (
int i = 0; i < (int) from.size(); i++) {
671 for (
int i = 0; i < (int) from.size(); i++) {
682 for (
int i = 0; i < (int)cartesian.size() - 1; i++) {
683 Position start = from[i + inserted];
684 Position end = from[i + inserted + 1];
685 double length = cartesian[i].distanceTo(cartesian[i + 1]);
686 const Position step = (end - start) * (maxLength / length);
688 while (length > maxLength) {
691 from.insert(from.begin() + i + inserted + 1, start + (step * steps));
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc, NBPTLineCont &lc, NBParkingCont &pc, bool removeGeometryNodes)
Removes "unwished" nodes.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static void validateRailCrossings(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Checks rail_crossing for validity.
@ SVC_PEDESTRIAN
pedestrian
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
double getZRange() const
Returns the elevation range of the boundary (z-axis)
void computeNodeShapes(double mismatchThreshold=-1)
Compute the junction shape for this node.
static void makeAllBidi(NBNetBuilder &nb)
void mirrorX()
mirror the network along the X-axis
NBNetBuilder()
Constructor.
#define WRITE_WARNING(msg)
const Boundary & getConvBoundary() const
Returns the converted boundary.
static const NBHeightMapper & get()
return the singleton instance (maybe 0)
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
NBPTStopCont myPTStopCont
The used container for pt stops.
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
void localizePTStops(NBEdgeCont &cont)
void process(NBEdgeCont &ec, NBPTStopCont &sc)
double ymin() const
Returns minimum y-coordinate.
void setDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
NBPTLineCont myPTLineCont
The used container for pt stops.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Set z-values for all network positions based on data from a height map.
void resetWritable()
Resets all options to be writeable.
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool ready() const
returns whether the NBHeightMapper has data
std::map< std::string, NBPTStop * >::const_iterator begin() const
Returns the pointer to the begin of the stored pt stops.
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
NBTypeCont myTypeCont
The used container for street types.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void checkGrade(double threshold) const
check whether edges are to steep
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
double xmax() const
Returns maximum x-coordinate.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void removeComponents(NBDistrictCont &dc, NBEdgeCont &ec, const int numKeep)
Checks the network for weak connectivity and removes all but the largest components....
@ SVC_BICYCLE
vehicle is a bicycle
void avoidOverlap()
fix overlap
static OptionsCont & getOptions()
Retrieves the options.
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
#define PROGRESS_TIME_MESSAGE(before)
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix)
remap node IDs accoring to options –numerical-ids and –reserved-ids
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
static methods for processing the coordinates conversion for the current net
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix, NBPTStopCont &sc)
remap node IDs accoring to options –numerical-ids and –reserved-ids
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
void fixBidiStops(const NBEdgeCont &ec)
select the correct stop on superposed rail edges
static long getCurrentMillis()
Returns the current time in milliseconds.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
void moveConvertedBy(double x, double y)
Shifts the converted boundary by the given amounts.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
double xmin() const
Returns minimum x-coordinate.
void generateStreetSigns()
assigns street signs to edges based on toNode types
std::set< std::string > & getServedPTStops()
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same)
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
bool myNetworkHaveCrossings
flag to indicate that network has crossings
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
T get(const std::string &str) const
NBTrafficLightLogicCont myTLLCont
The used container for traffic light logics.
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
static void repairTopology(NBNetBuilder &nb)
A class that stores a 2D geometrical boundary.
void recheckPostProcessConnections()
Try to set any stored connections.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
const Boundary & getOrigBoundary() const
Returns the original boundary.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
const Position getOffsetBase() const
Returns the network base.
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
A storage for options typed value containers)
void joinTLS(NBTrafficLightLogicCont &tlc, double maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
void splitGeometry(NBDistrictCont &dc, NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
void appendTurnarounds(bool noTLSControlled, bool onlyDeadends, bool noGeometryLike)
Appends turnarounds to all edges stored in the container.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
std::map< std::string, NBPTStop * >::const_iterator end() const
Returns the pointer to the end of the stored pt stops.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void appendRailwayTurnarounds(const NBPTStopCont &sc)
Appends turnarounds to all bidiRail edges with stops.
void computeLogics(const NBEdgeCont &ec)
build the list of outgoing edges and lanes
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
void moveToOrigin(GeoConvHelper &geoConvHelper, bool lefthand)
shift network so its lower left corner is at 0,0
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
const std::map< std::string, NBPTStop * > & getStops() const
NBEdgeCont myEdgeCont
The used container for edges.
void reduceGeometries(const double minDist)
NBDistrictCont myDistrictCont
The used container for districts.
double y() const
Returns the y-position.
#define PROGRESS_BEGIN_MESSAGE(msg)
static void analyzeTopology(NBNetBuilder &nb)
Computes highway on-/off-ramps (if wished)
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
#define PROGRESS_DONE_MESSAGE()
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data,...
void computeEdgeShapes(double smoothElevationThreshold=-1)
Computes the shapes of all edges stored in the container.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static int addGeometrySegments(PositionVector &from, const PositionVector &cartesian, const double maxLength)
insertion geometry points to ensure maximum segment length between points
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
int joinLanes(SVCPermissions perms)
join adjacent lanes with the given permissions
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc)
Computes highway on-/off-ramps (if wished)
static bool runningNetedit()
whether netbuilding takes place in the context of NETEDIT
NBParkingCont myParkingCont
void assignLanes(NBEdgeCont &cont)
int joinJunctions(double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc)
Joins junctions that are very close together.
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
int generateBidiStops(NBEdgeCont &cont)
duplicate stops for superposed rail edges and return the number of generated stops
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
void guessOpposites()
Sets opposite lane information for geometrically close edges.
void checkGeometries(const double maxAngle, const double minRadius, bool fix, bool fixRailways, bool silent=false)
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
Represents a single node (junction) during network building.
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
void postprocess(std::set< std::string > &usedStops)
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
@ SVC_IGNORING
vehicles ignoring classes
void findAccessEdgesForRailStops(NBEdgeCont &cont, double maxRadius, int maxCount, double accessFactor)
double getZ(const Position &geo) const
returns height for the given geo coordinate (WGS84)
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
static void reportWarnings()
reports warnings if any occurred
static void computeNodeTypes(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Computes node types.
#define WRITE_MESSAGE(msg)
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
NBNodeCont myNodeCont
The used container for nodes.
double ymax() const
Returns maximum y-coordinate.
void computeLogics2(const NBEdgeCont &ec, OptionsCont &oc)
compute right-of-way logic for all lane-to-lane connections
~NBNetBuilder()
Destructor.
static int getNumLoaded()