def loadAreaSourceLayer(cls):
    """Load area source layer from Shapefile. Add required feature attributes
    if they are missing.
    """
    area_source_path = os.path.join(
        layers.DATA_DIR, ZONE_FILE_DIR,
        unicode(cls.comboBoxAreaZoneInput.currentText()))

    if not os.path.isfile(area_source_path):
        utils.warning_missing_layer_file(area_source_path)
        return

    save_path = os.path.join(layers.DATA_DIR, ZONE_FILE_DIR, TEMP_FILENAME)
    layer = loadAreaSourceFromSHP(area_source_path,
                                  cls.data.mmax,
                                  cls.background_zone_layer,
                                  save_path,
                                  layer2file=False)

    # register layer in QGis
    QgsMapLayerRegistry.instance().addMapLayer(layer)

    # set layer visibility
    cls.legend.setLayerVisible(layer, render.AREA_LAYER_STYLE['visible'])

    return layer
def loadFaultBackgroundLayer(cls):
    """Load fault source background layer from Shapefile.
    """
    fault_background_path = os.path.join(
        layers.DATA_DIR, FAULT_BACKGROUND_FILE_DIR,
        unicode(cls.comboBoxFaultBackgrZoneInput.currentText()))

    if not os.path.isfile(fault_background_path):
        utils.warning_missing_layer_file(fault_background_path)
        return

    save_path = os.path.join(layers.DATA_DIR, FAULT_BACKGROUND_FILE_DIR,
                             TEMP_FILENAME)
    layer = loadFaultBackgroundFromSHP(fault_background_path,
                                       save_path,
                                       layer2file=False)

    # register layer in QGis
    QgsMapLayerRegistry.instance().addMapLayer(layer)

    # set layer visibility
    cls.legend.setLayerVisible(layer,
                               render.FAULT_BACKGROUND_LAYER_STYLE['visible'])

    return layer
def loadEQCatalogLayer(cls):
    """Load EQ catalog layer from ASCII catalog file. 
    Add required feature attributes if they are missing.

    TODO(fab): load catalog from Python pickle of compact catalog format.
    """
    catalog_path = os.path.join(
        layers.DATA_DIR, CATALOG_DIR,
        unicode(cls.comboBoxEQCatalogInput.currentText()))

    if not os.path.isfile(catalog_path):
        utils.warning_missing_layer_file(catalog_path)
        return

    (layer, cls.catalog) = loadEQCatalogFromFile(catalog_path)

    # set time span of catalog
    cls.catalog_time_span = cls.catalog.timeSpan()

    # update layer's extent when new features have been added
    # because change of extent in provider is not
    # propagated to the layer
    layer.updateExtents()
    QgsMapLayerRegistry.instance().addMapLayer(layer)

    # set layer visibility
    cls.legend.setLayerVisible(layer, render.EQ_LAYER_STYLE['visible'])

    return layer
def loadEQCatalogLayer(cls):
    """Load EQ catalog layer from ASCII catalog file. 
    Add required feature attributes if they are missing.

    TODO(fab): load catalog from Python pickle of compact catalog format.
    """
    catalog_path = os.path.join(layers.DATA_DIR, CATALOG_DIR, 
        unicode(cls.comboBoxEQCatalogInput.currentText()))

    if not os.path.isfile(catalog_path):
        utils.warning_missing_layer_file(catalog_path)
        return

    (layer, cls.catalog) = loadEQCatalogFromFile(catalog_path)

    # set time span of catalog
    cls.catalog_time_span = cls.catalog.timeSpan()
    
    # update layer's extent when new features have been added
    # because change of extent in provider is not 
    # propagated to the layer
    layer.updateExtents()
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    # set layer visibility
    cls.legend.setLayerVisible(layer, render.EQ_LAYER_STYLE['visible'])
        
    return layer
def loadBackgroundLayer(cls):
    if cls.background_layer is None:
        background_path = os.path.join(layers.DATA_DIR, MAP_OVERLAY_DIR,
            MAP_OVERLAY_POLITICAL_FILE)

        if not os.path.isfile(background_path):
            utils.warning_missing_layer_file(background_path)
            return

        cls.background_layer = QgsVectorLayer(background_path, 
            "Political Boundaries", "ogr")
        QgsMapLayerRegistry.instance().addMapLayer(cls.background_layer)
        
        # set layer visibility
        cls.legend.setLayerVisible(cls.background_layer, 
            render.BACKGROUND_LAYER_STYLE['visible'])
def loadBackgroundLayer(cls):
    if cls.background_layer is None:
        background_path = os.path.join(layers.DATA_DIR, MAP_OVERLAY_DIR,
                                       MAP_OVERLAY_POLITICAL_FILE)

        if not os.path.isfile(background_path):
            utils.warning_missing_layer_file(background_path)
            return

        cls.background_layer = QgsVectorLayer(background_path,
                                              "Political Boundaries", "ogr")
        QgsMapLayerRegistry.instance().addMapLayer(cls.background_layer)

        # set layer visibility
        cls.legend.setLayerVisible(cls.background_layer,
                                   render.BACKGROUND_LAYER_STYLE['visible'])
def loadAreaSourceLayer(cls):
    """Load area source layer from Shapefile. Add required feature attributes
    if they are missing.
    """
    area_source_path = os.path.join(layers.DATA_DIR, 
        ZONE_FILE_DIR, unicode(cls.comboBoxAreaZoneInput.currentText()))
        
    if not os.path.isfile(area_source_path):
        utils.warning_missing_layer_file(area_source_path)
        return

    save_path = os.path.join(layers.DATA_DIR, ZONE_FILE_DIR, TEMP_FILENAME)
    layer = loadAreaSourceFromSHP(area_source_path, cls.data.mmax, 
        cls.background_zone_layer, save_path, layer2file=False)
    
    # register layer in QGis
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    # set layer visibility
    cls.legend.setLayerVisible(layer, render.AREA_LAYER_STYLE['visible'])
    
    return layer
