eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.49k stars 1.41k forks source link

osmWebWizard fails when no edge exists for the selected traffic mode #13947

Closed RobertHilbrich closed 11 months ago

RobertHilbrich commented 11 months ago

OSM WebWizard fails with a ValueError exception, when a scenario should be built with trains (for example), but there are no edges allowing trains in the network.

The following example fails as there are no tram edges in the selected area:

from osmWebWizard import Builder

def test_func():
    data = {
        "coords": ["13.33868980407715000", "52.50300440020900000", "13.34070682525635000", "52.50339624977660000"],
        "duration": 900,
        "vehicles": {"tram": {"count": 35.0, "fringeFactor": 20.0}},
        "poly": True,
        "publicTransport": False,
        "leftHand": False,
        "decal": False,
        "carOnlyNetwork": False,
        "osmMirror": "http://overpass.geofabrik.de/<redacted>/api/interpreter",
        "outputDir": "/tmp/outputdir",
    }
    builder = Builder(data, True)
    builder.build()

Error message:

Traceback (most recent call last):
...
  File "/Users/robert/Git-Repositories/sumo/tools/osmWebWizard.py", line 336, in build
    randomTrips.main(randomTrips.get_options(options))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/robert/Git-Repositories/sumo/tools/randomTrips.py", line 221, in get_options
    raise ValueError("insertionRate must be positive.")
ValueError: insertionRate must be positive.

SUMO version: v1.18.0 OS: Linux and others

RobertHilbrich commented 11 months ago

randomTrips.py is to blame. Fix will follow.