def identify(self, occshape_attribs_obj_list, pycitygml_writer):
     """
     This function executes the analysis rule and identify the city object based on the condition set. e.g. if a shell is opened and within anopther shell boundary, the shell is a plot.
     
     Parameters
     ----------
     occshape_attribs_obj_list : list of ShapeAttributes objects
         The geometeries of the massing model to be identified.
         
     pycitygml_writer : pycitygml.Writer class instance
         The writer to write the identified city objects into CityGML.
     """
     landuse_list = super(IdentifyLandUseMassings, self).identify(occshape_attribs_obj_list,pycitygml_writer)
     tolerance = 1e-04
     lcnt = 0
     for landuse in landuse_list:
         xmin,ymin,zmin,xmax,ymax,zmax = py3dmodel.calculate.get_bounding_box(landuse)
         zrange = zmax-zmin
         if zrange <= tolerance:
             landuse = py3dmodel.modify.simplify_shell(landuse, tolerance = tolerance)
         else:
             mesh_faces = py3dmodel.construct.simple_mesh(landuse)
             landuse = py3dmodel.construct.sew_faces(mesh_faces,tolerance = tolerance)[0]
             landuse = py3dmodel.modify.fix_shell_orientation(landuse)
             
         lfaces =  py3dmodel.fetch.topo_explorer(landuse, "face")
         gml_geometry_list = gml3dmodel.write_gml_srf_member(lfaces)
         luse_name = "luse" + str(lcnt)
         pycitygml_writer.add_landuse("lod1", luse_name, gml_geometry_list)
         lcnt +=1
Exemple #2
0
    def identify(self, occshape_attribs_obj_list, pycitygml_writer):
        """
        This function executes the analysis rule and identify the city object based on the condition set. e.g. if a shell is opened and within anopther shell boundary, the shell is a plot.
        
        Parameters
        ----------
        occshape_attribs_obj_list : list of ShapeAttributes objects
            The geometeries of the massing model to be identified.
            
        pycitygml_writer : pycitygml.Writer class instance
            The writer to write the identified city objects into CityGML.
        """
        landuse_list = super(IdentifyLandUseMassings,
                             self).identify(occshape_attribs_obj_list,
                                            pycitygml_writer)
        tolerance = 1e-04
        lcnt = 0
        for landuse in landuse_list:
            xmin, ymin, zmin, xmax, ymax, zmax = py3dmodel.calculate.get_bounding_box(
                landuse)
            zrange = zmax - zmin
            if zrange <= tolerance:
                landuse = py3dmodel.modify.simplify_shell(landuse,
                                                          tolerance=tolerance)
            else:
                mesh_faces = py3dmodel.construct.simple_mesh(landuse)
                landuse = py3dmodel.construct.sew_faces(mesh_faces,
                                                        tolerance=tolerance)[0]
                landuse = py3dmodel.modify.fix_shell_orientation(landuse)

            lfaces = py3dmodel.fetch.topo_explorer(landuse, "face")
            gml_geometry_list = gml3dmodel.write_gml_srf_member(lfaces)
            luse_name = "luse" + str(lcnt)
            pycitygml_writer.add_landuse("lod1", luse_name, gml_geometry_list)
            lcnt += 1
    def identify(self, occshape_attribs_obj_list, pycitygml_writer):
        building_list = super(IdentifyBuildingMassings,
                              self).identify(occshape_attribs_obj_list,
                                             pycitygml_writer)
        tolerance = 1e-04
        bcnt = 0
        for building in building_list:
            building = py3dmodel.modify.fix_shell_orientation(building)
            #first try to simplify the solid as much as possible
            mbuilding = py3dmodel.modify.simplify_shell(building,
                                                        tolerance=tolerance)

            least_verts = 2
            while least_verts < 3:
                least_verts = 3
                shell_faces = py3dmodel.fetch.geom_explorer(mbuilding, "face")
                #this is to try to remove any unwanted small area face
                #this will only happens when the simplification do not work
                for face in shell_faces:
                    pyptlist = py3dmodel.fetch.pyptlist_frm_occface(face)
                    nverts = len(pyptlist)
                    if nverts < 3:
                        shell_faces.remove(face)
                        least_verts = 2
                        continue
                    area = py3dmodel.calculate.face_area(face)
                    if area < 1e-03:
                        shell_faces.remove(face)
                        least_verts = 2

                #reconstruct the shell with the remaining face
                mbuilding = py3dmodel.construct.make_shell_frm_faces(
                    shell_faces, tolerance=tolerance)[0]
                mbuilding = py3dmodel.modify.fix_shell_orientation(mbuilding)

            is_shell_close = py3dmodel.calculate.is_shell_closed(mbuilding)
            is_shell_planar = gml3dmodel.is_shell_faces_planar(mbuilding)
            is_shell_simple = gml3dmodel.is_shell_simple(mbuilding)
            #if after removal of faces the shell is no longer close
            #reconstruct the entire shell entirely by meshing the original geometry
            if is_shell_close == False or is_shell_planar == False or is_shell_simple == False:
                mesh_faces = py3dmodel.construct.simple_mesh(building)
                mbuilding = py3dmodel.construct.make_shell_frm_faces(
                    mesh_faces, tolerance=tolerance)[0]
                mbuilding = py3dmodel.modify.fix_shell_orientation(mbuilding)
                mbuilding = py3dmodel.construct.make_solid(mbuilding)
                mbuilding = py3dmodel.modify.fix_close_solid(mbuilding)
            else:
                mbuilding = py3dmodel.construct.make_solid(mbuilding)
                mbuilding = py3dmodel.modify.fix_close_solid(mbuilding)

            bfaces = py3dmodel.fetch.geom_explorer(mbuilding, "face")
            gml_geometry_list = gml3dmodel.write_gml_srf_member(bfaces)
            bldg_name = "bldg" + str(bcnt)
            pycitygml_writer.add_building("lod1", bldg_name, gml_geometry_list)
            bcnt += 1
