Skip to content

Commit

Permalink
Merge pull request #196 from bacetiner/master
Browse files Browse the repository at this point in the history
Miscellaneous updates for R2D widget integration
  • Loading branch information
bacetiner authored Mar 22, 2024
2 parents d8bd24c + c3250f6 commit f024053
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
47 changes: 47 additions & 0 deletions brails/EnabledAttributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2024 The Regents of the University of California
#
# This file is part of BRAILS.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# You should have received a copy of the BSD 3-Clause License along with
# BRAILS. If not, see <http://www.opensource.org/licenses/>.
#
# Contributors:
# Barbaros Cetiner
#
# Last updated:
# 03-21-2024

def BldgAttributes():
attr = ['buildingheight','chimney','erabuilt',
'garage','numstories','occupancy',
'roofeaveheight','roofshape','roofpitch',
'constype', 'roofcover','constype']
return attr
10 changes: 4 additions & 6 deletions brails/InventoryGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# Satish Rao
#
# Last updated:
# 02-07-2024
# 03-21-2024

import random
import sys
Expand All @@ -52,6 +52,7 @@
from importlib.metadata import version

#import brails.models as models
from brails.EnabledAttributes import BldgAttributes
from brails.modules import (ChimneyDetector, FacadeParser, GarageDetector,
NFloorDetector, RoofClassifier,
OccupancyClassifier, RoofCoverClassifier,
Expand All @@ -65,11 +66,7 @@ class InventoryGenerator:
def __init__(self, location='Berkeley', nbldgs=10, randomSelection=True,
fpSource='osm', GoogleAPIKey=''):
self.apiKey = GoogleAPIKey
self.enabledAttributes = ['buildingheight','chimney','erabuilt',
'garage','numstories','occupancy',
'roofeaveheight','roofshape','roofpitch',
'constype'] #roofcover,'constype']

self.enabledAttributes = BldgAttributes()
self.inventory = None
self.incompleteInventory = None
self.location = location
Expand Down Expand Up @@ -129,6 +126,7 @@ def __init__(self, location='Berkeley', nbldgs=10, randomSelection=True,
# is valid:
image_handler = ImageHandler(self.apiKey)

@staticmethod
def enabled_attributes(self):
print('Here is the list of attributes currently enabled in InventoryGenerator:\n')
for attribute in self.enabledAttributes:
Expand Down
13 changes: 8 additions & 5 deletions brails/workflow/FootprintHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# Barbaros Cetiner
#
# Last updated:
# 03-20-2024
# 03-22-2024

import math
import json
Expand Down Expand Up @@ -819,8 +819,10 @@ def parse_pt_geojson(data, attrmap, attrkeys, fpSource):
# Create the attribute fields that will be extracted from the
# GeoJSON file:
attributes = {}
for attr in attrmap.values():
attributes[attr] = []
attributestr = [attr for attr in attrmap.values() if attr!='']
for attr in attributestr:
attributes[attr] = []


# Write the data in datalist into a dictionary for better data access,
# and filtering the duplicate entries:
Expand Down Expand Up @@ -911,8 +913,9 @@ def parse_pt_geojson(data, attrmap, attrkeys, fpSource):
pass
ignored_Attr = set(attrkeys0) - attrkeys
if ignored_Attr:
print('Attribute mapping does not cover all attributes detected in'
' the input GeoJSON. Ignoring detected attributes: ' +
print('\nAttribute mapping does not cover all attributes detected in'
' the input GeoJSON. Ignoring detected attributes '
'(building positions extracted from geometry info): ' +
', '.join(ignored_Attr) + '\n')
else:
attrmap = {}
Expand Down

0 comments on commit f024053

Please sign in to comment.