57 #include <internal/HeightMapper.h>
60 #ifdef CHECK_MEMORY_LEAKS
62 #endif // CHECK_MEMORY_LEAKS
69 myEdgeCont(myTypeCont),
70 myHaveSeenRoundabouts(false)
80 if (oc.
isSet(
"keep-edges.input-file")) {
81 std::ifstream strm(oc.
getString(
"keep-edges.input-file").c_str());
83 throw ProcessError(
"Could not load names of edges too keep from '" + oc.
getString(
"keep-edges.input-file") +
"'.");
85 std::ostringstream oss;
96 oc.
set(
"keep-edges.explicit", oss.str());
109 const std::set<std::string>& explicitTurnarounds,
110 bool removeElements) {
121 if (oc.
exists(
"remove-edges.isolated") && oc.
getBool(
"remove-edges.isolated")) {
127 if (oc.
exists(
"keep-edges.postload") && oc.
getBool(
"keep-edges.postload")) {
128 if (oc.
isSet(
"keep-edges.explicit")) {
135 if (oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
139 if (oc.
getBool(
"junctions.join")) {
152 for (std::vector<EdgeVector>::const_iterator it_round =
myRoundabouts.begin();
154 std::vector<std::string> nodeIDs;
155 for (EdgeVector::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
156 nodeIDs.push_back((*it_edge)->getToNode()->getID());
164 myEdgeCont.computeLaneShapes();
172 if (removeElements) {
174 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
175 PROGRESS_BEGIN_MESSAGE(
"Removing empty nodes" + std::string(removeGeometryNodes ?
" and geometry nodes" :
""));
185 boundary.
add(it->second->getPosition());
188 boundary.
add(it->second->getGeometry().getBoxBoundary());
197 if (oc.
exists(
"geometry.min-dist") && oc.
isSet(
"geometry.min-dist")) {
204 if (removeElements) {
211 if (oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
227 if (oc.
exists(
"geometry.max-angle")) {
231 oc.
getBool(
"geometry.min-radius.fix"));
246 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
258 if (oc.
exists(
"speed.offset")) {
261 if (speedOffset != 0 || speedFactor != 1) {
264 (*i).second->setSpeed(-1, (*i).second->getSpeed() * speedFactor + speedOffset);
300 if (!oc.
getBool(
"no-turnarounds")) {
314 if (oc.
isSet(
"tls.set")) {
315 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
317 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
320 WRITE_WARNING(
"Building a tl-logic for node '" + *i +
"' is not possible." +
"\n The node '" + *i +
"' is not known.");
349 std::string progCount =
"";
350 if (numbers.first != numbers.second) {
351 progCount =
"(" +
toString(numbers.second) +
" programs) ";
355 if (oc.
isSet(
"street-sign-output")) {
362 if (!oc.
getBool(
"no-internal-links")) {
365 (*i).second->sortOutgoingConnectionsByIndex();
368 (*i).second->buildInnerEdges();
375 WRITE_MESSAGE(
"-----------------------------------------------------");
382 WRITE_MESSAGE(
"-----------------------------------------------------");
387 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");
399 (*i).second->reshiftPosition(x, y);
402 (*i).second->reshiftPosition(x, y);
405 (*i).second->reshiftPosition(x, y);
418 const HeightMapper& hm = HeightMapper::get();
437 if (maxLength > 0 && from.size() > 1) {
440 for (
int i = 0; i < (
int) from.size(); i++) {
446 for (
int i = 0; i < (
int)copy.size() - 1; i++) {
447 Position start = from[i + inserted];
448 Position end = from[i + inserted + 1];
449 SUMOReal length = copy[i].distanceTo(copy[i + 1]);
450 const Position step = (end - start) * (maxLength / length);
452 while (length > maxLength) {
455 from.
insertAt(i + inserted + 1, start + (step * steps));
463 for (
int i = 0; i < (
int) from.size(); i++) {
void moveToOrigin(GeoConvHelper &geoConvHelper)
shift network so its lower left corner is at 0,0
NBNetBuilder()
Constructor.
NBTypeCont myTypeCont
The used container for street types.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
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 setTLControllingInformation(const NBEdgeCont &ec)
Informs the edges about being controlled by a tls.
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
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 computeNodeShapes(bool leftHand, SUMOReal mismatchThreshold=-1)
Compute the junction shape for this node.
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
NBJoinedEdgesMap myJoinedEdges
Map of joined edges.
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
unsigned int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBJoinedEdgesMap &je, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
Removes "unwished" nodes.
void insertAt(int index, const Position &p)
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool removeElements=true)
Performs the network building steps.
unsigned int joinJunctions(SUMOReal maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins junctions that are very close together.
~NBNetBuilder()
Destructor.
SUMOReal ymin() const
Returns minimum y-coordinate.
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)
SUMOReal xmin() const
Returns minimum x-coordinate.
void generateStreetSigns()
assigns street signs to edges based on toNode types
void recheckPostProcessConnections()
Try to set any stored connections.
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
bool myHaveSeenRoundabouts
whether a sumo network with roundabout information was loaded
SUMOReal x() const
Returns the x-position.
#define UNUSED_PARAMETER(x)
SUMOReal xmax() const
Returns maximum x-coordinate.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix)
void computeLogics(const NBEdgeCont &ec, OptionsCont &oc)
build the list of outgoing edges and lanes
void guessRoundabouts(std::vector< EdgeVector > &marked)
Determines which edges belong to roundabouts and increases their priority.
static void computeFinal()
compute the location attributes which will be used for output based on the loaded location data...
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
void reduceGeometries(const SUMOReal minDist)
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::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)
void joinTLS(NBTrafficLightLogicCont &tlc, SUMOReal maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
static StringBijection< TrafficLightType > TrafficLightTypes
A point in 2D or 3D with translation and scaling methods.
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.
void setDefaults(int defaultNoLanes, SUMOReal defaultSpeed, int defaultPriority)
Sets the default values.
NBEdgeCont myEdgeCont
The used container for edges.
unsigned int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
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.
std::vector< EdgeVector > myRoundabouts
Edges marked as belonging to a roundabout (each EdgeVector is a roundabout)
static void computeTurnDirections(NBNodeCont &nc)
Computes turnaround destinations for all edges (if exist)
#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.
std::pair< unsigned int, unsigned int > computeLogics(NBEdgeCont &ec, OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
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.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
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.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
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.
static void computeNodeTypes(NBNodeCont &nc)
Computes node types.
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
SUMOReal y() const
Returns the y-position.
A storage for options typed value containers)
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
NBDistrictCont myDistrictCont
The used container for districts.
SUMOReal ymax() const
Returns maximum y-coordinate.
const Boundary & getOrigBoundary() const
Returns the original boundary.
void init(NBEdgeCont &ec)
Initialises the map using the list of edge names.
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.
#define PROGRESS_DONE_MESSAGE()
static void sortNodesEdges(NBNodeCont &nc, bool leftHand)
Sorts a node's edges clockwise regarding driving direction.
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
#define WRITE_MESSAGE(msg)
NBNodeCont myNodeCont
The used container for nodes.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
void moveConvertedBy(SUMOReal x, SUMOReal y)
Shifts the converted boundary by the given amounts.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.