citygml4j / citygml-tools

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

Add option to write output to log file #12

Closed clausnagel closed 4 years ago

masgra commented 4 years ago

As for now, if you want to automate your convert in python multiple files, here is a simple work around. Call this function with the (full) path of your .gml file, e.g. when looping over the files in a folder.
Note that this code below might only work with windows. I would also not recommend to run multiple convert jobs in parallel, as the file is of cores not thread-save.

import os
import subprocess

def convert_to_cityjson(file_path):
    program_path = os.path.abspath('./citygml-tools-1.3.2/bin/citygml-tools.bat')
    command = [program_path, "to-cityjson", "--epsg=25832", os.path.abspath(file_path)]
    with open("./convert_out.log", "a") as log_file:
        log_file.write("-"*30 + "\n")
        subprocess.run(args=command , shell=False, stdout=log_file)
    return
clausnagel commented 4 years ago

Thanks for your comment and for sharing your code. I think this is a very nice example and useful for other users.

When invoking citygml-tools from the command line, then the log messages can, of course, also simply be piped into a log file. I nevertheless added a --log-file option (c68c658f3b14ca6db5d5612bf9e6e29105429edb) for convenience.