Beispiel #1
0
 def __init__(self, options=None, name='Mapping Scheme Loaded'):
     """ constructor """
     Operator.__init__(self, options,  name)
     if isinstance(options['taxonomy'], Taxonomy):
         self._taxonomy = options['taxonomy']
     else:
         self._taxonomy = get_taxonomy(options['taxonomy'])
Beispiel #2
0
Datei: ms.py Projekt: gem/sidd
 def __init__(self, options=None, name='Mapping Scheme Loaded'):
     """ constructor """
     Operator.__init__(self, options, name)
     if isinstance(options['taxonomy'], Taxonomy):
         self._taxonomy = options['taxonomy']
     else:
         self._taxonomy = get_taxonomy(options['taxonomy'])
Beispiel #3
0
 def setUp(self):
     super(MSTestCase, self).setUp()
     self.taxonomy = get_taxonomy("gem")
     self.survey_file = self.test_data_dir + "survey.csv"
     self.ms_file = self.test_data_dir + "ms.xml"
     self.ms_parse_order = [
         'Material Type', 'Material Technology',
         'Lateral Load Resisting System', 'Height', 'Occupancy'
     ]
Beispiel #4
0
 def __init__(self, options=None, name='Empty MS Creator'):
     super(EmptyMSCreator, self).__init__(options, name)
     self._tmp_dir = get_dictionary_value(options, 'tmp_dir',
                                          get_temp_dir())
     self._taxonomy = get_dictionary_value(options, 'taxonomy',
                                           get_taxonomy('GEM'))
     self._parse_modifiers = get_dictionary_value(options,
                                                  'parse_modifiers', True)
     self._parse_order = get_dictionary_value(options, 'attribute.order',
                                              None)
Beispiel #5
0
    def setUp(self):
        super(OperatorTestCase, self).setUp()
        self.taxonomy = get_taxonomy("gem")

        # test data set 1
        self.ms_file = self.test_data_dir + "ms.xml"
        self.fp_path = self.test_data_dir + "footprint.shp"
        self.fp_feature_count = 1475
        self.zone1_path = self.test_data_dir + "zones1.shp"
        self.zone1_field = "ZONE"

        # test data set 2
        self.zone2_path = self.test_data_dir + "zones2.shp"
        self.zone2_field = "LandUse"
        self.zone2_feature_count = 546
        self.zone2_total_bldg_cnt = 292377
        self.zone2_total_bldg_area = 71582303
        self.zone2_bldgcount_field = "NumBldg"
        self.zone2_bldgarea_field = "SqMtBldg"

        # test data set 3
        self.fp3_path = self.test_data_dir + "footprints3.shp"
        self.fp3_height_field = "HEIGHT"
        self.fp3_feature_count = 785
        self.fp3_total_area = 774814.441
        self.gemdb3_path = self.test_data_dir + "survey3.db3"
        self.zone3_path = self.test_data_dir + "zones3.shp"
        self.zone3_field = "ZONE"
        self.zone3_bldgcount_field = "NumBldgs"
        self.zone3_bldgarea_field = "SqMtBldg"
        self.zone3_total_bldg_cnt = 850
        self.zone3_total_bldg_area = 500000

        self.popgrid_path = self.test_data_dir + "popgrid.shp"
        self.pop_field = "Population"
        self.popgrid_feature_count = 4
        self.popgrid_zone_path = self.test_data_dir + "popgrid_zone.shp"
        self.popgrid_zone_field = "ZONE"

        self.grid_path = self.test_data_dir + "grid.shp"
        self.grid2_path = self.test_data_dir + "grid2.shp"

        self.operator_options = {
            "tmp_dir": self.test_tmp_dir,
            "taxonomy": self.taxonomy,
            "attribute.order": [
                "Material Type",
                "Material Technology",
                "Lateral Load Resisting System",
                "Height",
                "Occupancy",
            ],
        }
