# Path: mapchete/errors.py
# class GeometryTypeError(TypeError):
#     """Raised when geometry type does not fit."""
# 
# Path: mapchete/validate.py
# def validate_crs(crs):
#     """
#     Return crs as rasterio.crs.CRS.
# 
#     Parameters
#     ----------
#     crs : rasterio.crs.CRS, str, int or dict
# 
#     Returns
#     -------
#     rasterio.crs.CRS
# 
#     Raises
#     ------
#     TypeError if type is invalid.
#     """
#     if isinstance(crs, CRS):
#         return crs
#     elif isinstance(crs, str):
#         try:
#             return CRS().from_epsg(int(crs))
#         except Exception:
#             return CRS().from_string(crs)
#     elif isinstance(crs, int):
#         return CRS().from_epsg(crs)
#     elif isinstance(crs, dict):
#         return CRS().from_dict(crs)
#     else:
#         raise TypeError("invalid CRS given")


from fiona.transform import transform_geom
from rasterio.crs import CRS
from shapely.errors import TopologicalError
from shapely.geometry import (
    box,
    GeometryCollection,
    shape,
    mapping,
    MultiPoint,
    MultiLineString,
    MultiPolygon,
    Polygon,
    LinearRing,
    LineString,
    base,
)
from shapely.validation import explain_validity
from mapchete.errors import GeometryTypeError
from mapchete.validate import validate_crs
import logging
import pyproj
    """
    Reproject a geometry to target CRS.

    Also, clips geometry if it lies outside the destination CRS boundary.
    Supported destination CRSes for clipping: 4326 (WGS84), 3857 (Spherical
    Mercator) and 3035 (ETRS89 / ETRS-LAEA).

    Parameters
    ----------
    geometry : ``shapely.geometry``
    src_crs : ``rasterio.crs.CRS`` or EPSG code
        CRS of source data
    dst_crs : ``rasterio.crs.CRS`` or EPSG code
        target CRS
    error_on_clip : bool
        raises a ``RuntimeError`` if a geometry is outside of CRS bounds
        (default: False)
    validity_check : bool
        checks if reprojected geometry is valid and throws ``TopologicalError``
        if invalid (default: True)
    clip_to_crs_bounds : bool
        Always clip geometries to CRS bounds. (default: True)
    antimeridian_cutting : bool
        cut geometry at Antimeridian; can result in a multipart output geometry

    Returns
    -------
    geometry : ``shapely.geometry``
    """
    logger.debug("reproject geometry from %s to %s", src_crs, dst_crs)

# Path: mapchete/errors.py
# class GeometryTypeError(TypeError):
#     """Raised when geometry type does not fit."""
# 
# Path: mapchete/validate.py
# def validate_crs(crs):
#     """
#     Return crs as rasterio.crs.CRS.
# 
#     Parameters
#     ----------
#     crs : rasterio.crs.CRS, str, int or dict
# 
#     Returns
#     -------
#     rasterio.crs.CRS
# 
#     Raises
#     ------
#     TypeError if type is invalid.
#     """
#     if isinstance(crs, CRS):
#         return crs
#     elif isinstance(crs, str):
#         try:
#             return CRS().from_epsg(int(crs))
#         except Exception:
#             return CRS().from_string(crs)
#     elif isinstance(crs, int):
#         return CRS().from_epsg(crs)
#     elif isinstance(crs, dict):
#         return CRS().from_dict(crs)
#     else:
#         raise TypeError("invalid CRS given")


# Path: mapchete/io/_geometry_operations.py
from fiona.transform import transform_geom
from rasterio.crs import CRS
from shapely.errors import TopologicalError
from shapely.geometry import (
    box,
    GeometryCollection,
    shape,
    mapping,
    MultiPoint,
    MultiLineString,
    MultiPolygon,
    Polygon,
    LinearRing,
    LineString,
    base,
)
from shapely.validation import explain_validity
from mapchete.errors import GeometryTypeError
from mapchete.validate import validate_crs
import logging
import pyproj

    """
    Reproject a geometry to target CRS.

    Also, clips geometry if it lies outside the destination CRS boundary.
    Supported destination CRSes for clipping: 4326 (WGS84), 3857 (Spherical
    Mercator) and 3035 (ETRS89 / ETRS-LAEA).

    Parameters
    ----------
    geometry : ``shapely.geometry``
    src_crs : ``rasterio.crs.CRS`` or EPSG code
        CRS of source data
    dst_crs : ``rasterio.crs.CRS`` or EPSG code
        target CRS
    error_on_clip : bool
        raises a ``RuntimeError`` if a geometry is outside of CRS bounds
        (default: False)
    validity_check : bool
        checks if reprojected geometry is valid and throws ``TopologicalError``
        if invalid (default: True)
    clip_to_crs_bounds : bool
        Always clip geometries to CRS bounds. (default: True)
    antimeridian_cutting : bool
        cut geometry at Antimeridian; can result in a multipart output geometry

    Returns
    -------
    geometry : ``shapely.geometry``
    """
    logger.debug("reproject geometry from %s to %s", src_crs, dst_crs)

    src_crs = validate_crs(src_crs)