Exemple #4
0
def building2citygml(building_dict, height, citygml_writer, building_function, storey):
    """
    This function converts the building dictionariesinto building GML.
 
    Parameters
    ----------
    building_dict : dictionary
        The building to be converted. The dictionary is generated from the function get_buildings().
    
    height : float
        The building height.
        
    citygml_writer : Pycitygml.Writer() class instance
        The writer is used to write information to the GML transportation.
        
    name : str
            The name of the transportation object.
    
    building_function : str
        The class/function of the building. Options: Options: "residential", "transport", "recreation_ground", "education", "commercial", "civic", "mixed", "place_of_worship", "reserve", "utility", "health".
        
    storey : int
        The number of storeys of the building.
    """
    storey_blw_grd = "0"
    bclass = map_osm2citygml_building_class(building_function)
    if "name" in building_dict:
        name = building_dict["name"]
    else:
        name = "building" + str(uuid.uuid1())
        
    if "amenity" in building_dict:
        function = map_osm2citygml_building_amenity_function(building_dict["amenity"])
    else:
        function = map_osm2citygml_building_function(building_function)
        
    generic_attrib_dict = {"landuse":building_function}
    if "amenity" in building_dict:
        generic_attrib_dict["amenity"] = building_dict["amenity"]
        
    if "parking" in building_dict:
        generic_attrib_dict["parking"] = building_dict["parking"]

    bgeom_list = building_dict["geometry"]
    for bface in bgeom_list:
        #extrude the buildings according to their height
        face_list = extrude_building_n_fetch_faces(bface, height)
        geometry_list = gml3dmodel.write_gml_srf_member(face_list)
        
    citygml_writer.add_building("lod1", name,geometry_list, bldg_class = bclass, function = function, usage = function,
                         rooftype = "1000", height = str(height),
                         stry_abv_grd = str(storey), stry_blw_grd = storey_blw_grd, generic_attrib_dict = generic_attrib_dict)