Beispiel #6
0
    def setUp(self):
        super(OperatorTestCase, self).setUp()
        self.taxonomy = get_taxonomy("gem")

        # test data set 1
        self.ms_file = self.test_data_dir + "ms.xml"
        self.fp_path = self.test_data_dir + 'footprint.shp'
        self.fp_feature_count = 1475
        self.zone1_path = self.test_data_dir + "zones1.shp"
        self.zone1_field = "ZONE"

        # test data set 2
        self.zone2_path = self.test_data_dir + "zones2.shp"
        self.zone2_field = 'LandUse'
        self.zone2_feature_count = 546
        self.zone2_total_bldg_cnt = 292377
        self.zone2_total_bldg_area = 71582303
        self.zone2_bldgcount_field = 'NumBldg'
        self.zone2_bldgarea_field = 'SqMtBldg'

        # test data set 3
        self.fp3_path = self.test_data_dir + "footprints3.shp"
        self.fp3_height_field = "HEIGHT"
        self.fp3_feature_count = 785
        self.fp3_total_area = 774814.441
        self.gemdb3_path = self.test_data_dir + "survey3.db3"
        self.zone3_path = self.test_data_dir + "zones3.shp"
        self.zone3_field = "ZONE"
        self.zone3_bldgcount_field = 'NumBldgs'
        self.zone3_bldgarea_field = 'SqMtBldg'
        self.zone3_total_bldg_cnt = 850
        self.zone3_total_bldg_area = 500000

        self.popgrid_path = self.test_data_dir + 'popgrid.shp'
        self.pop_field = "Population"
        self.popgrid_feature_count = 4
        self.popgrid_zone_path = self.test_data_dir + 'popgrid_zone.shp'
        self.popgrid_zone_field = "ZONE"

        self.grid_path = self.test_data_dir + "grid.shp"
        self.grid2_path = self.test_data_dir + "grid2.shp"

        self.operator_options = {
            'tmp_dir':
            self.test_tmp_dir,
            'taxonomy':
            self.taxonomy,
            'attribute.order': [
                'Material Type', 'Material Technology',
                'Lateral Load Resisting System', 'Height', 'Occupancy'
            ],
        }
Beispiel #7
0
Datei: ms.py Projekt: gem/sidd
    def from_xml_tree(self, tree):
        # check to make sure it is correct.
        # use DTD???
        tax = tree.find('taxonomy')
        self.taxonomy = get_taxonomy(tax.find('name').text)
        self.ms = {}
        for zone in tree.findall("zone"):
            stats = Statistics(self.taxonomy)
            stats.from_xml(zone.find('node'))
            stats.finalized = True
            #stats.finalize()
            stats.attributes = stats.get_attributes(stats.get_tree())

            #self.ms[zone.attrib['name']] = stats
            ms_zone = MappingSchemeZone(get_node_attrib(zone, 'name'))
            ms_zone.stats = stats
            self.zones.append(ms_zone)

        self.sort_zones()
Beispiel #8
0
    def from_xml_tree(self, tree):
        # check to make sure it is correct.
        # use DTD???
        tax = tree.find('taxonomy')
        self.taxonomy = get_taxonomy(tax.find('name').text)        
        self.ms = {}
        for zone in tree.findall("zone"):
            stats = Statistics(self.taxonomy)
            stats.from_xml(zone.find('node'))
            stats.finalized = True
            #stats.finalize()
            stats.attributes = stats.get_attributes(stats.get_tree())

            #self.ms[zone.attrib['name']] = stats
            ms_zone = MappingSchemeZone(get_node_attrib(zone, 'name'))
            ms_zone.stats = stats
            self.zones.append(ms_zone)
                      
        self.sort_zones()
Beispiel #9
0
    def setUp(self):
        super(ProjectTestCase, self).setUp()
        
        self.taxonomy = get_taxonomy("gem")
        self.test_config = SIDDConfig(self.test_data_dir + '/test.cfg')
        
        self.proj_file = self.test_data_dir +  'test.db'
        self.proj_file3 = self.test_data_dir +  'test3.db'
        
        self.fp_path = self.test_data_dir +  'footprints3.shp'
        self.survey_path = self.test_data_dir +  "survey3.db3"
        self.zone_path = self.test_data_dir +  "zones3.shp"
        self.zone_field = 'LandUse'
        self.bldgcount_field = 'NumBldg'

        self.zone2_path = self.test_data_dir +  "zones2.shp"
        self.zone2_field = "ZONE"
        
        self.operator_options = {
            'tmp_dir': self.test_tmp_dir,
            'taxonomy':self.taxonomy,
            'skips': self.test_config.get('options', 'skips', [], types.ListType),     
        }
