editor_roadArchitect_networkImport¶
File: lua/ge/extensions/editor/roadArchitect/networkImport.lua · VM: Game Engine (GE) · 653 lines · BeamNG.drive 0.40.5 (buildbot 302427 on GitLab)
Access: extension editor_roadArchitect_networkImport: extensions.load("editor_roadArchitect_networkImport"), then the global editor_roadArchitect_networkImport
Shared OpenStreetMap (.osm) and SUMO (.nod.xml/.edg.xml) import into Road Architect. Each OSM way or SUMO edge becomes an independent Road Architect road (two-lane 'driving' import profile, width inferred from the tags or the number of lanes). Ends that share the same source node are snapped to a common position, but no real Road Architect junction is created. The module is the implementation behind osmImport.lua (importFromFile) and can be called without the UI (headless). The import is recorded in the editor history (undo/redo).
Example¶
local res = editor_roadArchitect_networkImport.importOsmFromFile('C:/data/ville.osm', {placeMode = 2, terraform = false})
print(res.importedRoadCount, res.skippedRoadCount)
Notes¶
- Recognized options (options table): placeMode (0 = file position, 1 = placeX/placeY, 2 = camera XY, 3 = player vehicle XY; error if no vehicle in mode 3), placeX, placeY, placeZ (shifts the network so that the start of the first road is at this height), offsetToTerrain (true: conform the roads to the terrain), verticalOffset (Z offset in m), terraform (true: terraformMultiRoads with domainOfInfluence, default 30, and margin, default 1.0), plus the options read by importFile.maybeFinalise (for example finalize).
- The result is a table { success, importedRoadCount, skippedRoadCount, warningCount, warnings, junctionCount, unsupported = {junctions}, finalized }. On error during creation, the roads already added are deleted then the error is rethrown (error).
- OSM: exports generated by BeamNG (generator="BeamNG") are decoded with lat/lon = world/1e7 + 45 (axes x = latitude, y = longitude). Other files are projected in meters from the corner (minlat, minlon). For a non-BeamNG file, only ways with a highway tag are imported (footway, path, cycleway, pedestrian, steps, bridleway ignored).
- OSM: width = width tag, otherwise lanes x 3.5 m, otherwise 7.0 m. Default node altitude 0.1 m if ele is absent.
- SUMO: reads the .nod.xml file and the .edg.xml file with the same prefix (the given path may end with .nod.xml, .edg.xml, .xml or have no extension). Width = numLanes (default 2) x laneWidth (default 3.5). Reverse or duplicate edges between the same two nodes are merged, keeping the one with the richest shape.
- The imported roads have the outline, surface and node sphere display disabled.
Functions¶
| Function | Description | Line |
|---|---|---|
editor_roadArchitect_networkImport.importOsmFromFile(filePath, options) |
Reads an OpenStreetMap file, converts the road ways into Road Architect roads, applies the requested placement/height, snaps the shared ends, optionally terraforms, then finalizes and records the action in the history. Raises an error if the file is unreadable or contains no usable node. | 342 |
editor_roadArchitect_networkImport.importSumoFromFile(filePath, options) |
Reads the SUMO .nod.xml and .edg.xml files sharing the prefix of filePath and creates one Road Architect road per edge (deduplicating reverse directions). Same options and same result as importOsmFromFile. Raises an error if either file is unreadable. | 535 |
Parameter details¶
editor_roadArchitect_networkImport.importOsmFromFile(filePath, options)¶
Reads an OpenStreetMap file, converts the road ways into Road Architect roads, applies the requested placement/height, snaps the shared ends, optionally terraforms, then finalizes and records the action in the history. Raises an error if the file is unreadable or contains no usable node.
filePath(string) : Path of the .osm file.options(table|nil) : Import options (placeMode, placeX, placeY, placeZ, offsetToTerrain, verticalOffset, terraform, domainOfInfluence, margin, finalize...).- returns: table Summary { success, importedRoadCount, skippedRoadCount, warningCount, warnings, junctionCount, unsupported, finalized }.
editor_roadArchitect_networkImport.importSumoFromFile(filePath, options)¶
Reads the SUMO .nod.xml and .edg.xml files sharing the prefix of filePath and creates one Road Architect road per edge (deduplicating reverse directions). Same options and same result as importOsmFromFile. Raises an error if either file is unreadable.
filePath(string) : Path of the SUMO file (.nod.xml, .edg.xml, .xml or prefix without extension).options(table|nil) : Same options as importOsmFromFile.- returns: table Summary { success, importedRoadCount, skippedRoadCount, warningCount, warnings, junctionCount, unsupported, finalized }.
Calls into the engine (C++)¶
be:getPlayerVehicle,reloadCollision
tim19Atlas (Tim0219800) — derived from BeamNG GmbH Lua code (bCDDL 1.1, see LICENSE). Source: lua/ge/extensions/editor/roadArchitect/networkImport.lua.