lib/urbanopt/geojson/helper.rb in urbanopt-geojson-0.3.0 vs lib/urbanopt/geojson/helper.rb in urbanopt-geojson-0.3.1
- old
+ new
@@ -152,11 +152,11 @@
def self.create_space_types(stories, model, runner)
space_types = []
stories.each_index do |i|
space_type = nil
space = stories[i].spaces.first
- if space && space.spaceType.is_initialized
+ if space&.spaceType&.is_initialized
space_type = space.spaceType.get
else
space_type = OpenStudio::Model::SpaceType.new(model)
runner.registerInfo("Story #{i} does not have a space type, creating new one")
end
@@ -241,17 +241,25 @@
maximum_roof_height = other_building[:properties][:maximum_roof_height]
if number_of_stories_above_ground.nil?
number_of_stories_above_ground = number_of_stories
number_of_stories_below_ground = 0
+
else
number_of_stories_below_ground = number_of_stories - number_of_stories_above_ground
end
floor_to_floor_height = 3
if number_of_stories_above_ground && number_of_stories_above_ground > 0 && maximum_roof_height
floor_to_floor_height = maximum_roof_height / number_of_stories_above_ground
end
+
+ # check that feature has a # stories
+ if number_of_stories_above_ground.nil?
+ runner.registerWarning("[geojson process_other_buildings] Unable to include feature #{other_building[:properties][:id]} in shading calculations: no 'number of stories' data")
+ end
+ next if number_of_stories_above_ground.nil?
+
other_height = number_of_stories_above_ground * floor_to_floor_height
# find the polygon of the other_building by passing it to the get_multi_polygons method
other_building_points = building.other_points(other_building, other_height, origin_lat_lon, runner, zoning)
shadowed = URBANopt::GeoJSON::Helper.is_shadowed(feature_points, other_building_points, origin_lat_lon)
next unless shadowed