Beispiel #10
0
    def __init__(self, qtapp, app_config):
        """
        constructor
        - initialize UI elements
        - connect UI elements to callback            
        """
        # create UI
        super(AppMainWindow, self).__init__()
        AppMainWindow.apiCallChecker.setWindow(self)
        
        self.qtapp = qtapp
        self.app_config = app_config
        self.taxonomy = get_taxonomy(app_config.get('options', 'taxonomy', 'gem'))
        self.ui = Ui_mainWindow()
        self.ui.setupUi(self)
        
        self.settings = QSettings(SIDD_COMPANY, '%s %s' %(SIDD_APP_NAME, SIDD_VERSION));
        self.restoreGeometry(self.settings.value(self.UI_WINDOW_GEOM).toByteArray());
        self.restoreState(self.settings.value(self.UI_WINDOW_STATE).toByteArray());
        
        self.lb_map_location = QLabel(self)
        self.lb_map_location.resize(self.ui.statusbar.width()/3, self.ui.statusbar.height())
        self.ui.statusbar.addPermanentWidget(self.lb_map_location)
        
        self.msdb_dao = MSDatabaseDAO(FILE_MS_DB)
        
        self.tab_datainput = WidgetDataInput(self)
        self.ui.mainTabs.addTab(self.tab_datainput, get_ui_string("app.window.tab.input"))

        self.tab_ms = WidgetMappingSchemes(self)
        self.ui.mainTabs.addTab(self.tab_ms, get_ui_string("app.window.tab.ms"))

        self.tab_mod = WidgetSecondaryModifier(self)
        self.ui.mainTabs.addTab(self.tab_mod, get_ui_string("app.window.tab.mod"))

        self.tab_result = WidgetResult(self)
        self.ui.mainTabs.addTab(self.tab_result, get_ui_string("app.window.tab.result"))
        self.previewInput = True
        
        self.about = DialogAbout(self)
        self.about.setModal(True)        
        
        self.dlgAttrRange = DialogAttrRanges()
        self.dlgAttrRange.setModal(True)
        
        self.progress = DialogApply(self)
        self.progress.setModal(True)
        
        self.proc_options = DialogProcessingOptions(self)
        self.proc_options.setModal(True)
        
        # connect menu action to slots (ui events)        
        self.ui.mainTabs.currentChanged.connect(self.tabChanged)
        
        self.ui.actionProject_Blank.triggered.connect(self.createBlank)
        self.ui.actionUsing_Data_Wizard.triggered.connect(self.createWizard)
        self.ui.actionOpen_Existing.triggered.connect(self.loadProj)
        self.ui.actionSave.triggered.connect(self.saveProj)
        self.ui.actionSave_as.triggered.connect(self.saveProjAs)
        self.ui.actionExit.triggered.connect(self.close)
        
        self.ui.actionData_Input.triggered.connect(self.changeTab)
        self.ui.actionMapping_Schemes.triggered.connect(self.changeTab)
        self.ui.actionResult.triggered.connect(self.changeTab)
        
        self.ui.actionProcessing_Options.triggered.connect(self.setProcessingOptions)
        
        self.ui.actionAbout.triggered.connect(self.showAbout)
        
        # set project to None and adjust ui as needed
        self.closeProject()        
        self.ui.statusbar.showMessage(get_ui_string("app.status.ready"))

        # perform clean up from previous runs
        try:
            delete_folders_in_dir(get_temp_dir(), "tmp*")
        except:
            # cleanup is not-critical. no action taken even if fails
            pass

        # hide features 
        if not app_config.get('options', 'parse_modifier', True, bool):
            self.tab_mod.setVisible(False)
            self.ui.mainTabs.removeTab(self.TAB_MOD) 
            self.TAB_MOD = self.TAB_MS
            self.TAB_RESULT -= 1             
            
        # hide view menu
        self.ui.menuView.menuAction().setVisible(False)
        # hide data wizard
        self.ui.actionUsing_Data_Wizard.setVisible(False)
Beispiel #11
0
 def setUp(self):
     super(MSTestCase, self).setUp()
     self.taxonomy = get_taxonomy("gem")
     self.survey_file = self.test_data_dir + "survey.csv"
     self.ms_file = self.test_data_dir + "ms.xml"
     self.ms_parse_order = ['Material Type', 'Material Technology', 'Lateral Load Resisting System', 'Height', 'Occupancy']
