63 myEdgeCont(myTypeCont),
64 myHaveLoadedNetworkWithoutInternalEdges(false),
65 myNetworkHaveCrossings(false) {
88 const bool lefthand = oc.
getBool(
"lefthand");
101 if (oc.
exists(
"remove-edges.isolated") && oc.
getBool(
"remove-edges.isolated")) {
108 if (oc.
exists(
"keep-edges.postload") && oc.
getBool(
"keep-edges.postload")) {
109 if (oc.
isSet(
"keep-edges.explicit") || oc.
isSet(
"keep-edges.input-file")) {
126 if (oc.
getBool(
"roundabouts.guess")) {
130 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
131 it_round != roundabouts.end(); ++it_round) {
132 std::vector<std::string> nodeIDs;
133 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
134 nodeIDs.push_back((*it_edge)->getToNode()->getID());
140 if (oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
144 if (oc.
getBool(
"junctions.join")) {
159 if (mayAddOrRemove) {
161 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
163 PROGRESS_BEGIN_MESSAGE(
"Removing empty nodes" + std::string(removeGeometryNodes ?
" and geometry nodes" :
""));
175 boundary.
add(it->second->getPosition());
178 boundary.
add(it->second->getGeometry().getBoxBoundary());
187 if (oc.
exists(
"geometry.min-dist") && !oc.
isDefault(
"geometry.min-dist")) {
195 if (mayAddOrRemove && oc.
getBool(
"edges.join")) {
201 if (oc.
getBool(
"opposites.guess")) {
207 if (mayAddOrRemove && oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
221 if (mayAddOrRemove) {
231 if (oc.
getBool(
"sidewalks.guess") || oc.
getBool(
"sidewalks.guess.from-permissions")) {
233 oc.
getFloat(
"sidewalks.guess.min-speed"),
234 oc.
getFloat(
"sidewalks.guess.max-speed"),
235 oc.
getBool(
"sidewalks.guess.from-permissions"));
245 if (numChangedEdges + numChangedNodes > 0) {
250 if (oc.
exists(
"geometry.max-angle")) {
254 oc.
getBool(
"geometry.min-radius.fix"));
267 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
283 if (oc.
exists(
"speed.offset")) {
284 const double speedOffset = oc.
getFloat(
"speed.offset");
285 const double speedFactor = oc.
getFloat(
"speed.factor");
286 if (speedOffset != 0 || speedFactor != 1) {
287 const double speedMin = oc.
getFloat(
"speed.minimum");
291 (*i).second->setSpeed(-1,
MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
305 if (oc.
getBool(
"crossings.guess")) {
309 crossings += (*i).second->guessCrossings();
316 if (i->second->getCrossings().size() > 0) {
324 oc.
set(
"no-internal-links",
"true");
328 oc.
set(
"no-internal-links",
"false");
342 if (oc.
getBool(
"roundabouts.guess")) {
346 if (numGuessed > 0) {
366 if (!oc.
getBool(
"no-turnarounds")) {
380 i->second->buildCrossingsAndWalkingAreas();
387 if (oc.
isSet(
"tls.set")) {
388 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
390 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
393 WRITE_WARNING(
"Building a tl-logic for junction '" + *i +
"' is not possible." +
"\n The junction '" + *i +
"' is not known.");
426 std::string progCount =
"";
427 if (numbers.first != numbers.second) {
428 progCount =
"(" +
toString(numbers.second) +
" programs) ";
432 if (oc.
isSet(
"street-sign-output")) {
440 (*i).second->sortOutgoingConnectionsByIndex();
443 if (!oc.
getBool(
"no-internal-links")) {
448 (*i).second->buildInnerEdges();
453 if (oc.
getFloat(
"junctions.scurve-stretch") > 0) {
461 (*i).second->buildInnerEdges();
469 if (oc.
exists(
"geometry.check-overlap") && oc.
getFloat(
"geometry.check-overlap") > 0) {
482 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
490 WRITE_MESSAGE(
"-----------------------------------------------------");
497 WRITE_MESSAGE(
"-----------------------------------------------------");
502 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");
512 const bool lefthand = oc.
getBool(
"lefthand");
522 if (oc.
exists(
"remove-edges.isolated") && oc.
getBool(
"remove-edges.isolated")) {
526 if (oc.
exists(
"keep-edges.postload") && oc.
getBool(
"keep-edges.postload")) {
527 if (oc.
isSet(
"keep-edges.explicit") || oc.
isSet(
"keep-edges.input-file")) {
541 if (oc.
getBool(
"roundabouts.guess")) {
545 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
546 it_round != roundabouts.end(); ++it_round) {
547 std::vector<std::string> nodeIDs;
548 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
549 nodeIDs.push_back((*it_edge)->getToNode()->getID());
555 if (oc.
exists(
"junctions.join-exclude") && oc.
isSet(
"junctions.join-exclude")) {
559 if (oc.
getBool(
"junctions.join")) {
567 if (mayAddOrRemove) {
568 const bool removeGeometryNodes = oc.
exists(
"geometry.remove") && oc.
getBool(
"geometry.remove");
579 boundary.
add(it->second->getGeometry().getBoxBoundary());
588 if (oc.
exists(
"geometry.min-dist") && !oc.
isDefault(
"geometry.min-dist")) {
593 if (mayAddOrRemove && oc.
getBool(
"edges.join")) {
596 if (oc.
getBool(
"opposites.guess")) {
600 if (mayAddOrRemove && oc.
exists(
"geometry.split") && oc.
getBool(
"geometry.split")) {
608 if (mayAddOrRemove) {
615 if (oc.
getBool(
"sidewalks.guess") || oc.
getBool(
"sidewalks.guess.from-permissions")) {
617 oc.
getFloat(
"sidewalks.guess.min-speed"),
618 oc.
getFloat(
"sidewalks.guess.max-speed"),
619 oc.
getBool(
"sidewalks.guess.from-permissions"));
630 if (oc.
exists(
"geometry.max-angle")) {
634 oc.
getBool(
"geometry.min-radius.fix"));
642 if (oc.
exists(
"geometry.junction-mismatch-threshold")) {
654 if (oc.
exists(
"speed.offset")) {
655 const double speedOffset = oc.
getFloat(
"speed.offset");
656 const double speedFactor = oc.
getFloat(
"speed.factor");
657 if (speedOffset != 0 || speedFactor != 1) {
658 const double speedMin = oc.
getFloat(
"speed.minimum");
660 (*i).second->setSpeed(-1,
MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
670 if (oc.
getBool(
"crossings.guess")) {
683 oc.
set(
"no-internal-links",
"true");
687 oc.
set(
"no-internal-links",
"false");
695 if (oc.
getBool(
"roundabouts.guess")) {
705 if (!oc.
getBool(
"no-turnarounds")) {
718 if (oc.
isSet(
"tls.set")) {
719 std::vector<std::string> tlControlledNodes = oc.
getStringVector(
"tls.set");
721 for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
740 std::string progCount =
"";
741 if (numbers.first != numbers.second) {
742 progCount =
"(" +
toString(numbers.second) +
" programs) ";
745 if (oc.
isSet(
"street-sign-output")) {
750 (*i).second->sortOutgoingConnectionsByIndex();
753 if (!oc.
getBool(
"no-internal-links")) {
758 if (oc.
getFloat(
"junctions.scurve-stretch") > 0) {
769 if (oc.
exists(
"geometry.check-overlap") && oc.
getFloat(
"geometry.check-overlap") > 0) {
776 if (oc.
exists(
"ptstop-output") && oc.
isSet(
"ptstop-output")) {
787 const double x = -boundary.
xmin();
788 const double y = -(lefthand ? boundary.
ymax() : boundary.
ymin());
793 (*i).second->reshiftPosition(x, y);
796 (*i).second->reshiftPosition(x, y);
799 (*i).second->reshiftPosition(x, y);
802 (*i).second->reshiftPostion(x, y);
813 (*i).second->mirrorX();
816 (*i).second->mirrorX();
819 (*i).second->mirrorX();
834 double z = hm.
getZ(orig);
845 if (maxLength > 0 && from.size() > 1) {
848 for (
int i = 0; i < (int) from.size(); i++) {
854 for (
int i = 0; i < (int)copy.size() - 1; i++) {
855 Position start = from[i + inserted];
856 Position end = from[i + inserted + 1];
857 double length = copy[i].distanceTo(copy[i + 1]);
858 const Position step = (end - start) * (maxLength / length);
860 while (length > maxLength) {
863 from.insert(from.begin() + i + inserted + 1, start + (step * steps));
871 for (
int i = 0; i < (int) from.size(); i++) {
NBNetBuilder()
Constructor.
NBTypeCont myTypeCont
The used container for street types.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
NBPTStopCont myPTStopCont
The used container for pt stops.
double ymin() const
Returns minimum y-coordinate.
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same) ...
double xmax() const
Returns maximum x-coordinate.
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 setConvBoundary(const Boundary &boundary)
sets the converted boundary
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
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...
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
void reduceGeometries(const double minDist)
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
Removes "unwished" nodes.
void mirrorX()
mirror the network along the X-axis
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.
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data...
~NBNetBuilder()
Destructor.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool x2cartesian(Position &from, bool includeInBoundary=true)
double y() const
Returns the y-position.
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
void guessOpposites()
Sets opposite lane information for geometrically close edges.
double x() const
Returns the x-position.
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
const Boundary & getOrigBoundary() const
Returns the original boundary.
static void computeSingleNodeType(NBNode *node)
Computes a single node type.
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.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void avoidOverlap()
fix overlap
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
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)
void sortEdges(bool useNodeShape)
sort all edge containers for this node
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 checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
void computeLogics(const NBEdgeCont &ec, OptionsCont &oc)
build the list of outgoing edges and lanes
void checkGrade(double threshold) const
check whether edges are to steep
static const NBHeightMapper & get()
return the singleton instance (maybe 0)
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static void reportWarnings()
reports warnings if any occured
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
#define PROGRESS_TIME_MESSAGE(before)
void computeLanes2Lanes()
computes the connections of lanes to edges
void computeNodeShape(double mismatchThreshold)
Compute the junction shape for this node.
std::map< std::string, NBPTStop * >::const_iterator begin() const
Returns the pointer to the begin of the stored pt stops.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
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)
void buildCrossingsAndWalkingAreas(bool discardInvalid=true)
build crossings, and walkingareas. Also removes invalid loaded crossings if wished ...
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
void computeSingleNode(NBNode *node, OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps only for a single Node.
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.
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.
T get(const std::string &str) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool myNetworkHaveCrossings
flag to indicate that network has crossings
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.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
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) ...
double xmin() const
Returns minimum x-coordinate.
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 std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
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.
std::map< std::string, NBPTStop * >::const_iterator end() const
Returns the pointer to the end of the stored pt stops.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any) ...
void avoidOverlap()
fix overlap
void process(NBEdgeCont &cont)
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.
int removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes edges which are both incoming and outgoing into this node.
static void computeEdgePrioritiesSingleNode(NBNode *node)
Computes edge priorities within a single node.
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
void buildInnerEdges()
build internal lanes, pedestrian crossings and walking areas
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
A storage for options typed value containers)
const Position getOffsetBase() const
Returns the network base.
void computeEdgeShapes()
Computes the shapes of all edges stored in the container.
const Position & getPosition() const
Represents a single node (junction) during network building.
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
int guessCrossings()
guess pedestrian crossings and return how many were guessed
NBDistrictCont myDistrictCont
The used container for districts.
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
double getZ(const Position &geo) const
returns height for the given geo coordinate (WGS84)
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
void computeLogic(const NBEdgeCont &ec, OptionsCont &oc)
computes the node's type, logic and traffic light
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 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
double ymax() const
Returns maximum y-coordinate.
#define WRITE_MESSAGE(msg)
double getZRange() const
Returns the elevation range of the boundary (z-axis)
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::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
bool ready() const
returns whether the NBHeightMapper has data
Set z-values for all network positions based on data from a height map.