Exemple #1
0
def call(file: str):

    if not path.exists(file):
        raise Exception(f"CityJSON file {file} not found.")

    data = cityjson.load(file)
    data.decompress()
    return data
Exemple #2
0
 def test_save_to_path(self, data_dir):
     p = os.path.join(data_dir, 'rotterdam', 'rotterdam_subset.json')
     cm = cityjson.load(p)
     new_cos = {}
     for co_id, co in cm.cityobjects.items():
         co.attributes['cjio_test'] = 'made by Balázs'
         new_cos[co_id] = co
     cm.cityobjects = new_cos
     p_out = os.path.join(data_dir, 'rotterdam_subset_cjio_test.json')
     cityjson.save(cm, p_out)
Exemple #3
0
    def execute(self, context):
        from cjio import cityjson

        props = context.scene.ifccityjson_properties
        city_model = cityjson.load(props.input)
        lods = set()
        for obj_id, obj in city_model.get_cityobjects().items():
            for geometry in obj.geometry:
                lod = str(geometry.lod)
                if lod not in lods:
                    lods.add(lod)
                    props.lods.add()
                    props.lods[-1].name = lod
        props.is_lod_found = True
        return {"FINISHED"}
Exemple #4
0
def cmdline():
    # Example:
    # python ifccityjson.py -i example/3DBAG_example.json -o example/output.ifc -n identificatie
    # python ifccityjson.py -i example/geometries.json -o example/geometry_output.ifc
    parser = argparse.ArgumentParser(description="")
    parser.add_argument("-i",
                        "--input",
                        type=str,
                        help="input CityJSON file",
                        required=True)
    parser.add_argument("-o",
                        "--output",
                        type=str,
                        help="output IFC file. Standard is output.ifc")
    parser.add_argument("-n",
                        "--name",
                        type=str,
                        help="Attribute containing the name")
    parser.add_argument('--split-lod',
                        dest='split',
                        action='store_true',
                        help="Split the file in multiple LoDs")
    parser.add_argument('--no-split-lod',
                        dest='split',
                        action='store_false',
                        help="Do not split the file in multiple LoDs")
    parser.add_argument("--lod",
                        type=str,
                        help="extract LOD value (example: 1.2)")
    parser.set_defaults(split=True)
    args = parser.parse_args()

    city_model = cityjson.load(args.input, transform=False)
    data = {}
    if args.name:
        data["name_attribute"] = args.name
    if args.output:
        data["file_destination"] = args.output
    if args.lod:
        data["lod"] = args.lod
    data["split"] = args.split

    converter = Cityjson2ifc()
    converter.configuration(**data)
    converter.convert(city_model)
Exemple #5
0
    def execute(self, context):
        from cjio import cityjson
        from ifccityjson.cityjson2ifc.cityjson2ifc import Cityjson2ifc

        props = context.scene.ifccityjson_properties
        city_model = cityjson.load(props.input, transform=False)
        data = {
            "file_destination": props.output,
            "lod": props.lod,
            "split": props.split_lod,
        }
        if props.name != "":
            data["name_attribute"] = props.name

        converter = Cityjson2ifc()
        converter.configuration(**data)
        converter.convert(city_model)
        if props.load_after_convert:
            bpy.ops.bim.load_project(filepath=props.output)
        return {"FINISHED"}
Exemple #6
0
 def test_from_path(self, data_dir):
     p = os.path.join(data_dir, 'rotterdam', 'rotterdam_subset.json')
     cm = cityjson.load(p)
     assert hasattr(cm, 'cityobjects')
     assert '{71B60053-BC28-404D-BAB9-8A642AAC0CF4}' in cm.cityobjects
Exemple #7
0
 def test_to_dataframe(self, data_dir):
     p = os.path.join(data_dir, 'rotterdam', 'rotterdam_subset.json')
     cm = cityjson.load(p)
     df = cm.to_dataframe()
     assert len(df) == len(cm.cityobjects)
Exemple #8
0
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    # Example:
    # python CJ2IFC.py -i example/3DBAG_example.json -o example/output.ifc -n identificatie
    parser = argparse.ArgumentParser(description="")
    parser.add_argument("-i",
                        "--input",
                        type=str,
                        help="input CityJSON file",
                        required=True)
    parser.add_argument("-o",
                        "--output",
                        type=str,
                        help="output IFC file. Standard is output.ifc")
    parser.add_argument("-n",
                        "--name",
                        type=str,
                        help="Attribute containing the name")
    args = parser.parse_args()

    city_model = cityjson.load(args.input)
    data = {}
    if args.name:
        data["name_attribute"] = args.name
    if args.output:
        data["file_destination"] = args.output

    converter = Converter()
    converter.configuration(**data)
    converter.convert(city_model)