Beispiel #12
0
    def __init__(self, qtapp, app_config):
        """
        constructor
        - initialize UI elements
        - connect UI elements to callback            
        """
        # create UI
        super(AppMainWindow, self).__init__()
        AppMainWindow.apiCallChecker.setWindow(self)

        self.qtapp = qtapp
        self.app_config = app_config
        self.taxonomy = get_taxonomy(
            app_config.get('options', 'taxonomy', 'gem'))
        self.ui = Ui_mainWindow()
        self.ui.setupUi(self)

        self.settings = QSettings(SIDD_COMPANY,
                                  '%s %s' % (SIDD_APP_NAME, SIDD_VERSION))
        self.restoreGeometry(
            self.settings.value(self.UI_WINDOW_GEOM).toByteArray())
        self.restoreState(
            self.settings.value(self.UI_WINDOW_STATE).toByteArray())

        self.lb_map_location = QLabel(self)
        self.lb_map_location.resize(self.ui.statusbar.width() / 3,
                                    self.ui.statusbar.height())
        self.ui.statusbar.addPermanentWidget(self.lb_map_location)

        self.msdb_dao = MSDatabaseDAO(FILE_MS_DB)

        self.tab_datainput = WidgetDataInput(self)
        self.ui.mainTabs.addTab(self.tab_datainput,
                                get_ui_string("app.window.tab.input"))

        self.tab_ms = WidgetMappingSchemes(self)
        self.ui.mainTabs.addTab(self.tab_ms,
                                get_ui_string("app.window.tab.ms"))

        self.tab_mod = WidgetSecondaryModifier(self)
        self.ui.mainTabs.addTab(self.tab_mod,
                                get_ui_string("app.window.tab.mod"))

        self.tab_result = WidgetResult(self)
        self.ui.mainTabs.addTab(self.tab_result,
                                get_ui_string("app.window.tab.result"))
        self.previewInput = True

        self.about = DialogAbout(self)
        self.about.setModal(True)

        self.dlgAttrRange = DialogAttrRanges()
        self.dlgAttrRange.setModal(True)

        self.progress = DialogApply(self)
        self.progress.setModal(True)

        self.proc_options = DialogProcessingOptions(self)
        self.proc_options.setModal(True)

        # connect menu action to slots (ui events)
        self.ui.mainTabs.currentChanged.connect(self.tabChanged)

        self.ui.actionProject_Blank.triggered.connect(self.createBlank)
        self.ui.actionUsing_Data_Wizard.triggered.connect(self.createWizard)
        self.ui.actionOpen_Existing.triggered.connect(self.loadProj)
        self.ui.actionSave.triggered.connect(self.saveProj)
        self.ui.actionSave_as.triggered.connect(self.saveProjAs)
        self.ui.actionExit.triggered.connect(self.close)

        self.ui.actionData_Input.triggered.connect(self.changeTab)
        self.ui.actionMapping_Schemes.triggered.connect(self.changeTab)
        self.ui.actionResult.triggered.connect(self.changeTab)

        self.ui.actionProcessing_Options.triggered.connect(
            self.setProcessingOptions)

        self.ui.actionAbout.triggered.connect(self.showAbout)

        # set project to None and adjust ui as needed
        self.closeProject()
        self.ui.statusbar.showMessage(get_ui_string("app.status.ready"))

        # perform clean up from previous runs
        try:
            delete_folders_in_dir(get_temp_dir(), "tmp*")
        except:
            # cleanup is not-critical. no action taken even if fails
            pass

        # hide features
        if not app_config.get('options', 'parse_modifier', True, bool):
            self.tab_mod.setVisible(False)
            self.ui.mainTabs.removeTab(self.TAB_MOD)
            self.TAB_MOD = self.TAB_MS
            self.TAB_RESULT -= 1

        # hide view menu
        self.ui.menuView.menuAction().setVisible(False)
        # hide data wizard
        self.ui.actionUsing_Data_Wizard.setVisible(False)
Beispiel #13
0
 def setUp(self):
     super(TaxonomyTestCase, self).setUp()
     self.taxonomy = get_taxonomy("gem")
Beispiel #14
0
 def __init__(self, options=None, name='Empty MS Creator'):
     super(EmptyMSCreator, self).__init__(options, name)
     self._tmp_dir = get_dictionary_value(options, 'tmp_dir', get_temp_dir())
     self._taxonomy = get_dictionary_value(options, 'taxonomy', get_taxonomy('GEM'))  
     self._parse_modifiers = get_dictionary_value(options, 'parse_modifiers', True)
     self._parse_order = get_dictionary_value(options, 'attribute.order', None)
Beispiel #15
0
 def setUp(self):
     super(TaxonomyTestCase, self).setUp()
     self.taxonomy = get_taxonomy("gem")