citygml-to-3dtiles - basic conversion from CityGML to 3DTiles

1,363 views
Skip to first unread message

retoo...@gmail.com

unread,
Mar 25, 2018, 12:23:38 PM3/25/18
to cesium-dev
Hello

I've created a very basic (!) JavaScript program to convert CityGML files to batched 3DTiles, which can then be loaded in Cesium.

https://github.com/njam/citygml-to-3dtiles

It works by reading the XML, extracting buildings (only buildings for now), converting coordinates of the geometric primitives, and then writing a single batched 3DTiles file.
The code for writing 3DTiles is based on the 3D Tiles Samples Generator (https://github.com/AnalyticalGraphicsInc/3d-tiles-tools/tree/master/samples-generator).


If you want to try it out, make sure you have a recent version of NodeJS with ESM module support (I'm using v9.9).

To convert the "3dified" CityGML of Delft:
-----------------------------
# Change into a temp dir:
cd $(mktemp -dt)

# Download and extract the model of Delft:
wget 'https://3d.bk.tudelft.nl/download/3dfier/Delft.gml.zip' && unzip Delft.gml.zip

# Install the conversion script
npm install citygml-to-3dtiles

# Run the conversion:
node --experimental-modules --max-old-space-size=10000 node_modules/.bin/citygml-to-3dtiles \
Delft_3dfier.gml 3dtiles/
-----------------------------

This will take a few minutes. Once done you should end up with a folder "3dtiles/" with two files "tileset.json" and "full.b3dm".


The code has many limitations, and probably does not work out of the box for many CityGML files out there. Maybe it's helpful for somebody as a starting point, but YMMV!

Regards
Reto

jelle....@gmail.com

unread,
Mar 26, 2018, 9:35:28 AM3/26/18
to cesium-dev
Hi,

Very useful tool! I have tried it on my own dataset, and it seems to work very well. I have noticed one small thing though: concave shapes are not always rendered correctly (example from the Delft dataset: https://imgur.com/a/eBBxA). I would love to contribute and fix it, but unfortunately I am not sufficiently familiar with node.js. If you would be able to have a look at it, could you please let me know?

Thanks!

Reto Kaiser

unread,
Mar 30, 2018, 6:46:42 AM3/30/18
to cesiu...@googlegroups.com, jelle....@gmail.com
Thanks for the feedback Jelle!

Indeed the triangulation for concave "linear rings" was completely wrong.
I'm now using a library to do that (libtess.js), and it works much better:
https://user-images.githubusercontent.com/360800/38134294-a667443c-3412-11e8-9d01-bd920a983a8f.png

I've released a new version v0.0.4.

Regards
Reto
> --
> You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/Ah0nl1FNUFE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
38134294-a667443c-3412-11e8-9d01-bd920a983a8f.png

jelle....@gmail.com

unread,
Mar 30, 2018, 9:04:22 AM3/30/18
to cesium-dev
Awesome, works perfectly!

Thanks!
Jelle

denis....@gmail.com

unread,
Sep 6, 2018, 4:30:24 AM9/6/18
to cesium-dev
Hello I want work with citygml-to-3dtiles, but when I try with example Delft I get ERRor
image.png

Can you help me
Thank You!

Reto Kaiser

unread,
Sep 8, 2018, 8:45:56 AM9/8/18
to denis....@gmail.com, cesiu...@googlegroups.com
@Denis the image you wanted to upload doesn't show up.
Feel free to open a ticket on Github if it's easier:
https://github.com/njam/citygml-to-3dtiles/issues

r...@garuda.io

unread,
Sep 24, 2018, 1:14:12 AM9/24/18
to cesium-dev
Hi Reto,

I would like to seek for your assitance regarding to the issue I faced.

Script ((below):

------------------------------------------------------------------------
E:\3D_FP\citygml-to-3dtiles>node --experimental-modules --max-old-space-size=10000 ./bin/citygml-to-3dtiles.mjs ./test/Buildings.gml ./output/
(node:18800) ExperimentalWarning: The ESM module loader is experimental.

Converting...

Reading CityGML file 1/1...

Unknown projection name: "urn:ogc:def:crs,crs:EPSG::3414,crs:EPSG::6916"
------------------------------------------------------------------------


How to make the projection known by the program?


Best Regards,
Rex

Reto Kaiser

unread,
Sep 29, 2018, 10:53:16 AM9/29/18
to r...@garuda.io, cesiu...@googlegroups.com
Hey Rex

Currently only a few predefined projections are available.
I've added the projection you mentioned to the list of predefined projections:
https://github.com/njam/citygml-to-3dtiles/commit/644d2ca21081a25e945f45ae9116f4ef83f2aaa6

When using the project as a NodeJS library you *can* configure
additional projections:
https://github.com/njam/citygml-to-3dtiles#option-srsprojections

It should be easy enough to allow passing additional projections from
a command line argument. Unfortunately I currently don't have the time
to implement it. If you do, I will be happy to accept a pull request.

Hope that helps.

Regards
Reto

mdrb...@gmail.com

unread,
Nov 5, 2019, 6:52:39 AM11/5/19
to cesium-dev
Hi Reto,

found your tool, but got problems with bug datasets - indexBuffer value out of bounds, if you use indexBuffer.writeUInt16LE - it is bounded to 65535.

Rüdiger
> To unsubscribe from this group and all its topics, send an email to cesiu...@googlegroups.com.

Reto Kaiser

unread,
Nov 7, 2019, 10:04:06 AM11/7/19
to cesiu...@googlegroups.com
Hello Rüdiger

Unfortunately I haven't seen that error message before, and therefore
cannot help you with a solution.
I'm not actively using/maintaining "citygml-to-3dtiles" (it was more
of a personal experiment). I hope you find a way to solve the problem!

Regards
Reto
> To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cesium-dev/b5c29477-8083-4e73-bf1d-f2542f7e8452%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages