OSM Tags in OSM2World generated .obj or gltf file

Hi,
I am using OSM2World to generate .obj and .gltf files. Is there a way to include the corresponding OSM tags as user data or attributes in the generated 3D models? Currently, I don’t see the OSM tags attached to the exported geometry.

Thanks!

At the moment, only the OSM element ID is exported when using the glTF export (as an osmId property in the “extras” of nodes in a glTF scene).

This happens when the keepOsmElements configuration option is enabled. When exporting individual glTF files, rather than 3D Tiles, this is currently enabled by default, so it should not require any further changes.

You could use that OSM ID to query, say, an Overpass API instance or a local file or database to get the tags.

It would probably not be hard to optionally export the element’s tags along with the element’s ID, and I’ll look into what it would take to add that as a feature. Would adding the tags in the extras of a node work for you? What does your use case look like?

Doing this for .obj seems less likely because the format doesn’t really offer proper support for metadata fields as far as I know.

If there is an extra node (Mesh?) for each OSM element, does this cause extra draw-calls to the GPU?

Keeping the keepOsmElements option active does indeed have major performance downsides due to a much larger number of draw calls when rendering the resulting model.

That’s not because of the extra nodes per se, but because it prevents combining geometry from different OSM elements, such as the asphalt surfaces of different roads, into a single large mesh. And the number of meshes tends to be directly linked to the number of draw calls for typical implementations.

Avoiding this performance hit is why I switch the feature off when generating 3D tiles, such as those used by the OSM2World demo frontend. And that’s why the frontend doesn’t let you click on buildings and such to inspect them.

This problem could be avoided by storing the metadata using the EXT_mesh_features extension, which apparently allows storing metadata for only some of the geometry of a mesh, but that’s currently not supported by OSM2World.

Thanks. That EXT is mostly what I did have in mind already. I need to check if there are code libs in what language.

Thanks, I see that the osmId is already included — that’s great. For now I’ll process the tags from my local OSM file.

I’m importing the glTF files into Rhino3D (and similar CAD software) for further analysis and context studies, so having geometry tags is important. Adding the tags in the extras of a node would definitely work for me, and glTF support alone would be sufficient.

I’d also like to know if the coordinate origin information (similar to what is exported in .obj as comments ) is available in glTF. For example:

Projection information:
Coordinate origin (0,0,0): lat 51.4490978581279, lon 7.027344703674315, ele 0

The latest build of OSM2World will now include the latitude, longitude and elevation of the coordinate origin as a property in the extras of the scene and the root node.

OSM2World can now also export tags from the source data into the extras of nodes, but this is not enabled by default. To do this, edit your OSM2World config file (“standard.properties” by default) and add a line with the following option:
exportMetadata = id;tags

2 Likes

Thank you!

I am testing latest build to get gltf with tags via c# custom app using OSM2World CLI feature by running new process with follwoing arguments.
var args = $“-jar “{OSM_JAR_PATH}” convert -i “{osmFilePath}” -o “{gltfFile}””;

This was wokring fine in earlier build. In the latest build when I run the same, I get following error
“Error: Unable to initialize main class org.osm2world.console.OSM2World\nCaused by: java.lang.NoClassDefFoundError: picocli/CommandLine$ITypeConverter\r\n”

However for latest build when I run the same arguments by opening command prompt manually; export wokrs fine. Do you know what possibly is going wrong, may be its my c# code/arguments?

That error message occurs if it can’t find the libraries in the lib directory (such as the picocli library).

So the issue could be related to the path which the command is executed from, or perhaps you moved the lib folder?