3DGI / cityjson2ifc

A command line tool for converting CityJSON files to IFC format
GNU Lesser General Public License v3.0
5 stars 0 forks source link

conversion --ignore_duplicated_keys doesn't work. #3

Open ger08061959 opened 2 months ago

ger08061959 commented 2 months ago

Option doesn't work. One has to delete the double keys from the jsonl file generated

balazsdukai commented 1 month ago

Hi, please provide the full command and a small amount of your input data to reproduce the issue.

ger08061959 commented 1 month ago

First empty record with metadata and empty fields cityobjects. Attached to it again a json record with cityobjects , now with filled cityobjects. using option --ignore_duplicated_keys is not ignoring the first or second mentioning of the key.

"metadata": {
    "referenceSystem": "https://www.opengis.net/def/crs/EPSG/0/7415"
},
"CityObjects": {}
"transform": {
    "scale": [
        0.001,
        0.001,
        0.001
    ],
    "translate": [
        157650.12575,
        571493.0715,
        0.05200005340576119
    ]
},
"type": "CityJSON",
"version": "2.0",
"CityObjects": {
    "NL.IMBAG.Pand.0710100000151707": {
        "attributes": {
     ...

change the file generating code from sample to replace the the fields in the initial section to

        jcUrl = 'https://api.3dbag.nl/collections/pand/items/NL.IMBAG.Pand.'+str(self.site.getBAGPandidentificatie())
        with urllib.request.urlopen(jcUrl) as response:
            if response.code == 200:
                j = json.loads(response.read().decode('utf-8'))
                j_meta = j["metadata"]
                if "feature" in j:
                    j_city = j["feature"]
                    # move correct data in place
                    j_meta['CityObjects'] = j_city['CityObjects']
                    j_meta['vertices'] = j_city['vertices']
                with open(self.IFCModelDict, "w") as my_file:
                    my_file.write(json.dumps(j_meta, indent=4) + "\n")
            else:
                self.logger.logger.error(f'Invalid response code {response.code}')
ger08061959 commented 1 month ago

call to cityjson...

call convert

        path_to_convert_dir = PATHToCityJSON2IFC
        self.outputIfc = self.site.getAddress()+'.ifc'
        cmd = [os.path.join(path_to_convert_dir, 'cityjson2ifc'),
               '--lod-split',
               self.IFCModelDict,
               self.outputIfc]
        result = subprocess.run(cmd)