urbanopt-geojson 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rakeTasks +7 -0
  4. data/.rdoc_options +43 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +10 -0
  7. data/.travis.yml +35 -0
  8. data/CHANGELOG.md +5 -0
  9. data/Gemfile +27 -0
  10. data/Jenkinsfile +10 -0
  11. data/LICENSE.md +27 -0
  12. data/RDOC_MAIN.md +48 -0
  13. data/README.md +40 -0
  14. data/Rakefile +45 -0
  15. data/deploy_docs.sh +4 -0
  16. data/doc_templates/LICENSE.md +27 -0
  17. data/doc_templates/README.md.erb +42 -0
  18. data/doc_templates/copyright_erb.txt +31 -0
  19. data/doc_templates/copyright_js.txt +4 -0
  20. data/doc_templates/copyright_ruby.txt +29 -0
  21. data/docs/.gitignore +3 -0
  22. data/docs/.vuepress/components/BuildingProperties.vue +12 -0
  23. data/docs/.vuepress/components/DistrictSystemProperties.vue +12 -0
  24. data/docs/.vuepress/components/ElectricalConnectorProperties.vue +12 -0
  25. data/docs/.vuepress/components/ElectricalJunctionProperties.vue +12 -0
  26. data/docs/.vuepress/components/InnerJsonSchema.vue +80 -0
  27. data/docs/.vuepress/components/JsonSchema.vue +12 -0
  28. data/docs/.vuepress/components/RegionProperties.vue +12 -0
  29. data/docs/.vuepress/components/SiteProperties.vue +12 -0
  30. data/docs/.vuepress/components/StaticLink.vue +8 -0
  31. data/docs/.vuepress/components/ThermalConnectorProperties.vue +12 -0
  32. data/docs/.vuepress/components/ThermalJunctionProperties.vue +12 -0
  33. data/docs/.vuepress/config.js +22 -0
  34. data/docs/.vuepress/highlight.js +8 -0
  35. data/docs/.vuepress/public/custom_rdoc_styles.css +64 -0
  36. data/docs/.vuepress/utils.js +17 -0
  37. data/docs/README.md +30 -0
  38. data/docs/doc/created.rid +0 -0
  39. data/docs/package-lock.json +11771 -0
  40. data/docs/package.json +22 -0
  41. data/docs/schemas/building-properties.md +3 -0
  42. data/docs/schemas/district-system-properties.md +3 -0
  43. data/docs/schemas/electrical-connector-properties.md +3 -0
  44. data/docs/schemas/electrical-junction-properties.md +3 -0
  45. data/docs/schemas/region-properties.md +3 -0
  46. data/docs/schemas/site-properties.md +3 -0
  47. data/docs/schemas/thermal-connector-properties.md +3 -0
  48. data/docs/schemas/thermal-junction-properties.md +3 -0
  49. data/lib/measures/.rubocop.yml +5 -0
  50. data/lib/measures/urban_geometry_creation/LICENSE.md +27 -0
  51. data/lib/measures/urban_geometry_creation/README.md +48 -0
  52. data/lib/measures/urban_geometry_creation/README.md.erb +42 -0
  53. data/lib/measures/urban_geometry_creation/measure.rb +199 -0
  54. data/lib/measures/urban_geometry_creation/measure.xml +139 -0
  55. data/lib/measures/urban_geometry_creation/tests/nrel_stm_footprints.geojson +3238 -0
  56. data/lib/measures/urban_geometry_creation/tests/shadowed_tests.rb +80 -0
  57. data/lib/measures/urban_geometry_creation/tests/urban_geometry_creation_test.rb +143 -0
  58. data/lib/measures/urban_geometry_creation_zoning/LICENSE.md +27 -0
  59. data/lib/measures/urban_geometry_creation_zoning/README.md +48 -0
  60. data/lib/measures/urban_geometry_creation_zoning/README.md.erb +42 -0
  61. data/lib/measures/urban_geometry_creation_zoning/measure.rb +203 -0
  62. data/lib/measures/urban_geometry_creation_zoning/measure.xml +133 -0
  63. data/lib/measures/urban_geometry_creation_zoning/tests/nrel_stm_footprints.geojson +3238 -0
  64. data/lib/measures/urban_geometry_creation_zoning/tests/urban_geometry_creation_test.rb +143 -0
  65. data/lib/urbanopt/geojson.rb +41 -0
  66. data/lib/urbanopt/geojson/building.rb +341 -0
  67. data/lib/urbanopt/geojson/district_system.rb +53 -0
  68. data/lib/urbanopt/geojson/extension.rb +63 -0
  69. data/lib/urbanopt/geojson/feature.rb +206 -0
  70. data/lib/urbanopt/geojson/geo_file.rb +154 -0
  71. data/lib/urbanopt/geojson/helper.rb +340 -0
  72. data/lib/urbanopt/geojson/logging.rb +46 -0
  73. data/lib/urbanopt/geojson/mapper_classes.rb +85 -0
  74. data/lib/urbanopt/geojson/model.rb +133 -0
  75. data/lib/urbanopt/geojson/region.rb +55 -0
  76. data/lib/urbanopt/geojson/schema/building_properties.json +358 -0
  77. data/lib/urbanopt/geojson/schema/district_system_properties.json +137 -0
  78. data/lib/urbanopt/geojson/schema/electrical_connector_properties.json +77 -0
  79. data/lib/urbanopt/geojson/schema/electrical_junction_properties.json +64 -0
  80. data/lib/urbanopt/geojson/schema/geojson_schema.json +323 -0
  81. data/lib/urbanopt/geojson/schema/region_properties.json +93 -0
  82. data/lib/urbanopt/geojson/schema/site_properties.json +87 -0
  83. data/lib/urbanopt/geojson/schema/thermal_connector_properties.json +107 -0
  84. data/lib/urbanopt/geojson/schema/thermal_junction_properties.json +83 -0
  85. data/lib/urbanopt/geojson/update_areas.rb +102 -0
  86. data/lib/urbanopt/geojson/validate_geojson.rb +147 -0
  87. data/lib/urbanopt/geojson/version.rb +35 -0
  88. data/lib/urbanopt/geojson/workflows/building.osw +187 -0
  89. data/lib/urbanopt/geojson/workflows/building.osw.out +2806 -0
  90. data/lib/urbanopt/geojson/workflows/district_system.osw +84 -0
  91. data/lib/urbanopt/geojson/workflows/district_system.osw.out +646 -0
  92. data/lib/urbanopt/geojson/zoning.rb +134 -0
  93. data/package-lock.json +3 -0
  94. data/urbanopt-geojson-gem.gemspec +39 -0
  95. metadata +238 -0
