Skip to content

Commit

Permalink
now importing all width data by default. refs #4392
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 22, 2024
1 parent 39d6544 commit 8467342
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/netimport/NIImporter_OpenStreetMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,14 @@ NIImporter_OpenStreetMap::insertEdge(Edge* e, int index, NBNode* from, NBNode* t
numLanesBackward = -e->myNoLanesForward;
}
}
// with is meant for raw lane count before adding sidewalks or cycleways
const int taggedLanes = (addForward ? numLanesForward : 0) + (addBackward ? numLanesBackward : 0);
if (e->myWidth > 0 && e->myWidthLanesForward.size() == 0 && e->myWidthLanesBackward.size() == 0 && taggedLanes != 0) {
// width is tagged excluding sidewalks and cycleways
forwardWidth = e->myWidth / taggedLanes;
backwardWidth = forwardWidth;
}

// if we had been able to extract the maximum speed, override the type's default
if (e->myMaxSpeed != MAXSPEED_UNGIVEN) {
speed = e->myMaxSpeed / 3.6;
Expand Down Expand Up @@ -1188,7 +1196,7 @@ NIImporter_OpenStreetMap::EdgesHandler::myStartElement(int element, const SUMOSA
&& key != "bicycle:lanes"
&& key != "bicycle:lanes:forward"
&& key != "bicycle:lanes:backward"
&& !StringUtils::startsWith(key, "width:lanes")
&& !StringUtils::startsWith(key, "width")
&& !StringUtils::startsWith(key, "turn:lanes")
&& key != "public_transport") {
return;
Expand Down Expand Up @@ -1364,6 +1372,12 @@ NIImporter_OpenStreetMap::EdgesHandler::myStartElement(int element, const SUMOSA
} catch (const NumberFormatException&) {
WRITE_WARNINGF(TL("Using default lane width for edge '%' as value '%' could not be parsed."), toString(myCurrentEdge->id), value);
}
} else if (key == "width") {
try {
myCurrentEdge->myWidth = StringUtils::toDouble(value);
} catch (const NumberFormatException&) {
WRITE_WARNINGF(TL("Using default width for edge '%' as value '%' could not be parsed."), toString(myCurrentEdge->id), value);
}
} else if (key == "foot") {
if (value == "use_sidepath" || value == "no") {
myCurrentEdge->myExtraDisallowed |= SVC_PEDESTRIAN;
Expand Down
4 changes: 3 additions & 1 deletion src/netimport/NIImporter_OpenStreetMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ class NIImporter_OpenStreetMap {
myChangeBackward(CHANGE_YES),
myLayer(0), // layer is non-zero only in conflict areas
myCurrentIsRoad(false),
myAmInRoundabout(false)
myAmInRoundabout(false),
myWidth(-1)
{ }

virtual ~Edge() {}
Expand Down Expand Up @@ -249,6 +250,7 @@ class NIImporter_OpenStreetMap {
/// @brief Information on lane width
std::vector<double> myWidthLanesForward;
std::vector<double> myWidthLanesBackward;
double myWidth;

private:
/// invalidated assignment operator
Expand Down

0 comments on commit 8467342

Please sign in to comment.