# Path: safe/common/utilities.py
# def get_utm_epsg(longitude, latitude, crs=None):
#     """Return epsg code of the utm zone according to X, Y coordinates.
# 
#     By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will
#     be reprojected from the input CRS to WGS84.
# 
#     The code is based on the code:
#     http://gis.stackexchange.com/questions/34401
# 
#     :param longitude: The longitude.
#     :type longitude: float
# 
#     :param latitude: The latitude.
#     :type latitude: float
# 
#     :param crs: The coordinate reference system of the latitude, longitude.
#     :type crs: QgsCoordinateReferenceSystem
#     """
#     if crs is None or crs.authid() == 'EPSG:4326':
#         epsg = 32600
#         if latitude < 0.0:
#             epsg += 100
#         epsg += get_utm_zone(longitude)
#         return epsg
#     else:
#         epsg_4326 = QgsCoordinateReferenceSystem('EPSG:4326')
#         transform = QgsCoordinateTransform(
#             crs, epsg_4326, QgsProject.instance())
#         geom = QgsGeometry.fromPointXY(QgsPointXY(longitude, latitude))
#         geom.transform(transform)
#         point = geom.asPoint()
#         # The point is now in 4326, we can call the function again.
#         return get_utm_epsg(point.x(), point.y())
# 
# Path: safe/definitions/layer_purposes.py



from qgis.core import (
    QgsCoordinateReferenceSystem,
    QgsCoordinateTransform,
    QgsProject,
    QgsGeometry,
    QgsFeature,
    QgsWkbTypes,
)
from safe.common.utilities import get_utm_epsg
from safe.definitions.fields import hazard_class_field, buffer_distance_field
from safe.definitions.layer_purposes import layer_purpose_hazard
from safe.definitions.processing_steps import buffer_steps
from safe.gis.sanity_check import check_layer
from safe.gis.vector.tools import (
    create_memory_layer,
    create_field_from_definition)
from safe.utilities.profiling import profile
        should accept params 'current' (int), 'maximum' (int) and 'step' (str).
        Defaults to None.
    :type callback: function

    :return: The buffered vector layer.
    :rtype: QgsVectorLayer
    """
    # Layer output
    output_layer_name = buffer_steps['output_layer_name']
    processing_step = buffer_steps['step_name']

    input_crs = layer.crs()
    feature_count = layer.featureCount()

    fields = layer.fields()
    # Set the new hazard class field.
    new_field = create_field_from_definition(hazard_class_field)
    fields.append(new_field)
    # Set the new buffer distances field.
    new_field = create_field_from_definition(buffer_distance_field)
    fields.append(new_field)

    buffered = create_memory_layer(
        output_layer_name, QgsWkbTypes.PolygonGeometry, input_crs, fields)
    buffered.startEditing()

    # Reproject features if needed into UTM if the layer is in 4326.
    if layer.crs().authid() == 'EPSG:4326':
        center = layer.extent().center()
        utm = QgsCoordinateReferenceSystem(

# Path: safe/common/utilities.py
# def get_utm_epsg(longitude, latitude, crs=None):
#     """Return epsg code of the utm zone according to X, Y coordinates.
# 
#     By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will
#     be reprojected from the input CRS to WGS84.
# 
#     The code is based on the code:
#     http://gis.stackexchange.com/questions/34401
# 
#     :param longitude: The longitude.
#     :type longitude: float
# 
#     :param latitude: The latitude.
#     :type latitude: float
# 
#     :param crs: The coordinate reference system of the latitude, longitude.
#     :type crs: QgsCoordinateReferenceSystem
#     """
#     if crs is None or crs.authid() == 'EPSG:4326':
#         epsg = 32600
#         if latitude < 0.0:
#             epsg += 100
#         epsg += get_utm_zone(longitude)
#         return epsg
#     else:
#         epsg_4326 = QgsCoordinateReferenceSystem('EPSG:4326')
#         transform = QgsCoordinateTransform(
#             crs, epsg_4326, QgsProject.instance())
#         geom = QgsGeometry.fromPointXY(QgsPointXY(longitude, latitude))
#         geom.transform(transform)
#         point = geom.asPoint()
#         # The point is now in 4326, we can call the function again.
#         return get_utm_epsg(point.x(), point.y())
# 
# Path: safe/definitions/layer_purposes.py



# Path: safe/gis/vector/multi_buffering.py
from qgis.core import (
    QgsCoordinateReferenceSystem,
    QgsCoordinateTransform,
    QgsProject,
    QgsGeometry,
    QgsFeature,
    QgsWkbTypes,
)
from safe.common.utilities import get_utm_epsg
from safe.definitions.fields import hazard_class_field, buffer_distance_field
from safe.definitions.layer_purposes import layer_purpose_hazard
from safe.definitions.processing_steps import buffer_steps
from safe.gis.sanity_check import check_layer
from safe.gis.vector.tools import (
    create_memory_layer,
    create_field_from_definition)
from safe.utilities.profiling import profile

        should accept params 'current' (int), 'maximum' (int) and 'step' (str).
        Defaults to None.
    :type callback: function

    :return: The buffered vector layer.
    :rtype: QgsVectorLayer
    """
    # Layer output
    output_layer_name = buffer_steps['output_layer_name']
    processing_step = buffer_steps['step_name']

    input_crs = layer.crs()
    feature_count = layer.featureCount()

    fields = layer.fields()
    # Set the new hazard class field.
    new_field = create_field_from_definition(hazard_class_field)
    fields.append(new_field)
    # Set the new buffer distances field.
    new_field = create_field_from_definition(buffer_distance_field)
    fields.append(new_field)

    buffered = create_memory_layer(
        output_layer_name, QgsWkbTypes.PolygonGeometry, input_crs, fields)
    buffered.startEditing()

    # Reproject features if needed into UTM if the layer is in 4326.
    if layer.crs().authid() == 'EPSG:4326':
        center = layer.extent().center()
        utm = QgsCoordinateReferenceSystem(

            get_utm_epsg(center.x(), center.y(), input_crs))