Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The table below maps in detail the BuildingSync XML data to measure inputs. Note
| | climate_zone | get_climate_zone | either `.../Site/ClimateZoneType/ASHRAE/ClimateZone` or `.../Site/ClimateZoneType/CaliforniaTitle24/ClimateZone` depending on standard |
| [create_bar_from_building_type_ratios] | | | |
| | bldg_type_a | get_building_type_and_bar_division_method | `.../Building/OccupancyClassification` + requirements for `get_total_floor_area` (+ requirements for `get_floor_above_grade` lest defaulted to 1 + requirements for `get_floor_below_grade` lest defaulted to 0) |
| | total_bldg_floor_area | get_total_floor_area | at least one entry of `/FloorArea` in either `.../Site/FloorAreas/` or `.../Building/FloorAreas/`, with `FloorAreaType` of "Gross", "Conditioned", "Common", "Heated and Cooled", "Heated Only", "Cooled Only", "Conditioned above grade", or "Conditioned below grade" |
| | total_bldg_floor_area | get_total_floor_area | at least one entry of `/FloorArea` in either `.../Building/FloorAreas/` or `.../Site/FloorAreas/` (Building is used when both have one), with `FloorAreaType` of "Gross", "Conditioned", "Common", "Heated and Cooled", "Heated Only", "Cooled Only", "Conditioned above grade", or "Conditioned below grade" |
| | floor_height | get_floor_to_floor_height | at least on entry of `.../Building/Sections/Section` with entry `/FloorToFloorHeight` |
| | num_stories_above_grade | get_floor_above_grade | either `.../Building/FloorsAboveGrade` or `.../Building/ConditionedFloorsAboveGrade` and `.../Building/UnconditionedFloorsAboveGrade` |
| | num_stories_below_grade | get_floor_below_grade | either `.../Building/FloorsBelowGrade` or `.../Building/ConditionedFloorsBelowGrade` and `.../Building/UnconditionedFloorsBelowGrade` |
Expand Down
17 changes: 10 additions & 7 deletions lib/BOSS/buildingsync_reader/buildingsync_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

require 'json'
require 'openstudio-standards'
require 'BOSS/boss_logger'
require 'BOSS/constants'
require_relative 'systems_map'
require_relative 'bcl_weather_file_downloader'
include Math
Expand Down Expand Up @@ -176,21 +178,22 @@ def get_building_type_and_bar_division_method
# tries to get total floor area from:
# 1. /FloorAreas of building
# 2. /FloorAreas of site
# The building is more specific than the site, so its value wins when both are present.
def get_total_floor_area(num_indent=2)
# check building floor area
BOSS.BOSS_logger.info("#{"|\t"*num_indent}- checking building for total floor area...")
building_floor_areas_xml = @building_xml.nil? ? nil : @building_xml.elements["#{@ns}FloorAreas"]
building_area = !building_floor_areas_xml.nil? ? _get_total_floor_area_from_floor_areas_xml(building_floor_areas_xml, num_indent+1) : 0
BOSS.BOSS_logger.info("#{"|\t"*num_indent} building floor area is #{building_area}")
return building_area if building_area > 0

# check site floor area
BOSS.BOSS_logger.info("#{"|\t"*num_indent}- checking site for total floor area...")
site_floor_areas_xml = @site_xml.elements["#{@ns}FloorAreas"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bcf2317 by guarding the Building floor-area lookup and adding a Site-only regression spec.

site_area = !site_floor_areas_xml.nil? ? _get_total_floor_area_from_floor_areas_xml(site_floor_areas_xml, num_indent+1) : 0
BOSS.BOSS_logger.info("#{"|\t"*num_indent} site floor area is #{site_area}")
return site_area if site_area > 0

# check building floor area
BOSS.BOSS_logger.info("#{"|\t"*num_indent}- checking building for total floor area...")
building_floor_areas_xml = @building_xml.elements["#{@ns}FloorAreas"]
building_area = !building_floor_areas_xml.nil? ? _get_total_floor_area_from_floor_areas_xml(building_floor_areas_xml, num_indent+1) : 0
BOSS.BOSS_logger.info("#{"|\t"*num_indent} building floor area is #{building_area}")
return building_area if building_area > 0

# TODO: read sections
end

Expand Down
49 changes: 49 additions & 0 deletions spec/tests/unit/buildingsync_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,55 @@ def wrap_in_systems(xml)
end

describe 'get_total_floor_area should' do
def floor_areas(gross)
<<~XML
<FloorAreas>
<FloorArea>
<FloorAreaType>Gross</FloorAreaType>
<FloorAreaValue>#{gross}</FloorAreaValue>
</FloorArea>
</FloorAreas>
XML
end

def site_with_building(site_xml, building_xml)
wrap_in_site(<<~XML)
#{site_xml}
<Buildings>
<Building>
#{building_xml}
</Building>
</Buildings>
XML
end

it "prefer building over site when both have floor area" do
doc = REXML::Document.new site_with_building(floor_areas(20000), floor_areas(15000))
buidingsync_reader = BOSS::BuildingSyncReader.new(doc, nil, ASHRAE90_1)

expect(buidingsync_reader.get_total_floor_area).to eq 15000
end

it "get from building" do
doc = REXML::Document.new site_with_building('', floor_areas(15000))
buidingsync_reader = BOSS::BuildingSyncReader.new(doc, nil, ASHRAE90_1)

expect(buidingsync_reader.get_total_floor_area).to eq 15000
end

it "fall back to site when building has no floor area" do
doc = REXML::Document.new site_with_building(floor_areas(20000), '')
buidingsync_reader = BOSS::BuildingSyncReader.new(doc, nil, ASHRAE90_1)

expect(buidingsync_reader.get_total_floor_area).to eq 20000
end

it "get from site when building is missing" do
doc = REXML::Document.new wrap_in_site(floor_areas(20000))
buidingsync_reader = BOSS::BuildingSyncReader.new(doc, nil, ASHRAE90_1)

expect(buidingsync_reader.get_total_floor_area).to eq 20000
end
end

describe 'get_floor_above_grade should' do
Expand Down
Loading