Skip to content

Commit

Permalink
adding option for disabling OSM width data import. refs #4392
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 22, 2024
1 parent 8467342 commit 7779088
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/netimport/NIFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ NIFrame::fillOptions(OptionsCont& oc, bool forNetedit) {
oc.doRegister("ignore-change-restrictions", new Option_StringVector(StringVector({"authority"})));
oc.addDescription("ignore-change-restrictions", "Formats", TL("List vehicle classes that may ignore lane changing restrictions ('all' discards all restrictions)"));

oc.doRegister("ignore-widths", new Option_Bool(false));
oc.addSynonyme("ignore-widths", "opendrive.ignore-widths", false);
oc.addDescription("ignore-widths", "Formats", TL("Whether lane widths shall be ignored."));

// register xml options
oc.doRegister("plain.extend-edge-shape", new Option_Bool(false));
oc.addSynonyme("plain.extend-edge-shape", "xml.keep-shape", true);
Expand Down Expand Up @@ -350,8 +354,6 @@ NIFrame::fillOptions(OptionsCont& oc, bool forNetedit) {
// register opendrive options
oc.doRegister("opendrive.import-all-lanes", new Option_Bool(false));
oc.addDescription("opendrive.import-all-lanes", "Formats", TL("Imports all lane types"));
oc.doRegister("opendrive.ignore-widths", new Option_Bool(false));
oc.addDescription("opendrive.ignore-widths", "Formats", TL("Whether lane widths shall be ignored."));
oc.doRegister("opendrive.curve-resolution", new Option_Float(2.0));
oc.addDescription("opendrive.curve-resolution", "Formats", TL("The geometry resolution in m when importing curved geometries as line segments."));
oc.doRegister("opendrive.advance-stopline", new Option_Float(0.0));
Expand Down
7 changes: 4 additions & 3 deletions src/netimport/NIImporter_OpenStreetMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ NIImporter_OpenStreetMap::insertEdge(Edge* e, int index, NBNode* from, NBNode* t
}
// 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) {
if (e->myWidth > 0 && e->myWidthLanesForward.size() == 0 && e->myWidthLanesBackward.size() == 0 && taggedLanes != 0
&& !OptionsCont::getOptions().getBool("ignore-widths")) {
// width is tagged excluding sidewalks and cycleways
forwardWidth = e->myWidth / taggedLanes;
backwardWidth = forwardWidth;
Expand Down Expand Up @@ -774,7 +775,7 @@ NIImporter_OpenStreetMap::insertEdge(Edge* e, int index, NBNode* from, NBNode* t

// process forward lanes width
const int numForwardLanesFromWidthKey = (int)e->myWidthLanesForward.size();
if (numForwardLanesFromWidthKey > 0) {
if (numForwardLanesFromWidthKey > 0 && !OptionsCont::getOptions().getBool("ignore-widths")) {
if ((int)nbe->getLanes().size() != numForwardLanesFromWidthKey) {
WRITE_WARNINGF(TL("Forward lanes count for edge '%' ('%') is not matching the number of lanes defined in width:lanes:forward key ('%'). Using default width values."),
id, nbe->getLanes().size(), numForwardLanesFromWidthKey);
Expand Down Expand Up @@ -824,7 +825,7 @@ NIImporter_OpenStreetMap::insertEdge(Edge* e, int index, NBNode* from, NBNode* t
}
// process backward lanes width
const int numBackwardLanesFromWidthKey = (int)e->myWidthLanesBackward.size();
if (numBackwardLanesFromWidthKey > 0) {
if (numBackwardLanesFromWidthKey > 0 && !OptionsCont::getOptions().getBool("ignore-widths")) {
if ((int)nbe->getLanes().size() != numBackwardLanesFromWidthKey) {
WRITE_WARNINGF(TL("Backward lanes count for edge '%' ('%') is not matching the number of lanes defined in width:lanes:backward key ('%'). Using default width values."),
id, nbe->getLanes().size(), numBackwardLanesFromWidthKey);
Expand Down

0 comments on commit 7779088

Please sign in to comment.