citygml4j / citygml-tools

Collection of tools for processing CityGML files
Apache License 2.0
113 stars 18 forks source link

possible to merge cityGml files? #36

Open pcace opened 1 year ago

pcace commented 1 year ago

Hi,

is there any way to merge cityGML files with citygml-tools? or what would be the way to go here?

Thanks a lot!

clausnagel commented 1 year ago

Hi @pcace, citygml-tools currently only offers a subset command to create a subset of a CityGML file based on filter criteria. Merging datasets sounds interesting. What would you expect such a command to do? Just create one big file from a list of input files? This would be rather simple to support.

Personally, I would write my own small program with citygml4j to merge files at the moment. Or use a tool like the 3DCityDB to import mutliple files into a database and get whatever I want back out of it. But yes, why not add a merge command to citygml-tools.

pcace commented 1 year ago

Hi, yes i am looking for a way to simply merge multiple files into one. currently i am trying to merge cityGML tiles to in the end convert them into one glb file. wich kind of works but i keep on messing up the projection and not really know what i am doing wrong. i tried to merge them after converting to cityJson with cjio, but have no luck with the projection (https://github.com/cityjson/cjio/issues/154) so i thought it might be a better solution to do the merging earlier in the process using citygml-tools. EDIT merging these cityGML files: https://cloud.johannes-froelich.de/s/xtwyW4rrNoeZTE5 with FZKViewer does produce proper results (merging them after converting to cityJson dose not work for some reason): image

hugoledoux commented 3 months ago

I would also like to have a merge function as mentioned above: merge all the files into one large files.

More and more cities release their datasets with many many small files with a few buildings, so being able to create a dataset in one shot would be useful.

hugoledoux commented 3 months ago

I just merged the CityGML LoD3 of Ingolstadt with cjio 'merge' operator and here's the script (mostly because I will remember where to look for it ;))

import os
import glob

#-- citygml-tools
cmd1 = '/Users/hugo/software/citygml-tools-2.3.0/citygml-tools'
cmd2 = 'to-cityjson'

fs = glob.glob('./citygml-dataset/*/*.xml')
for f in fs:
    a = " ".join([cmd1, cmd2, f])
    # print(a)
    os.system(a)

# #-- merge with cjio
fs = glob.glob('./citygml-dataset/*/*.json')
cmd3 = 'cjio'
cmd4 = fs[0]
a = " ".join(['cjio', fs[0], 'merge', "'./citygml-dataset/*/*.json'", 'save', 'merged.city.json'])
os.system(a)
clausnagel commented 3 months ago

Thanks for your feedback, @hugoledoux. Merging just the XML / JSON is pretty straight-forward, I guess (one might run into duplicate ID issues if the input datasets were created without caring about IDs). But how do you handle texture images and relative paths to those images in your cjio merge operation? Do you leave texture images at their file location and just adapt the relative paths to them? Or do you also merge txture images into a new file location (which would require potentially heavy file copy operations)?

hugoledoux commented 3 months ago

hmmm, actually I keep the original paths, which is wrong :\ I'll open an issue in cjio.

We offer operators to update the paths of textures, but indeed we should normalise the paths, at least...