How to use the cjio.models.Geometry function in cjio

To help you get started, we’ve selected a few cjio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cityjson / cjio / tests / test_geometry.py View on Github external
def test_get_surface_parent(self, surfaces):
        geom = models.Geometry(type='CompositeSolid')
        geom.surfaces = surfaces
        door = {
            2: {
            'type': 'Door',
            'attributes': {
                'colour': 'blue'
            },
            'parent': 0,
            'surface_idx': [[0, 0, 0], [0, 1, 0]]
            },
        }
        res = {
            0: {
                'type': 'WallSurface',
                'attributes': {
                    'slope': 33.4,
github cityjson / cjio / tests / test_geometry.py View on Github external
def test_get_surfaces(self, data_geometry, surfaces):
        geometry, vertices = data_geometry
        geom = models.Geometry(type='CompositeSolid')
        geom.boundaries = geometry[0]['boundaries']
        geom.surfaces = surfaces
        roof = geom.get_surfaces('roofsurface')
        wall = geom.get_surfaces('wallsurface')
        door = geom.get_surfaces('door')
        assert roof == {1: {
            'type': 'RoofSurface',
            'attributes': {
                'slope': 66.6,
            },
            'children': [0],
            'surface_idx': [[0, 0, 1], [0, 1, 1]]
        }}
        assert wall == {0: {
            'type': 'WallSurface',
            'attributes': {
github cityjson / cjio / tests / test_geometry.py View on Github external
def test_vertex_indexer(self, ms_triangles):
        vtx_lookup = {}
        vtx_idx = 0
        geom = models.Geometry(type='MultiSurface', lod=1)
        for record in ms_triangles:
            msurface = list()
            for _surface in record:
                r = list()
                for _ring in _surface:
                    bdry, vtx_lookup, vtx_idx = geom._vertex_indexer(_ring,
                                                                     vtx_lookup,
                                                                     vtx_idx)
                    r.append(bdry)
                msurface.append(r)
github cityjson / cjio / tests / test_geometry.py View on Github external
def test_dereference_boundaries(self, data_geometry, data_vtx_idx):
        type, boundary, result, vertex_list = data_vtx_idx
        vertices = data_geometry[1]
        geom = models.Geometry(type=type, boundaries=boundary, vertices=vertices)
        assert geom.boundaries == result
github cityjson / cjio / tests / test_geometry.py View on Github external
def test_set_surface_attributes(self, data_geometry):
        """Test how to set attributes on semantic surfaces"""
        geometry, vertices = data_geometry
        geom = models.Geometry(type=geometry[0]['type'],
                               lod=geometry[0]['lod'],
                               boundaries=geometry[0]['boundaries'],
                               semantics_obj=geometry[0]['semantics'],
                               vertices=vertices)
        roofsurfaces = geom.get_surfaces('roofsurface')
        for i, rsrf in roofsurfaces.items():
            if 'attributes' in rsrf.keys():
                rsrf['attributes']['colour'] = 'red'
            else:
                rsrf['attributes'] = {}
                rsrf['attributes']['colour'] = 'red'
            # overwrite the surface directly in the Geometry object
            geom.surfaces[i] = rsrf
        roofsurfaces_new = geom.get_surfaces('roofsurface')
        for i,rsrf in roofsurfaces_new.items():
            assert rsrf['attributes']['colour'] == 'red'
github cityjson / cjio / tests / test_geometry.py View on Github external
def test_get_surface_children(self, surfaces):
        geom = models.Geometry(type='CompositeSolid')
        geom.surfaces = surfaces
        res = {
            2: {
            'type': 'Door',
            'attributes': {
                'colour': 'blue'
            },
            'parent': 0,
            'surface_idx': [[0, 0, 0], [0, 1, 0]]
            },
            3: {
                'type': 'Door',
                'attributes': {
                    'colour': 'red'
                },
                'parent': 0,