Commit 7757ff33 authored by Eric Duminil's avatar Eric Duminil
Browse files

Extrusion: typo

parent 0054e195
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# File Name: building_extension.py # File Name: building_extension.py
# Purpose: CityGML building objects are randomly choosen and extended in given height # Purpose: CityGML building objects are randomly choosen and extended in given height
# Author: Nico Ehlers # Author: Nico Ehlers
# Created: 2024-07-08 # Created: 2024-07-08
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import pandas as pd import pandas as pd
import os import os
import ipywidgets as widgets import ipywidgets as widgets
from IPython.display import display from IPython.display import display
from choose_extrusion_buildings import choose_building from choose_extrusion_buildings import choose_building
from build_up_geonmetries import bldg_extrusion from build_up_geometries import bldg_extrusion
from gml_parsing import little_parser from gml_parsing import little_parser
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Create input widgets # Create input widgets
residential_code_input = widgets.Text(description='Residential Code:', value='31001_1000')# '31001_1010' Asberg) residential_code_input = widgets.Text(description='Residential Code:', value='31001_1000')# '31001_1010' Asberg)
bldg_extension_input = widgets.IntSlider(description='Building Extension:', min=0, max=5, step=1, value=2) bldg_extension_input = widgets.IntSlider(description='Building Extension:', min=0, max=5, step=1, value=2)
extrusion_percentage_input = widgets.FloatSlider(description='Extrusion Percentage:', min=0.0, max=1.0, step=0.1, value=1.0) extrusion_percentage_input = widgets.FloatSlider(description='Extrusion Percentage:', min=0.0, max=1.0, step=0.1, value=1.0)
floor_height_input = widgets.FloatText(description='Floor Height:', value=3.5) floor_height_input = widgets.FloatText(description='Floor Height:', value=3.5)
gml_path_input = widgets.Text(description='GML Path:', value=os.getcwd()+'\GML_files\\') gml_path_input = widgets.Text(description='GML Path:', value=os.getcwd()+'\GML_files\\')
gml_file_input = widgets.Text(description='GML File:', value='Grombuehl_LoD2_mini.gml')#Grafenbühl.gml gml_file_input = widgets.Text(description='GML File:', value='Grombuehl_LoD2_mini.gml')#Grafenbühl.gml
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Create button widget # Create button widget
run_button = widgets.Button(description='Run Code') run_button = widgets.Button(description='Run Code')
# Create output widget # Create output widget
output = widgets.Output() output = widgets.Output()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
gml_path =os.getcwd()+'\GML_files\\' gml_path =os.getcwd()+'\GML_files\\'
gml_file = 'Grombuehl_LoD2_mini.gml' gml_file = 'Grombuehl_LoD2_mini.gml'
save_name = gml_file.split('.')[0]+'_' save_name = gml_file.split('.')[0]+'_'
gml_info = little_parser(gml_path+gml_file) gml_info = little_parser(gml_path+gml_file)
gml_par = gml_info.little_parser() gml_par = gml_info.little_parser()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Define function to run when button is clicked # Define function to run when button is clicked
def run_code(button): def run_code(button):
with output: with output:
# Get user inputs # Get user inputs
residential_code = residential_code_input.value residential_code = residential_code_input.value
bldg_extension = bldg_extension_input.value bldg_extension = bldg_extension_input.value
extrusion_percentage = extrusion_percentage_input.value extrusion_percentage = extrusion_percentage_input.value
floor_height = floor_height_input.value floor_height = floor_height_input.value
gml_path = gml_path_input.value gml_path = gml_path_input.value
gml_file = gml_file_input.value gml_file = gml_file_input.value
file_path = gml_path + gml_file file_path = gml_path + gml_file
# Run choose_building and bldg_extrusion classes # Run choose_building and bldg_extrusion classes
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
### GML PARSING ### GML PARSING
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
save_name = gml_file.split('.')[0]+'_' save_name = gml_file.split('.')[0]+'_'
gml_info = little_parser(file_path) gml_info = little_parser(file_path)
gml_par = gml_info.little_parser() gml_par = gml_info.little_parser()
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
### choose buildings for extrusion ### choose buildings for extrusion
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# TODO: at the moment all construction massive # TODO: at the moment all construction massive
gml_par['construction_type'] = 'massive' gml_par['construction_type'] = 'massive'
extr = choose_building(gml_par, bldg_extension, residential_code, extrusion_percentage) extr = choose_building(gml_par, bldg_extension, residential_code, extrusion_percentage)
gml_par = extr.choose_building() gml_par = extr.choose_building()
# filter buildings with residential code # filter buildings with residential code
gml_par = gml_par[gml_par['function'] == residential_code].reset_index(drop=True) gml_par = gml_par[gml_par['function'] == residential_code].reset_index(drop=True)
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
### GML extrusion ### GML extrusion
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Example usage # Example usage
output_file_path = gml_path + gml_file.replace('.gml', '_extruded.gml') output_file_path = gml_path + gml_file.replace('.gml', '_extruded.gml')
extrude_gml = bldg_extrusion(gml_par, file_path, output_file_path, floor_height, residential_code) extrude_gml = bldg_extrusion(gml_par, file_path, output_file_path, floor_height, residential_code)
extrude_gml.bldg_extrusion() extrude_gml.bldg_extrusion()
# Print confirmation message # Print confirmation message
print('Code executed successfully!') print('Code executed successfully!')
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Attach function to button click event # Attach function to button click event
run_button.on_click(run_code) run_button.on_click(run_code)
# Display the widgets # Display the widgets
display(residential_code_input, bldg_extension_input, extrusion_percentage_input, floor_height_input, gml_path_input, gml_file_input, run_button, output) display(residential_code_input, bldg_extension_input, extrusion_percentage_input, floor_height_input, gml_path_input, gml_file_input, run_button, output)
``` ```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment