Esempio n. 1
0
    def exposure_class_fields(
            cls, layer_mode_key=None, layer_geometry_key=None,
            exposure_key=None):
        """Return list of exposure class field.

        :param layer_mode_key: The layer mode key
        :type layer_mode_key: str

        :param layer_geometry_key: The layer geometry key
        :type layer_geometry_key: str

        :param exposure_key: The exposure key
        :type exposure_key: str

        :returns: List of exposure class field.
        :rtype: list
        """
        exposure_layer_req = cls.get_exposure_requirements()
        layer_mode = exposure_layer_req['layer_mode']
        layer_geometries = exposure_layer_req['layer_geometries']
        exposures = exposure_layer_req['exposure_types']

        if layer_mode_key:
            if layer_mode_key != layer_mode['key']:
                return []
        if layer_geometry_key:
            if not is_key_exist(layer_geometry_key, layer_geometries):
                return []
        if exposure_key:
            if not is_key_exist(exposure_key, exposures):
                return []

        result = exposure_layer_req['exposure_class_fields']

        return result
    def exposure_class_fields(
            cls, layer_mode_key=None, layer_geometry_key=None,
            exposure_key=None):
        """Return list of exposure class field.

        :param layer_mode_key: The layer mode key
        :type layer_mode_key: str

        :param layer_geometry_key: The layer geometry key
        :type layer_geometry_key: str

        :param exposure_key: The exposure key
        :type exposure_key: str

        :returns: List of exposure class field.
        :rtype: list
        """
        exposure_layer_req = cls.get_exposure_requirements()
        layer_mode = exposure_layer_req['layer_mode']
        layer_geometries = exposure_layer_req['layer_geometries']
        exposures = exposure_layer_req['exposure_types']

        if layer_mode_key:
            if layer_mode_key != layer_mode['key']:
                return []
        if layer_geometry_key:
            if not is_key_exist(layer_geometry_key, layer_geometries):
                return []
        if exposure_key:
            if not is_key_exist(exposure_key, exposures):
                return []

        result = exposure_layer_req['exposure_class_fields']

        return result
    def is_function_for_constraint(
        cls,
        hazard_key,
        exposure_key,
        hazard_geometry_key=None,
        exposure_geometry_key=None,
        hazard_mode_key=None,
        exposure_mode_key=None,
    ):
        """Check if the constraints match with the function.

        :param hazard_key: The hazard key
        :type hazard_key: str

        :param exposure_key: the exposure key
        :type exposure_key: str

        :param hazard_geometry_key: The hazard geometry key
        :type hazard_geometry_key: str

        :param exposure_geometry_key: The exposure geometry key
        :type exposure_geometry_key: str

        :param hazard_mode_key: The hazard mode key
        :type hazard_mode_key: str

        :param exposure_mode_key: The exposure mode key
        :type exposure_mode_key: str

        :returns: True if match, else False
        :rtype: bool
        """
        hazard_layer_req = cls.get_hazard_requirements()
        exposure_layer_req = cls.get_exposure_requirements()

        hazards = hazard_layer_req["hazard_types"]
        exposures = exposure_layer_req["exposure_types"]
        hazard_geometries = hazard_layer_req["layer_geometries"]
        exposure_geometries = exposure_layer_req["layer_geometries"]
        hazard_mode = hazard_layer_req["layer_mode"]
        exposure_mode = exposure_layer_req["layer_mode"]

        if not is_key_exist(hazard_key, hazards):
            return False
        if not is_key_exist(exposure_key, exposures):
            return False
        if hazard_geometry_key:
            if not is_key_exist(hazard_geometry_key, hazard_geometries):
                return False
        if exposure_geometry_key:
            if not is_key_exist(exposure_geometry_key, exposure_geometries):
                return False
        if hazard_mode_key:
            if hazard_mode_key != hazard_mode["key"]:
                return False
        if exposure_mode_key:
            if exposure_mode_key != exposure_mode["key"]:
                return False

        return True
    def exposure_additional_keywords(
            cls, layer_mode_key=None, layer_geometry_key=None,
            exposure_key=None):
        """Return additional_keywords for exposure.

        :param layer_mode_key: The layer mode key
        :type layer_mode_key: str

        :param layer_geometry_key: The layer geometry key
        :type layer_geometry_key: str

        :param exposure_key: The hazard key
        :type exposure_key: str

        :returns: List of additional keywords
        :rtype: list
        """
        exposure_layer_req = cls.get_exposure_requirements()
        layer_mode = exposure_layer_req['layer_mode']
        layer_geometries = exposure_layer_req['layer_geometries']
        exposures = exposure_layer_req['exposure_types']

        if layer_mode_key:
            if layer_mode_key != layer_mode['key']:
                return []
        if layer_geometry_key:
            if not is_key_exist(layer_geometry_key, layer_geometries):
                return []
        if exposure_key:
            if not is_key_exist(exposure_key, exposures):
                return []

        additional_keywords = exposure_layer_req['additional_keywords']

        return additional_keywords
    def available_exposure_layer_mode(
            cls, exposure_key, exposure_geometry_key):
        """Get exposure layer mode for exposure_key.

        :param exposure_key: The exposure key
        :type exposure_key: str

        :param exposure_geometry_key: The exposure geometry key
        :type exposure_geometry_key: str

        :returns: A layer mode
        :rtype: dict
        """
        exposure_layer_req = cls.get_exposure_requirements()
        exposures = exposure_layer_req['exposure_types']
        exposure_geometries = exposure_layer_req['layer_geometries']

        if not is_key_exist(exposure_key, exposures):
            return None
        if not is_key_exist(exposure_geometry_key, exposure_geometries):
            return None

        layer_mode = exposure_layer_req['layer_mode']

        return layer_mode