@@ -0,0 +1,143 @@
1
+ # *********************************************************************************
2
+ # URBANopt, Copyright (c) 2019, Alliance for Sustainable Energy, LLC, and other
3
+ # contributors. All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without modification,
6
+ # are permitted provided that the following conditions are met:
7
+ #
8
+ # Redistributions of source code must retain the above copyright notice, this list
9
+ # of conditions and the following disclaimer.
10
+ #
11
+ # Redistributions in binary form must reproduce the above copyright notice, this
12
+ # list of conditions and the following disclaimer in the documentation and/or other
13
+ # materials provided with the distribution.
14
+ #
15
+ # Neither the name of the copyright holder nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without specific
17
+ # prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
+ # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
+ # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
+ # OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ # *********************************************************************************
30
+
31
+ require 'openstudio'
32
+ require 'openstudio/ruleset/ShowRunnerOutput'
33
+ require 'minitest/autorun'
34
+ require_relative '../measure.rb'
35
+ require 'fileutils'
36
+
37
+ class UrbanGeometryCreationZoningTest < MiniTest::Unit::TestCase
38
+ def test_one_building
39
+ # create an instance of the measure
40
+ measure = UrbanGeometryCreationZoning.new
41
+
42
+ # create an empty model
43
+ model = OpenStudio::Model::Model.new
44
+
45
+ # create an instance of a runner
46
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
47
+
48
+ geojson_file = File.absolute_path(File.join(File.dirname(__FILE__), 'nrel_stm_footprints.geojson'))
49
+
50
+ feature_id = '59a9ce2b42f7d007c059d2ee' # Energy Systems Integration Facility
51
+
52
+ surrounding_buildings = 'None'
53
+ # surrounding_buildings = "ShadingOnly"
54
+ # surrounding_buildings = "All"
55
+
56
+ # get arguments
57
+ arguments = measure.arguments(model)
58
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
59
+
60
+ # create hash of argument values.
61
+ # If the argument has a default that you want to use, you don't need it in the hash
62
+ args_hash = {}
63
+ args_hash['geojson_file'] = geojson_file
64
+ args_hash['feature_id'] = feature_id
65
+ args_hash['surrounding_buildings'] = surrounding_buildings
66
+
67
+ # populate argument with specified hash value if specified
68
+ arguments.each do |arg|
69
+ temp_arg_var = arg.clone
70
+ if args_hash[arg.name]
71
+ assert(temp_arg_var.setValue(args_hash[arg.name]))
72
+ end
73
+ argument_map[arg.name] = temp_arg_var
74
+ end
75
+
76
+ # run the measure
77
+ measure.run(model, runner, argument_map)
78
+ result = runner.result
79
+
80
+ # save the model to test output directory
81
+ output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + "/output/#{feature_id}.osm")
82
+ model.save(output_file_path, true)
83
+
84
+ # show the output
85
+ show_output(result)
86
+
87
+ # assert that it ran correctly
88
+ assert_equal('Success', result.value.valueName)
89
+ end
90
+
91
+ def test_one_building_w_surrounding_buildings
92
+ # create an instance of the measure
93
+ measure = UrbanGeometryCreationZoning.new
94
+
95
+ # create an empty model
96
+ model = OpenStudio::Model::Model.new
97
+
98
+ # create an instance of a runner
99
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
100
+
101
+ geojson_file = File.absolute_path(File.join(File.dirname(__FILE__), 'nrel_stm_footprints.geojson'))
102
+
103
+ feature_id = '59a9ce2b42f7d007c059d2f0' # Education Center
104
+
105
+ # surrounding_buildings = "None"
106
+ surrounding_buildings = 'ShadingOnly'
107
+ # surrounding_buildings = "All"
108
+
109
+ # get arguments
110
+ arguments = measure.arguments(model)
111
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
112
+
113
+ # create hash of argument values.
114
+ # If the argument has a default that you want to use, you don't need it in the hash
115
+ args_hash = {}
116
+ args_hash['geojson_file'] = geojson_file
117
+ args_hash['feature_id'] = feature_id
118
+ args_hash['surrounding_buildings'] = surrounding_buildings
119
+
120
+ # populate argument with specified hash value if specified
121
+ arguments.each do |arg|
122
+ temp_arg_var = arg.clone
123
+ if args_hash[arg.name]
124
+ assert(temp_arg_var.setValue(args_hash[arg.name]))
125
+ end
126
+ argument_map[arg.name] = temp_arg_var
127
+ end
128
+
129
+ # run the measure
130
+ measure.run(model, runner, argument_map)
131
+ result = runner.result
132
+
133
+ # save the model to test output directory
134
+ output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + "/output/#{feature_id}.osm")
135
+ model.save(output_file_path, true)
136
+
137
+ # show the output
138
+ show_output(result)
139
+
140
+ # assert that it ran correctly
141
+ assert_equal('Success', result.value.valueName)
142
+ end
143
+ end
@@ -0,0 +1,41 @@
1
+ # *********************************************************************************
2
+ # URBANopt, Copyright (c) 2019, Alliance for Sustainable Energy, LLC, and other
3
+ # contributors. All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without modification,
6
+ # are permitted provided that the following conditions are met:
7
+ #
8
+ # Redistributions of source code must retain the above copyright notice, this list
9
+ # of conditions and the following disclaimer.
10
+ #
11
+ # Redistributions in binary form must reproduce the above copyright notice, this
12
+ # list of conditions and the following disclaimer in the documentation and/or other
13
+ # materials provided with the distribution.
14
+ #
15
+ # Neither the name of the copyright holder nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without specific
17
+ # prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
+ # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
+ # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
+ # OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ # *********************************************************************************
30
+
31
+ require 'urbanopt/geojson/feature'
32
+ require 'urbanopt/geojson/building'
33
+ require 'urbanopt/geojson/region'
34
+ require 'urbanopt/geojson/district_system'
35
+ require 'urbanopt/geojson/geo_file'
36
+ require 'urbanopt/geojson/helper'
37
+ require 'urbanopt/geojson/model'
38
+ require 'urbanopt/geojson/zoning'
39
+ require 'urbanopt/geojson/model'
40
+ require 'urbanopt/geojson/extension'
41
+ require 'urbanopt/geojson/logging'
@@ -0,0 +1,341 @@
1
+ # *********************************************************************************
2
+ # URBANopt, Copyright (c) 2019, Alliance for Sustainable Energy, LLC, and other
3
+ # contributors. All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without modification,
6
+ # are permitted provided that the following conditions are met:
7
+ #
8
+ # Redistributions of source code must retain the above copyright notice, this list
9
+ # of conditions and the following disclaimer.
10
+ #
11
+ # Redistributions in binary form must reproduce the above copyright notice, this
12
+ # list of conditions and the following disclaimer in the documentation and/or other
13
+ # materials provided with the distribution.
14
+ #
15
+ # Neither the name of the copyright holder nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without specific
17
+ # prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
+ # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
+ # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
+ # OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ # *********************************************************************************
30
+
31
+ require 'urbanopt/geojson/feature'
32
+
33
+ module URBANopt
34
+ module GeoJSON
35
+ class Building < URBANopt::GeoJSON::Feature
36
+ ##
37
+ # Used to initialize the feature. This method is inherited from the Feature class.
38
+ def initialize(feature)
39
+ super(feature)
40
+ end
41
+
42
+ ##
43
+ # Used to describe the Building feature type using the base method from the Feature class.
44
+ def feature_type
45
+ 'Building'
46
+ end
47
+
48
+ ##
49
+ # Returns the building_properties schema.
50
+ def schema_file
51
+ return File.join(File.dirname(__FILE__), 'schema', 'building_properties.json')
52
+ end
53
+
54
+ ##
55
+ # This method creates a building for a given feature specified in the
56
+ # feature_json as per the create_method.
57
+ #
58
+ # Returns an array of instances of +OpenStudio::Model::Space+ .
59
+ #
60
+ # [Parameters]
61
+ # * +create_method+ - _Type:Symbol_ - +:space_per_floor+ or +:space_per_building+ methods can be
62
+ # used.
63
+ # * +model+ - _Type:String_ - An instance of +OpenStudio::Model::Model+_ .
64
+ # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
65
+ # * +runner+ - _Type:String_ - An instance of +OpenStudio::Measure::OSRunner+ for the measure run.
66
+ # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
67
+ # +false+. Zoning is set to False by default. Currently, only zoning set to +false+ is
68
+ # supported.
69
+ # * +other_building+ - _Type:URBANopt::GeoJSON::Feature - Optional, allow the user to pass in a different building to process. This is used for creating the other buildings for shading.
70
+ def create_building(create_method, model, origin_lat_lon, runner, zoning = false, other_building = @feature_json)
71
+ number_of_stories = other_building[:properties][:number_of_stories]
72
+ number_of_stories_above_ground = other_building[:properties][:number_of_stories_above_ground]
73
+ number_of_stories_below_ground = other_building[:properties][:number_of_stories_below_ground]
74
+ number_of_residential_units = other_building[:properties][:number_of_residential_units]
75
+
76
+ if zoning
77
+ surface_elevation = other_building[:properties][:surface_elevation]
78
+ roof_elevation = other_building[:properties][:roof_elevation]
79
+ floor_to_floor_height = other_building[:properties][:floor_to_floor_height]
80
+ else
81
+ maximum_roof_height = other_building[:properties][:maximum_roof_height]
82
+ end
83
+
84
+ if number_of_stories_above_ground.nil?
85
+ number_of_stories_above_ground = number_of_stories
86
+ number_of_stories_below_ground = 0
87
+ else
88
+ number_of_stories_below_ground = number_of_stories - number_of_stories_above_ground
89
+ end
90
+ floor_to_floor_height = zoning ? 3.6 : 3
91
+
92
+ if number_of_stories_above_ground && number_of_stories_above_ground > 0 && maximum_roof_height && !zoning
93
+ floor_to_floor_height = maximum_roof_height / number_of_stories_above_ground
94
+ floor_to_floor_height = OpenStudio.convert(floor_to_floor_height, 'ft', 'm').get
95
+ end
96
+
97
+ if create_method == :space_per_floor || create_method == :spaces_per_floor
98
+ if number_of_residential_units
99
+ model.getBuilding.setStandardsNumberOfLivingUnits(number_of_residential_units)
100
+ end
101
+ model.getBuilding.setStandardsNumberOfStories(number_of_stories)
102
+ model.getBuilding.setStandardsNumberOfAboveGroundStories(number_of_stories_above_ground)
103
+ model.getBuilding.setNominalFloortoFloorHeight(floor_to_floor_height)
104
+ end
105
+
106
+ spaces = []
107
+ if create_method == :space_per_floor || create_method == :spaces_per_floor
108
+ (-number_of_stories_below_ground + 1..number_of_stories_above_ground).each do |story_number|
109
+ new_spaces = create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning)
110
+ spaces.concat(new_spaces)
111
+ end
112
+ elsif create_method == :space_per_building
113
+ spaces = create_space_per_building(-number_of_stories_below_ground * floor_to_floor_height, number_of_stories_above_ground * floor_to_floor_height, model, origin_lat_lon, runner, zoning)
114
+ end
115
+ return spaces
116
+ end
117
+ alias create_other_building create_building
118
+
119
+ ##
120
+ # Return the features multi polygon in an array of the form coordinate pairs in double nested Array.
121
+ #
122
+ # [Parameters]
123
+ # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
124
+ # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
125
+ # * +zoning+ - _Type:Boolean_ - Should be true if you'd like to utilize aspects of function that are specific to zoning.
126
+ def feature_points(origin_lat_lon, runner, zoning)
127
+ feature_points = []
128
+ multi_polygons = get_multi_polygons(@feature_json)
129
+ multi_polygons.each do |multi_polygon|
130
+ multi_polygon.each do |polygon|
131
+ elevation = 0
132
+ floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, elevation, origin_lat_lon, runner, zoning)
133
+ floor_print.each do |point|
134
+ feature_points << point
135
+ end
136
+
137
+ # Subsequent polygons are holes, and are not supported.
138
+ break
139
+ end
140
+ end
141
+ return feature_points
142
+ end
143
+
144
+ ##
145
+ # Return the points of the other building object. This method is similar to feature_points, but accepts
146
+ # the other building and other height.
147
+ #
148
+ # [Parameters]
149
+ # * +other_building+ - _Type:Array_ - Array of points.
150
+ # * +other_height+ - _Type:Double_ - Value of the other height from which to create the floor prints.
151
+ # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
152
+ # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
153
+ # * +zoning+ - _Type:Boolean_ - Should be true if you'd like to utilize aspects of function that are specific to zoning.
154
+ def other_points(other_building, other_height, origin_lat_lon, runner, zoning)
155
+ other_points = []
156
+ multi_polygons = get_multi_polygons(other_building)
157
+ multi_polygons.each do |multi_polygon|
158
+ multi_polygon.each do |polygon|
159
+ floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, other_height, origin_lat_lon, runner, zoning)
160
+ floor_print.each do |point|
161
+ other_points << point
162
+ end
163
+
164
+ # Subsequent polygons are holes, and are not supported.
165
+ break
166
+ end
167
+ end
168
+ return other_points
169
+ end
170
+
171
+ ##
172
+ # This method is used to create the surrounding buildings as shading objects.
173
+ #
174
+ # Returns an array of instances of +OpenStudio::Model::Space+.
175
+ #
176
+ # [Parameters]
177
+ # * +other_building_type+ - _Type:String_ - Describes the surrounding buildings. Currently 'ShadingOnly' is the only option that is processed.
178
+ # * +other_buildings+ - _Type:URBANopt::GeoJSON::FeatureCollection_ - List of surrounding buildings to include (self will be ignored if present in list).
179
+ # * +model+ - _Type:OpenStudio::Model::Model_ - An instance of an OpenStudio Model.
180
+ # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
181
+ # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
182
+ # * +zoning+ - _Type:Boolean_ - Value is +True+ if utilizing detailed zoning, else +False+. Zoning is set to False by default.
183
+ def create_other_buildings(other_building_type, other_buildings, model, origin_lat_lon, runner, zoning = false)
184
+ if other_buildings[:features].nil?
185
+ runner.registerWarning("No features found in #{other_buildings}")
186
+ return []
187
+ end
188
+
189
+ other_spaces = URBANopt::GeoJSON::Helper.process_other_buildings(
190
+ self, other_building_type, other_buildings, model, origin_lat_lon, runner, zoning
191
+ )
192
+ return other_spaces
193
+ end
194
+
195
+ ##
196
+ # This method loops through all the spaces of the building and for each Wall
197
+ # surface with Outdoors boundary condition, sets the window to wall ratio as per
198
+ # the specified value or as a default value of 0.3.
199
+ #
200
+ # Returns an array of instances of +OpenStudio::Model::Space+ with windows.
201
+ #
202
+ # [Parameters]
203
+ # * +spaces+ - _Type:Array_ - Contains instances of +OpenStudio::Model::Space+ .
204
+ def create_windows(spaces)
205
+ window_to_wall_ratio = @feature_json[:properties][:window_to_wall_ratio]
206
+ if window_to_wall_ratio.nil?
207
+ window_to_wall_ratio = 0.3
208
+ end
209
+ spaces.each do |space|
210
+ space.surfaces.each do |surface|
211
+ if surface.surfaceType == 'Wall' && surface.outsideBoundaryCondition == 'Outdoors'
212
+ surface.setWindowToWallRatio(window_to_wall_ratio)
213
+ end
214
+ end
215
+ end
216
+ end
217
+
218
+ private
219
+
220
+ ##
221
+ # Returns an array of instances of +OpenStudio::Model::Space+ per building
222
+ #
223
+ # [Parameters]
224
+ # * +min_elevation+ - _Type:Integer_ - Indicates minimum elevation across all buildings.
225
+ # * +max_elevation+ - _Type:Integer_ - Indicates maximum elevation across all buildings.
226
+ # * +model+ - _Type:String_ - An instance of +OpenStudio::Model::Model+ .
227
+ # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latidude and longitude of the origin.
228
+ # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
229
+ # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
230
+ # +false+. Zoning is set to False by default. Currently, only zoning set to +false+ is
231
+ # supported.
232
+ def create_space_per_building(min_elevation, max_elevation, model, origin_lat_lon, runner, zoning = false) #:doc:
233
+ geometry = @feature_json[:geometry]
234
+ properties = @feature_json[:properties]
235
+ if zoning
236
+ name = properties[:id]
237
+ else
238
+ name = properties[:name]
239
+ end
240
+ floor_prints = []
241
+ multi_polygons = get_multi_polygons
242
+ multi_polygons.each do |multi_polygon|
243
+ if multi_polygon.size > 1
244
+ runner.registerWarning('Ignoring holes in polygon')
245
+ end
246
+ multi_polygon.each do |polygon|
247
+ floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, min_elevation, origin_lat_lon, runner, zoning)
248
+ if floor_print
249
+ floor_prints << floor_print
250
+ else
251
+ runner.registerWarning("Cannot get floor print for building '#{name}'")
252
+ end
253
+ break
254
+ end
255
+ end
256
+ result = []
257
+ floor_prints.each do |floor_print|
258
+ space = OpenStudio::Model::Space.fromFloorPrint(floor_print, max_elevation - min_elevation, model)
259
+ if space.empty?
260
+ runner.registerWarning('Cannot create building space')
261
+ next
262
+ end
263
+ space = space.get
264
+ space.setName("Building #{name} Space")
265
+ thermal_zone = OpenStudio::Model::ThermalZone.new(model)
266
+ thermal_zone.setName("Building #{name} ThermalZone")
267
+ space.setThermalZone(thermal_zone)
268
+ result << space
269
+ end
270
+ return result
271
+ end
272
+
273
+ ##
274
+ # Returns an array of instances of +OpenStudio::Model::Space+ per floor.
275
+ #
276
+ # [Parameters]
277
+ # * +feature+ - _Type:String_ - An instance of Feature class built off of the GeoJSON file.
278
+ # * +story_number+ - _Type:Integer_ - Number of floors in the building.
279
+ # * +floor_to_floor_height+ - _Type:Integer_ - Height of the building stories.
280
+ # * +model+ - _Type:String_ - An instance of +OpenStudio::Model::Model+.
281
+ # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the
282
+ # origin's latitude and longitude.
283
+ # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
284
+ # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
285
+ # +false+. Zoning is set to False by default. Currently, only zoning set to +false+ is
286
+ # supported.
287
+ def create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning = false) #:doc:
288
+ geometry = @feature_json[:geometry]
289
+ properties = @feature_json[:properties]
290
+ floor_prints = []
291
+ multi_polygons = get_multi_polygons
292
+ multi_polygons.each do |multi_polygon|
293
+ if story_number == 1 && multi_polygon.size > 1
294
+ runner.registerWarning('Ignoring holes in polygon')
295
+ end
296
+ multi_polygon.each do |polygon|
297
+ elevation = (story_number - 1) * floor_to_floor_height
298
+ floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, elevation, origin_lat_lon, runner, zoning)
299
+ if floor_print
300
+ if zoning
301
+ this_floor_prints = URBANopt::GeoJSON::Zoning.divide_floor_print(floor_print, 4.0, runner)
302
+ floor_prints.concat(this_floor_prints)
303
+ else
304
+ floor_prints << floor_print
305
+ end
306
+ else
307
+ runner.registerWarning("Cannot create story #{story_number}")
308
+ end
309
+ # Subsequent polygons are holes, and are not supported.
310
+ break
311
+ end
312
+ end
313
+ result = []
314
+ floor_prints.each do |floor_print|
315
+ space = OpenStudio::Model::Space.fromFloorPrint(floor_print, floor_to_floor_height, model)
316
+ if space.empty?
317
+ runner.registerWarning("Cannot create space for story #{story_number}")
318
+ next
319
+ end
320
+ space = space.get
321
+ space.setName("Building Story #{story_number} Space")
322
+ space.surfaces.each do |surface|
323
+ if surface.surfaceType == 'Wall'
324
+ if story_number < 1
325
+ surface.setOutsideBoundaryCondition('Ground')
326
+ end
327
+ end
328
+ end
329
+ building_story = OpenStudio::Model::BuildingStory.new(model)
330
+ building_story.setName("Building Story #{story_number}")
331
+ space.setBuildingStory(building_story)
332
+ thermal_zone = OpenStudio::Model::ThermalZone.new(model)
333
+ thermal_zone.setName("Building Story #{story_number} ThermalZone")
334
+ space.setThermalZone(thermal_zone)
335
+ result << space
336
+ end
337
+ return result
338
+ end
339
+ end
340
+ end
341
+ end