Exemple #5
0
def building2citygml(building, height, citygml, landuse, storey):
    storey_blw_grd = "0"
    bclass = map_osm2citygml_building_class(landuse)
    if "name" in building:
        name = building["name"]
    else:
        name = "building" + str(uuid.uuid1())

    if "amenity" in building:
        function = map_osm2citygml_building_amenity_function(
            building["amenity"])
    else:
        function = map_osm2citygml_building_function(landuse)

    generic_attrib_dict = {"landuse": landuse}
    if "amenity" in building:
        generic_attrib_dict["amenity"] = building["amenity"]

    if "parking" in building:
        generic_attrib_dict["parking"] = building["parking"]

    bgeom_list = building["geometry"]
    for bface in bgeom_list:
        #extrude the buildings according to their height
        face_list = extrude_building_n_fetch_faces(bface, height)
        geometry_list = gml3dmodel.write_gml_srf_member(face_list)

    citygml.add_building("lod1",
                         name,
                         geometry_list,
                         bldg_class=bclass,
                         function=function,
                         usage=function,
                         rooftype="1000",
                         height=str(height),
                         stry_abv_grd=str(storey),
                         stry_blw_grd=storey_blw_grd,
                         generic_attrib_dict=generic_attrib_dict)
    def identify(self, occshape_attribs_obj_list, pycitygml_writer):
        landuse_list = super(IdentifyLandUseMassings,
                             self).identify(occshape_attribs_obj_list,
                                            pycitygml_writer)
        tolerance = 1e-04
        lcnt = 0
        for landuse in landuse_list:
            xmin, ymin, zmin, xmax, ymax, zmax = py3dmodel.calculate.get_bounding_box(
                landuse)
            zrange = zmax - zmin
            if zrange <= tolerance:
                landuse = py3dmodel.modify.simplify_shell(landuse,
                                                          tolerance=tolerance)
            else:
                mesh_faces = py3dmodel.construct.simple_mesh(landuse)
                landuse = py3dmodel.construct.make_shell_frm_faces(
                    mesh_faces, tolerance=tolerance)[0]
                landuse = py3dmodel.modify.fix_shell_orientation(landuse)

            lfaces = py3dmodel.fetch.geom_explorer(landuse, "face")
            gml_geometry_list = gml3dmodel.write_gml_srf_member(lfaces)
            luse_name = "luse" + str(lcnt)
            pycitygml_writer.add_landuse("lod1", luse_name, gml_geometry_list)
            lcnt += 1
    def identify(self, occshape_attribs_obj_list, pycitygml_writer):
        """
        This function executes the analysis rule and identify the city object based on the condition set. e.g. if a shell is closed and within anopther shell boundary, the shell is a building.
        
        Parameters
        ----------
        occshape_attribs_obj_list : list of ShapeAttributes objects
            The geometeries of the massing model to be identified.
            
        pycitygml_writer : pycitygml.Writer class instance
            The writer to write the identified city objects into CityGML.
        """
        building_list = super(IdentifyResidentialBuildingMassings, self).identify(occshape_attribs_obj_list,pycitygml_writer)
        tolerance = 1e-04
        bcnt = 0
        for building in building_list:
            building = py3dmodel.modify.fix_shell_orientation(building)
            #first try to simplify the solid as much as possible
            mbuilding = py3dmodel.modify.simplify_shell(building, tolerance = tolerance)

            least_verts = 2
            while least_verts <3:
                least_verts = 3
                shell_faces = py3dmodel.fetch.topo_explorer(mbuilding, "face")
                #this is to try to remove any unwanted small area face 
                #this will only happens when the simplification do not work
                for face in shell_faces:
                    pyptlist= py3dmodel.fetch.points_frm_occface(face)
                    nverts = len(pyptlist)
                    if nverts <3:
                        shell_faces.remove(face)
                        least_verts = 2
                        continue
                    area = py3dmodel.calculate.face_area(face)
                    if area < 1e-03:
                        shell_faces.remove(face)
                        least_verts = 2
                        
                #reconstruct the shell with the remaining face
                mbuilding = py3dmodel.construct.sew_faces(shell_faces,tolerance = tolerance)[0]
                mbuilding = py3dmodel.modify.fix_shell_orientation(mbuilding)
            
            is_shell_close = py3dmodel.calculate.is_shell_closed(mbuilding)
            is_shell_planar = urbangeom.is_shell_faces_planar(mbuilding)
            is_shell_simple = urbangeom.is_shell_simple(mbuilding)
            #if after removal of faces the shell is no longer close 
            #reconstruct the entire shell entirely by meshing the original geometry
            if is_shell_close == False or is_shell_planar == False or is_shell_simple == False :
                mesh_faces = py3dmodel.construct.simple_mesh(building)
                mbuilding = py3dmodel.construct.sew_faces(mesh_faces,tolerance = tolerance)[0]
                mbuilding = py3dmodel.modify.fix_shell_orientation(mbuilding)
                mbuilding = py3dmodel.construct.make_solid(mbuilding)
                mbuilding = py3dmodel.modify.fix_close_solid(mbuilding)
            else:
                mbuilding = py3dmodel.construct.make_solid(mbuilding)
                mbuilding = py3dmodel.modify.fix_close_solid(mbuilding)

            bfaces = py3dmodel.fetch.topo_explorer(mbuilding, "face")
            gml_geometry_list = gml3dmodel.write_gml_srf_member(bfaces)
            bldg_name = "residential_bldg" + str(bcnt)
            pycitygml_writer.add_building("lod1",bldg_name, gml_geometry_list, 
                                          bldg_class="1000", function="1000", usage="1000")
            bcnt+=1