Esempio n. 6
0
    def available_exposure_layer_mode(cls, exposure_key,
                                      exposure_geometry_key):
        """Get exposure layer mode for exposure_key.

        :param exposure_key: The exposure key
        :type exposure_key: str

        :param exposure_geometry_key: The exposure geometry key
        :type exposure_geometry_key: str

        :returns: A layer mode
        :rtype: dict
        """
        exposure_layer_req = cls.get_exposure_requirements()
        exposures = exposure_layer_req['exposure_types']
        exposure_geometries = exposure_layer_req['layer_geometries']

        if not is_key_exist(exposure_key, exposures):
            return None
        if not is_key_exist(exposure_geometry_key, exposure_geometries):
            return None

        layer_mode = exposure_layer_req['layer_mode']

        return layer_mode
    def available_hazard_layer_mode(
            cls, hazard_key, hazard_geometry_key, hazard_category_key):
        """Return all available layer_mode.

        :param hazard_key: The hazard key
        :type hazard_key: str

        :param hazard_geometry_key: The hazard geometry key
        :type hazard_geometry_key: str

        :param hazard_category_key: The hazard category key
        :type hazard_category_key: str

        :returns: A layer mode
        :rtype: dict, None
        """

        hazard_layer_req = cls.get_hazard_requirements()
        hazards = hazard_layer_req['hazard_types']
        hazard_categories = hazard_layer_req['hazard_categories']
        hazard_geometries = hazard_layer_req['layer_geometries']

        if not is_key_exist(hazard_key, hazards):
            return None
        if not is_key_exist(hazard_geometry_key, hazard_geometries):
            return None
        if not is_key_exist(hazard_category_key, hazard_categories):
            return None

        layer_mode = hazard_layer_req['layer_mode']

        return layer_mode
    def available_hazard_constraints(cls, hazard_key, hazard_category_key):
        """Get hazard constraints for hazard_key and hazard_category_key

        :param hazard_key: The hazard key
        :type hazard_key: str

        :param hazard_category_key: The hazard category key
        :type hazard_category_key: str

        :returns: List of tuple of layer_mode and layer_geometry
        :rtype: list
        """
        hazard_layer_req = cls.get_hazard_requirements()
        hazards = hazard_layer_req['hazard_types']
        hazard_categories = hazard_layer_req['hazard_categories']

        if not is_key_exist(hazard_key, hazards):
            return []
        if not is_key_exist(hazard_category_key, hazard_categories):
            return []

        layer_mode = hazard_layer_req['layer_mode']
        layer_geometries = hazard_layer_req['layer_geometries']

        result = []
        for layer_geometry in layer_geometries:
            result.append((layer_mode, layer_geometry))

        return result
Esempio n. 9
0
    def exposure_additional_keywords(
            cls, layer_mode_key=None, layer_geometry_key=None,
            exposure_key=None):
        """Return additional_keywords for exposure.

        :param layer_mode_key: The layer mode key
        :type layer_mode_key: str

        :param layer_geometry_key: The layer geometry key
        :type layer_geometry_key: str

        :param exposure_key: The hazard key
        :type exposure_key: str

        :returns: List of additional keywords
        :rtype: list
        """
        exposure_layer_req = cls.get_exposure_requirements()
        layer_mode = exposure_layer_req['layer_mode']
        layer_geometries = exposure_layer_req['layer_geometries']
        exposures = exposure_layer_req['exposure_types']

        if layer_mode_key:
            if layer_mode_key != layer_mode['key']:
                return []
        if layer_geometry_key:
            if not is_key_exist(layer_geometry_key, layer_geometries):
                return []
        if exposure_key:
            if not is_key_exist(exposure_key, exposures):
                return []

        additional_keywords = exposure_layer_req['additional_keywords']

        return additional_keywords
Esempio n. 10
0
    def available_hazard_layer_mode(cls, hazard_key, hazard_geometry_key,
                                    hazard_category_key):
        """Return all available layer_mode.

        :param hazard_key: The hazard key
        :type hazard_key: str

        :param hazard_geometry_key: The hazard geometry key
        :type hazard_geometry_key: str

        :param hazard_category_key: The hazard category key
        :type hazard_category_key: str

        :returns: A layer mode
        :rtype: dict, None
        """

        hazard_layer_req = cls.get_hazard_requirements()
        hazards = hazard_layer_req['hazard_types']
        hazard_categories = hazard_layer_req['hazard_categories']
        hazard_geometries = hazard_layer_req['layer_geometries']

        if not is_key_exist(hazard_key, hazards):
            return None
        if not is_key_exist(hazard_geometry_key, hazard_geometries):
            return None
        if not is_key_exist(hazard_category_key, hazard_categories):
            return None

        layer_mode = hazard_layer_req['layer_mode']

        return layer_mode
Esempio n. 11
0
    def available_hazard_constraints(cls, hazard_key, hazard_category_key):
        """Get hazard constraints for hazard_key and hazard_category_key

        :param hazard_key: The hazard key
        :type hazard_key: str

        :param hazard_category_key: The hazard category key
        :type hazard_category_key: str

        :returns: List of tuple of layer_mode and layer_geometry
        :rtype: list
        """
        hazard_layer_req = cls.get_hazard_requirements()
        hazards = hazard_layer_req['hazard_types']
        hazard_categories = hazard_layer_req['hazard_categories']

        if not is_key_exist(hazard_key, hazards):
            return []
        if not is_key_exist(hazard_category_key, hazard_categories):
            return []

        layer_mode = hazard_layer_req['layer_mode']
        layer_geometries = hazard_layer_req['layer_geometries']

        result = []
        for layer_geometry in layer_geometries:
            result.append((layer_mode, layer_geometry))

        return result
Esempio n. 12
0
    def is_function_for_constraint(cls,
                                   hazard_key,
                                   exposure_key,
                                   hazard_geometry_key=None,
                                   exposure_geometry_key=None,
                                   hazard_mode_key=None,
                                   exposure_mode_key=None):
        """Check if the constraints match with the function.

        :param hazard_key: The hazard key
        :type hazard_key: str

        :param exposure_key: the exposure key
        :type exposure_key: str

        :param hazard_geometry_key: The hazard geometry key
        :type hazard_geometry_key: str

        :param exposure_geometry_key: The exposure geometry key
        :type exposure_geometry_key: str

        :param hazard_mode_key: The hazard mode key
        :type hazard_mode_key: str

        :param exposure_mode_key: The exposure mode key
        :type exposure_mode_key: str

        :returns: True if match, else False
        :rtype: bool
        """
        hazard_layer_req = cls.get_hazard_requirements()
        exposure_layer_req = cls.get_exposure_requirements()

        hazards = hazard_layer_req['hazard_types']
        exposures = exposure_layer_req['exposure_types']
        hazard_geometries = hazard_layer_req['layer_geometries']
        exposure_geometries = exposure_layer_req['layer_geometries']
        hazard_mode = hazard_layer_req['layer_mode']
        exposure_mode = exposure_layer_req['layer_mode']

        if not is_key_exist(hazard_key, hazards):
            return False
        if not is_key_exist(exposure_key, exposures):
            return False
        if hazard_geometry_key:
            if not is_key_exist(hazard_geometry_key, hazard_geometries):
                return False
        if exposure_geometry_key:
            if not is_key_exist(exposure_geometry_key, exposure_geometries):
                return False
        if hazard_mode_key:
            if hazard_mode_key != hazard_mode['key']:
                return False
        if exposure_mode_key:
            if exposure_mode_key != exposure_mode['key']:
                return False

        return True