def loadFaultSourceLayer(cls):
    """Load fault source layer from Shapefile. Add required feature attributes
    if they are missing.
    """
    fault_source_path = os.path.join(layers.DATA_DIR, 
        FAULT_FILE_DIR, unicode(cls.comboBoxFaultZoneInput.currentText()))

    if not os.path.isfile(fault_source_path):
        utils.warning_missing_layer_file(fault_source_path)
        return

    save_path = os.path.join(layers.DATA_DIR, FAULT_FILE_DIR, TEMP_FILENAME)
    layer = loadFaultSourceFromSHP(fault_source_path, save_path, 
        layer2file=False)
    
    # register layer in QGis
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    # set layer visibility
    cls.legend.setLayerVisible(layer, render.FAULT_LAYER_STYLE['visible'])
        
    return layer
def loadBackgroundZoneLayer(cls):
    """Load layer of background zones with completeness history and
    Mmax from ASCII files. 
    """
    background_mmax_path = os.path.join(layers.DATA_DIR, BACKGROUND_DIR,
                                        BACKGROUND_ZONES_MMAX_FILE)

    if not os.path.isfile(background_mmax_path):
        utils.warning_missing_layer_file(background_mmax_path)
        return None

    background_completeness_path = os.path.join(
        layers.DATA_DIR, BACKGROUND_DIR, BACKGROUND_ZONES_COMPLETENESS_FILE)

    if not os.path.isfile(background_completeness_path):
        utils.warning_missing_layer_file(background_completeness_path)
        return None

    save_path = os.path.join(layers.DATA_DIR, BACKGROUND_DIR, TEMP_FILENAME)
    layer = loadBackgroundZoneFromFile(background_mmax_path,
                                       background_completeness_path,
                                       save_path,
                                       layer2file=False)

    # update layer's extent when new features have been added
    # because change of extent in provider is not
    # propagated to the layer
    layer.updateExtents()
    QgsMapLayerRegistry.instance().addMapLayer(layer)

    # set layer as not visible
    cls.legend.setLayerVisible(layer, False)

    # set layer visibility
    cls.legend.setLayerVisible(layer,
                               render.BACKGROUND_ZONE_LAYER_STYLE['visible'])

    return layer
Exemple #10
0
def loadFaultSourceLayer(cls):
    """Load fault source layer from Shapefile. Add required feature attributes
    if they are missing.
    """
    fault_source_path = os.path.join(
        layers.DATA_DIR, FAULT_FILE_DIR,
        unicode(cls.comboBoxFaultZoneInput.currentText()))

    if not os.path.isfile(fault_source_path):
        utils.warning_missing_layer_file(fault_source_path)
        return

    save_path = os.path.join(layers.DATA_DIR, FAULT_FILE_DIR, TEMP_FILENAME)
    layer = loadFaultSourceFromSHP(fault_source_path,
                                   save_path,
                                   layer2file=False)

    # register layer in QGis
    QgsMapLayerRegistry.instance().addMapLayer(layer)

    # set layer visibility
    cls.legend.setLayerVisible(layer, render.FAULT_LAYER_STYLE['visible'])

    return layer
def loadBackgroundZoneLayer(cls):
    """Load layer of background zones with completeness history and
    Mmax from ASCII files. 
    """
    background_mmax_path = os.path.join(layers.DATA_DIR, BACKGROUND_DIR, 
        BACKGROUND_ZONES_MMAX_FILE)

    if not os.path.isfile(background_mmax_path):
        utils.warning_missing_layer_file(background_mmax_path)
        return None

    background_completeness_path = os.path.join(layers.DATA_DIR, 
        BACKGROUND_DIR, BACKGROUND_ZONES_COMPLETENESS_FILE)

    if not os.path.isfile(background_completeness_path):
        utils.warning_missing_layer_file(background_completeness_path)
        return None

    save_path = os.path.join(layers.DATA_DIR, BACKGROUND_DIR, TEMP_FILENAME)
    layer = loadBackgroundZoneFromFile(background_mmax_path, 
        background_completeness_path, save_path, layer2file=False)

    # update layer's extent when new features have been added
    # because change of extent in provider is not 
    # propagated to the layer
    layer.updateExtents()
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    # set layer as not visible
    cls.legend.setLayerVisible(layer, False)
    
    # set layer visibility
    cls.legend.setLayerVisible(layer, 
        render.BACKGROUND_ZONE_LAYER_STYLE['visible'])
    
    return layer
def loadFaultBackgroundLayer(cls):
    """Load fault source background layer from Shapefile.
    """
    fault_background_path = os.path.join(layers.DATA_DIR, 
        FAULT_BACKGROUND_FILE_DIR, unicode(
            cls.comboBoxFaultBackgrZoneInput.currentText()))

    if not os.path.isfile(fault_background_path):
        utils.warning_missing_layer_file(fault_background_path)
        return

    save_path = os.path.join(layers.DATA_DIR, FAULT_BACKGROUND_FILE_DIR, 
        TEMP_FILENAME)
    layer = loadFaultBackgroundFromSHP(fault_background_path, save_path,
        layer2file=False)

    # register layer in QGis
    QgsMapLayerRegistry.instance().addMapLayer(layer)
    
    # set layer visibility
    cls.legend.setLayerVisible(layer, 
        render.FAULT_BACKGROUND_LAYER_STYLE['visible'])
    
    return layer