def execute(self, pycitygml_reader, nrmlised_parm_list): parm_list = self.map_nrmlise_parms_2_parms(nrmlised_parm_list) citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #get the parameters for this landuse plot parms_4_luse = parm_list[bcnt:bcnt + n_eligibility_bldgs] #change the bldgs height bcnt = 0 for eligible_gml_bldg in eligibility_bldg_list: #get the height parm for the bldg height_parm = parms_4_luse[bcnt] #extract the bldg solid bldg_solid = gml3dmodel.get_building_occsolid( eligible_gml_bldg, pycitygml_reader) #change the height of each bldg according to the parameter height, nstorey, storey_height = gml3dmodel.get_building_height_storey( eligible_gml_bldg, pycitygml_reader) bldg_bounding_footprint = gml3dmodel.get_building_bounding_footprint( bldg_solid) midpt = py3dmodel.calculate.face_midpt(bldg_bounding_footprint) height_ratio = float(height_parm) / height scaled_bldg = py3dmodel.modify.uniform_scale( bldg_solid, 1, 1, height_ratio, midpt) new_bldg_occsolid = py3dmodel.fetch.geom_explorer( scaled_bldg, "solid")[0] new_height, new_n_storey = gml3dmodel.calculate_bldg_height_n_nstorey( new_bldg_occsolid, storey_height) gml3dmodel.update_gml_building(eligible_gml_bldg, new_bldg_occsolid, pycitygml_reader, citygml_writer, new_height=new_height, new_nstorey=new_n_storey) bcnt += 1 non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader
def calculate_far(self, flr2flr_height): """ This function calculates the FAR of each landuse plot. Parameters ---------- flr2flr_height : float The floor to floor height of the buildings. Returns ------- far list : list of floats List of FAR for each landuse plot. """ if self.building_occsolids == None: self.initialise_occgeom() reader = self.citygml luse_polygons = self.landuse_occpolygons gmlluses = self.landuses gmlbldgs = self.buildings nluse = len(gmlluses) far_list = [] for gcnt in range(nluse): gmlluse = gmlluses[gcnt] luse = luse_polygons[gcnt] luse_area = py3dmodel.calculate.face_area(luse) gmlbldg_on_luse = gml3dmodel.buildings_on_landuse( gmlluse, gmlbldgs, reader) flr_area_list = [] for gmlbldg in gmlbldg_on_luse: pypolygon = reader.get_pypolygon_list(gmlbldg) bsolid = py3dmodel.construct.make_occsolid_frm_pypolygons( pypolygon) b_flr_area = urbangeom.calculate_bldg_flr_area( bsolid, flr2flr_height) flr_area_list.append(b_flr_area) far = sum(flr_area_list) / luse_area far_list.append(far) return far_list
def calculate_far(self, flr2flr_height): """ This function calculates the FAR of each landuse plot. Parameters ---------- flr2flr_height : float The floor to floor height of the buildings. Returns ------- far list : list of floats List of FAR for each landuse plot. """ if self.building_occsolids == None: self.initialise_occgeom() reader = self.citygml luse_polygons = self.landuse_occpolygons gmlluses = self.landuses gmlbldgs = self.buildings nluse = len(gmlluses) far_list = [] for gcnt in range(nluse): gmlluse = gmlluses[gcnt] luse = luse_polygons[gcnt] luse_area = py3dmodel.calculate.face_area(luse) gmlbldg_on_luse = gml3dmodel.buildings_on_landuse(gmlluse, gmlbldgs, reader) flr_area_list = [] for gmlbldg in gmlbldg_on_luse: pypolygon = reader.get_pypolygon_list(gmlbldg) bsolid = py3dmodel.construct.make_occsolid_frm_pypolygons(pypolygon) b_flr_area = urbangeom.calculate_bldg_flr_area(bsolid, flr2flr_height) flr_area_list.append(b_flr_area) far = sum(flr_area_list)/luse_area far_list.append(far) return far_list
def execute(self, pycitygml_reader, nrmlised_parm_list): citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #grid the plot luse_occface = gml3dmodel.gml_landuse_2_occface( gml_landuse, pycitygml_reader) pypt_list, grid_faces = gml3dmodel.landuse_2_grid( luse_occface, self.xdim, self.ydim) npypt_list = len(pypt_list) self.define_int_range(0, npypt_list - 1, 1) #get the parameters for this landuse plot nrmlised_parms_4_luse = nrmlised_parm_list[bcnt:bcnt + n_eligibility_bldgs] parms_4_luse = self.map_nrmlise_parms_2_parms( nrmlised_parms_4_luse) bldg_occsolid_list = [] #get all the occsolid of the buildings for eligible_gml_bldg in eligibility_bldg_list: bldg_occsolid = gml3dmodel.get_building_occsolid( eligible_gml_bldg, pycitygml_reader) bldg_occsolid_list.append(bldg_occsolid) non_bldg_occsolid_list = [] for non_eligible_gml_bldg in non_eligible_bldg_list: non_bldg_occsolid = gml3dmodel.get_building_occsolid( non_eligible_gml_bldg, pycitygml_reader) non_bldg_occsolid_list.append(non_bldg_occsolid) posed_bldg_occsolid_list = gml3dmodel.rearrange_building_position( bldg_occsolid_list, pypt_list, luse_occface, parms_4_luse, other_occsolids=non_bldg_occsolid_list, clash_detection=self.clash_detection, boundary_detection=self.boundary_detection) for up_cnt in range(n_eligibility_bldgs): gml_bldg = eligibility_bldg_list[up_cnt] new_building_solid = posed_bldg_occsolid_list[up_cnt] gml3dmodel.update_gml_building(gml_bldg, new_building_solid, pycitygml_reader, citygml_writer) bcnt += n_eligibility_bldgs non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader
def execute(self, pycitygml_reader, nrmlised_parm_list): parm_list = self.map_nrmlise_parms_2_parms(nrmlised_parm_list) citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #get the parameters for this landuse plot parms_4_luse = parm_list[bcnt:bcnt + n_eligibility_bldgs] luse_occface = gml3dmodel.gml_landuse_2_occface( gml_landuse, pycitygml_reader) #get all the bldg_occsolid roting_bldg_occsolid_list = [] for gml_bldg in eligibility_bldg_list: bldg_occsolid = gml3dmodel.get_building_occsolid( gml_bldg, pycitygml_reader) roting_bldg_occsolid_list.append(bldg_occsolid) non_roting_bldg_occsolid_list = [] for non_gml_bldg in non_eligible_bldg_list: non_bldg_occsolid = gml3dmodel.get_building_occsolid( non_gml_bldg, pycitygml_reader) non_roting_bldg_occsolid_list.append(non_bldg_occsolid) #rotate the buildings for cnt in range(n_eligibility_bldgs): eligible_gml_bldg = eligibility_bldg_list[cnt] rot_angle = parms_4_luse[cnt] rot_bldg_occsolid = gml3dmodel.rotate_bldg( eligible_gml_bldg, rot_angle, pycitygml_reader) roting_bldg_occsolid_list2 = roting_bldg_occsolid_list[:] del roting_bldg_occsolid_list2[cnt] roting_bldg_occsolid_list2.extend( non_roting_bldg_occsolid_list) if self.clash_detection == True and self.boundary_detection == False: clash_detected = gml3dmodel.detect_clash( rot_bldg_occsolid, roting_bldg_occsolid_list2) if not clash_detected: #there is no clash roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid elif self.boundary_detection == True and self.clash_detection == False: is_in_boundary = gml3dmodel.detect_in_boundary( rot_bldg_occsolid, luse_occface) if is_in_boundary: #it is within the boundary roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid elif self.boundary_detection == True and self.clash_detection == True: clash_detected = gml3dmodel.detect_clash( rot_bldg_occsolid, roting_bldg_occsolid_list2) is_in_boundary = gml3dmodel.detect_in_boundary( rot_bldg_occsolid, luse_occface) if not clash_detected and is_in_boundary: roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid elif self.clash_detection == False and self.boundary_detection == False: roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid for up_cnt in range(n_eligibility_bldgs): gml_bldg = eligibility_bldg_list[up_cnt] new_building_solid = roting_bldg_occsolid_list[up_cnt] gml3dmodel.update_gml_building(gml_bldg, new_building_solid, pycitygml_reader, citygml_writer) bcnt += n_eligibility_bldgs non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader
def execute(self, pycitygml_reader, nrmlised_parm_list): parm_list = self.map_nrmlise_parms_2_parms(nrmlised_parm_list) citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #calculate the total landuse floor area luse_flr_area = 0 for eligible_gml_bldg in eligibility_bldg_list: height, nstorey, storey_height = gml3dmodel.get_building_height_storey( eligible_gml_bldg, pycitygml_reader) bldg_flr_area, flrplates = gml3dmodel.get_bulding_floor_area( eligible_gml_bldg, nstorey, storey_height, pycitygml_reader) luse_flr_area += bldg_flr_area #get the parameters for this landuse plot parms_4_luse = parm_list[bcnt:bcnt + n_eligibility_bldgs] total_prop = float(sum(parms_4_luse)) #redistribute the flr area new_bldg_flr_area_list = [] for parm in parms_4_luse: new_bldg_flr_area = float(parm) / total_prop * luse_flr_area new_bldg_flr_area_list.append(new_bldg_flr_area) #reconstuct the buildings according to the new distribuition for cnt in range(n_eligibility_bldgs): gml_bldg = eligibility_bldg_list[cnt] bldg_occsolid = gml3dmodel.get_building_occsolid( gml_bldg, pycitygml_reader) height, nstorey, storey_height = gml3dmodel.get_building_height_storey( gml_bldg, pycitygml_reader) new_bldg_flr_area = new_bldg_flr_area_list[cnt] new_building_solid = gml3dmodel.construct_building_through_floorplates( bldg_occsolid, new_bldg_flr_area, storey_height) new_height, new_n_storey = gml3dmodel.calculate_bldg_height_n_nstorey( new_building_solid, storey_height) gml3dmodel.update_gml_building(gml_bldg, new_building_solid, pycitygml_reader, citygml_writer, new_height=new_height, new_nstorey=new_n_storey) bcnt += n_eligibility_bldgs non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader