def convert_coordinates(coords, stac=False):
    """
    Converts footprint coordinates that have been retrieved from the metadata of source SLC scenes stored in an
    :class:`~pyroSAR.drivers.ID` object OR a product extent retrieved using :func:`spatialist.vector.Vector.extent` to
    either `envelop` and `center` for usage in the XML metadata files or `bbox` and `geometry` for usage in STAC
    metadata files. The latter is returned if the optional parameter `stac` is set to True, else the former is returned.
    
    Parameters
    ----------
    coords: list[tuple(float, float)] or dict
        List of coordinate tuple pairs as retrieved from an :class:`~pyroSAR.drivers.ID` objects of source SLC scenes
        OR the product extent retrieved using :func:`spatialist.vector.Vector.extent` in the form of a dictionary with
        keys: xmin, xmax, ymin, ymax
    stac: bool, optional
        If set to True, `bbox` and `geometry` are returned for usage in STAC metadata file. If set to False (default)
        `envelop` and `center` are returned for usage in XML metadata files.
    
    Returns
    -------
    envelop: str
        Acquisition footprint coordinates for the XML element 'eop:Footprint/multiExtentOf'.
    center: str
        Acquisition center coordinates for the XML element 'eop:Footprint/centerOf'.
    
    Notes
    -------
    If `stac=True` the following results are returned instead of `envelop` and `center`:
    
    bbox: list[float]
        Acquisition bounding box for usage in STAC Items. Formatted in accordance with RFC 7946, section 5:
        https://datatracker.ietf.org/doc/html/rfc7946#section-5
    geometry: dict
        Acquisition footprint geometry for usage in STAC Items. Formatted in accordance with RFC 7946, section 3.1.:
        https://datatracker.ietf.org/doc/html/rfc7946#section-3.1
    """
    if isinstance(coords, (list, tuple)) and len(coords) == 4:
        c = coords
        x = [c[0][0], c[1][0], c[2][0], c[3][0]]
        y = [c[0][1], c[1][1], c[2][1], c[3][1]]
        xmin = min(x)
        xmax = max(x)
        ymin = min(y)
        ymax = max(y)
    elif isinstance(coords, dict) and len(coords.keys()) == 4:
        xmin = coords['xmin']
        xmax = coords['xmax']
        ymin = coords['ymin']
        ymax = coords['ymax']
        x = [xmin, xmin, xmax, xmax]
        y = [ymin, ymax, ymax, ymin]
    else:
        raise RuntimeError('Coordinates must be provided as a list of coordinate tuples OR as a dictionary with '
                           'keys xmin, xmax, ymin, ymax')
    if stac:
        bbox = [xmin, ymin, xmax, ymax]
        geometry = {'type': 'Polygon', 'coordinates': (((x[0], y[0]), (x[1], y[1]), (x[2], y[2]), (x[3], y[3]),
                                                        (x[0], y[0])),)}
        return bbox, geometry
    else:
        x_c = (xmax + xmin) / 2
        y_c = (ymax + ymin) / 2
        center = '{} {}'.format(y_c, x_c)
        envelop = '{} {} {} {} {} {} {} {} {} {}'.format(y[0], x[0], y[1], x[1], y[2], x[2], y[3], x[3], y[0], x[0])
        return center, envelop