Exemple #8
0
    def identify(self, occshape_attribs_obj_list, pycitygml_writer):
        """
        This function executes the analysis rule and identify the city object based on the condition set. e.g. if a shell is closed and within anopther shell boundary, the shell is a building.
        
        Parameters
        ----------
        occshape_attribs_obj_list : list of ShapeAttributes objects
            The geometeries of the massing model to be identified.
            
        pycitygml_writer : pycitygml.Writer class instance
            The writer to write the identified city objects into CityGML.
        """
        building_list = super(IdentifyResidentialBuildingMassings,
                              self).identify(occshape_attribs_obj_list,
                                             pycitygml_writer)
        tolerance = 1e-04
        bcnt = 0
        for building in building_list:
            building = py3dmodel.modify.fix_shell_orientation(building)
            #first try to simplify the solid as much as possible
            mbuilding = py3dmodel.modify.simplify_shell(building,
                                                        tolerance=tolerance)

            least_verts = 2
            while least_verts < 3:
                least_verts = 3
                shell_faces = py3dmodel.fetch.topo_explorer(mbuilding, "face")
                #this is to try to remove any unwanted small area face
                #this will only happens when the simplification do not work
                for face in shell_faces:
                    pyptlist = py3dmodel.fetch.points_frm_occface(face)
                    nverts = len(pyptlist)
                    if nverts < 3:
                        shell_faces.remove(face)
                        least_verts = 2
                        continue
                    area = py3dmodel.calculate.face_area(face)
                    if area < 1e-03:
                        shell_faces.remove(face)
                        least_verts = 2

                #reconstruct the shell with the remaining face
                mbuilding = py3dmodel.construct.sew_faces(
                    shell_faces, tolerance=tolerance)[0]
                mbuilding = py3dmodel.modify.fix_shell_orientation(mbuilding)

            is_shell_close = py3dmodel.calculate.is_shell_closed(mbuilding)
            is_shell_planar = urbangeom.is_shell_faces_planar(mbuilding)
            is_shell_simple = urbangeom.is_shell_simple(mbuilding)
            #if after removal of faces the shell is no longer close
            #reconstruct the entire shell entirely by meshing the original geometry
            if is_shell_close == False or is_shell_planar == False or is_shell_simple == False:
                mesh_faces = py3dmodel.construct.simple_mesh(building)
                mbuilding = py3dmodel.construct.sew_faces(
                    mesh_faces, tolerance=tolerance)[0]
                mbuilding = py3dmodel.modify.fix_shell_orientation(mbuilding)
                mbuilding = py3dmodel.construct.make_solid(mbuilding)
                mbuilding = py3dmodel.modify.fix_close_solid(mbuilding)
            else:
                mbuilding = py3dmodel.construct.make_solid(mbuilding)
                mbuilding = py3dmodel.modify.fix_close_solid(mbuilding)

            bfaces = py3dmodel.fetch.topo_explorer(mbuilding, "face")
            gml_geometry_list = gml3dmodel.write_gml_srf_member(bfaces)
            bldg_name = "residential_bldg" + str(bcnt)
            pycitygml_writer.add_building("lod1",
                                          bldg_name,
                                          gml_geometry_list,
                                          bldg_class="1000",
                                          function="1000",
                                          usage="1000")
            bcnt += 1