Esempio n. 13
0
    def hazard_additional_keywords(cls,
                                   layer_mode_key=None,
                                   layer_geometry_key=None,
                                   hazard_category_key=None,
                                   hazard_key=None):
        """Return additional_keywords for hazard.

        :param layer_mode_key: The layer mode key
        :type layer_mode_key: str

        :param layer_geometry_key: The layer geometry key
        :type layer_geometry_key: str

        :param hazard_category_key: The hazard category key
        :type hazard_category_key: str

        :param hazard_key: The hazard key
        :type hazard_key: str

        :returns: List of additional keywords
        :rtype: list
        """
        hazard_layer_req = cls.get_hazard_requirements()
        layer_mode = hazard_layer_req['layer_mode']
        layer_geometries = hazard_layer_req['layer_geometries']
        hazard_categories = hazard_layer_req['hazard_categories']
        hazards = hazard_layer_req['hazard_types']

        if layer_mode_key:
            if layer_mode_key != layer_mode['key']:
                return []
        if layer_geometry_key:
            if not is_key_exist(layer_geometry_key, layer_geometries):
                return []
        if hazard_category_key:
            if not is_key_exist(hazard_category_key, hazard_categories):
                return []
        if hazard_key:
            if not is_key_exist(hazard_key, hazards):
                return []

        additional_keywords = hazard_layer_req['additional_keywords']

        return additional_keywords
    def hazard_additional_keywords(
            cls, layer_mode_key=None, layer_geometry_key=None,
            hazard_category_key=None, hazard_key=None):
        """Return additional_keywords for hazard.

        :param layer_mode_key: The layer mode key
        :type layer_mode_key: str

        :param layer_geometry_key: The layer geometry key
        :type layer_geometry_key: str

        :param hazard_category_key: The hazard category key
        :type hazard_category_key: str

        :param hazard_key: The hazard key
        :type hazard_key: str

        :returns: List of additional keywords
        :rtype: list
        """
        hazard_layer_req = cls.get_hazard_requirements()
        layer_mode = hazard_layer_req['layer_mode']
        layer_geometries = hazard_layer_req['layer_geometries']
        hazard_categories = hazard_layer_req['hazard_categories']
        hazards = hazard_layer_req['hazard_types']

        if layer_mode_key:
            if layer_mode_key != layer_mode['key']:
                return []
        if layer_geometry_key:
            if not is_key_exist(layer_geometry_key, layer_geometries):
                return []
        if hazard_category_key:
            if not is_key_exist(hazard_category_key, hazard_categories):
                return []
        if hazard_key:
            if not is_key_exist(hazard_key, hazards):
                return []

        additional_keywords = hazard_layer_req['additional_keywords']

        return additional_keywords
    def hazards_for_layer(cls, hazard_geometry_key, hazard_category_key=None):
        """Get hazard categories form layer_geometry_key

        :param hazard_geometry_key: The geometry id
        :type hazard_geometry_key: str

        :param hazard_category_key: The hazard category
        :type hazard_category_key: str

        :returns: List of hazard
        :rtype: list
        """
        hazard_layer_req = cls.get_hazard_requirements()
        hazard_categories = hazard_layer_req['hazard_categories']
        hazard_geometries = hazard_layer_req['layer_geometries']

        if not is_key_exist(hazard_geometry_key, hazard_geometries):
            return []
        if hazard_category_key:
            if not is_key_exist(hazard_category_key, hazard_categories):
                return []

        return hazard_layer_req['hazard_types']
Esempio n. 16
0
    def hazards_for_layer(cls, hazard_geometry_key, hazard_category_key=None):
        """Get hazard categories form layer_geometry_key

        :param hazard_geometry_key: The geometry id
        :type hazard_geometry_key: str

        :param hazard_category_key: The hazard category
        :type hazard_category_key: str

        :returns: List of hazard
        :rtype: list
        """
        hazard_layer_req = cls.get_hazard_requirements()
        hazard_categories = hazard_layer_req['hazard_categories']
        hazard_geometries = hazard_layer_req['layer_geometries']

        if not is_key_exist(hazard_geometry_key, hazard_geometries):
            return []
        if hazard_category_key:
            if not is_key_exist(hazard_category_key, hazard_categories):
                return []

        return hazard_layer_req['hazard_types']
    def available_exposure_constraints(cls, exposure_key):
        """Get exposure constraints for exposure_key.

        :param exposure_key: The exposure key
        :type exposure_key: str

        :returns: List of tuple of layer_mode and layer_geometry
        :rtype: list
        """
        exposure_layer_req = cls.get_exposure_requirements()
        exposures = exposure_layer_req['exposure_types']

        if not is_key_exist(exposure_key, exposures):
            return []

        layer_mode = exposure_layer_req['layer_mode']
        layer_geometries = exposure_layer_req['layer_geometries']

        result = []
        for layer_geometry in layer_geometries:
            result.append((layer_mode, layer_geometry))

        return result
Esempio n. 18
0
    def available_exposure_constraints(cls, exposure_key):
        """Get exposure constraints for exposure_key.

        :param exposure_key: The exposure key
        :type exposure_key: str

        :returns: List of tuple of layer_mode and layer_geometry
        :rtype: list
        """
        exposure_layer_req = cls.get_exposure_requirements()
        exposures = exposure_layer_req['exposure_types']

        if not is_key_exist(exposure_key, exposures):
            return []

        layer_mode = exposure_layer_req['layer_mode']
        layer_geometries = exposure_layer_req['layer_geometries']

        result = []
        for layer_geometry in layer_geometries:
            result.append((layer_mode, layer_geometry))

        return result