Class: UrbanGeometryCreationZoning
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- UrbanGeometryCreationZoning
- Defined in:
- lib/measures/urban_geometry_creation_zoning/measure.rb
Overview
start the measure
Instance Attribute Summary collapse
-
#origin_lat_lon ⇒ Object
Returns the value of attribute origin_lat_lon.
Instance Method Summary collapse
- #arguments(model) ⇒ Object
-
#description ⇒ Object
human readable description.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
human readable name.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Attribute Details
#origin_lat_lon ⇒ Object
Returns the value of attribute origin_lat_lon.
19 20 21 |
# File 'lib/measures/urban_geometry_creation_zoning/measure.rb', line 19 def origin_lat_lon @origin_lat_lon end |
Instance Method Details
#arguments(model) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/measures/urban_geometry_creation_zoning/measure.rb', line 36 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # geojson file geojson_file = OpenStudio::Measure::OSArgument.makeStringArgument('geojson_file', true) geojson_file.setDisplayName('GeoJSON File') geojson_file.setDescription('GeoJSON File.') args << geojson_file # feature id of the building to create feature_id = OpenStudio::Measure::OSArgument.makeStringArgument('feature_id', true) feature_id.setDisplayName('Feature ID') feature_id.setDescription('Feature ID.') args << feature_id # which surrounding buildings to include chs = OpenStudio::StringVector.new chs << 'None' chs << 'ShadingOnly' surrounding_buildings = OpenStudio::Measure::OSArgument.makeChoiceArgument('surrounding_buildings', chs, true) surrounding_buildings.setDisplayName('Surrounding Buildings') surrounding_buildings.setDescription('Select which surrounding buildings to include.') surrounding_buildings.setDefaultValue('ShadingOnly') args << surrounding_buildings return args end |
#description ⇒ Object
human readable description
27 28 29 |
# File 'lib/measures/urban_geometry_creation_zoning/measure.rb', line 27 def description return 'This measure reads an URBANopt GeoJSON and creates geometry with zoning for a particular building. Surrounding buildings are included as shading structures.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
32 33 34 |
# File 'lib/measures/urban_geometry_creation_zoning/measure.rb', line 32 def modeler_description return '' end |
#name ⇒ Object
human readable name
22 23 24 |
# File 'lib/measures/urban_geometry_creation_zoning/measure.rb', line 22 def name return 'UrbanGeometryCreationZoning' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/measures/urban_geometry_creation_zoning/measure.rb', line 61 def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end # assign the user inputs to variables geojson_file = runner.getStringArgumentValue('geojson_file', user_arguments) feature_id = runner.getStringArgumentValue('feature_id', user_arguments) surrounding_buildings = runner.getStringArgumentValue('surrounding_buildings', user_arguments) default_construction_set = URBANopt::GeoJSON::Model.create_construction_set(model, runner) stories = [] model.getBuildingStorys.each { |story| stories << story } stories.sort! { |x, y| x.nominalZCoordinate.to_s.to_f <=> y.nominalZCoordinate.to_s.to_f } space_types = URBANopt::GeoJSON::Helper.create_space_types(stories, model, runner) # delete the previous building model.getBuilding.remove # create new building and transfer default construction set model.getBuilding.setDefaultConstructionSet(default_construction_set) # instance variables @runner = runner @origin_lat_lon = nil all_features = URBANopt::GeoJSON::GeoFile.from_file(geojson_file) feature = URBANopt::GeoJSON::GeoFile.from_file(geojson_file).get_feature_by_id(feature_id) # EXPOSE NAME name = feature.feature_json[:properties][:name] model.getBuilding.setName(name) # find min and max x coordinate @origin_lat_lon = feature.create_origin_lat_lon(@runner) site = model.getSite site.setLatitude(@origin_lat_lon.lat) site.setLongitude(@origin_lat_lon.lon) begin surface_elevation = feature.surface_elevation.to_f surface_elevation = OpenStudio.convert(surface_elevation, 'ft', 'm').get site.setElevation(surface_elevation) rescue StandardError @runner.registerWarning("Surface elevation not set for building '#{name}'") end if feature.type == 'Building' # make requested building, zoning is set to true spaces = feature.create_building(:spaces_per_floor, model, @origin_lat_lon, @runner, true) if spaces.nil? || spaces.empty? @runner.registerError("Failed to create building spaces for feature #{feature_id}") return false end # DLM: temp hack building_type = feature.building_type if building_type == 'Vacant' shading_surfaces = URBANopt::GeoJSON::Helper.create_shading_surfaces(feature, model, @origin_lat_lon, @runner, spaces) end # make other buildings to convert to shading convert_to_shades = [] if surrounding_buildings == 'ShadingOnly' convert_to_shades = feature.create_other_buildings(surrounding_buildings, all_features.json, model, @origin_lat_lon, @runner) end # intersect surfaces in this building with others @runner.registerInfo('Intersecting surfaces') spaces.each do |space| convert_to_shades.each do |other_space| space.intersectSurfaces(other_space) end end # match surfaces @runner.registerInfo('Matching surfaces') all_spaces = OpenStudio::Model::SpaceVector.new model.getSpaces.each do |space| all_spaces << space end OpenStudio::Model.matchSurfaces(all_spaces) # make windows spaces = feature.create_windows(spaces) # change adjacent surfaces to adiabatic model = URBANopt::GeoJSON::Model.change_adjacent_surfaces_to_adiabatic(model, @runner) # convert other buildings to shading surfaces convert_to_shades.map do |space| URBANopt::GeoJSON::Helper.convert_to_shading_surface_group(space) end elsif feature.type == 'District System' district_system_type = feature[:properties][:district_system_type] if district_system_type == 'Community Photovoltaic' shading_surfaces = URBANopt::GeoJSON::Helper.create_photovoltaics(feature, 0, model, @origin_lat_lon, @runner) end else @runner.registerError("Unknown feature type '#{feature.type}'") return false end # transfer data from previous model stories = URBANopt::GeoJSON::Model.transfer_prev_model_data(model, space_types) return true end |