# 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
        "LineString": MultiLineString,
        "Polygon": MultiPolygon,
        "MultiPoint": MultiPoint,
        "MultiLineString": MultiLineString,
        "MultiPolygon": MultiPolygon,
    }
    if target_type not in multipart_geoms.keys():
        raise TypeError("target type is not supported: %s" % target_type)

    if geometry.geom_type == target_type:
        return geometry

    elif allow_multipart:
        target_multipart_type = multipart_geoms[target_type]
        if geometry.geom_type == "GeometryCollection":
            return target_multipart_type(
                [
                    clean_geometry_type(
                        g, target_type, allow_multipart, raise_exception=raise_exception
                    )
                    for g in geometry.geoms
                ]
            )
        elif (
            isinstance(geometry, target_multipart_type)
            or multipart_geoms[geometry.geom_type] == target_multipart_type
        ):
            return geometry

    if raise_exception:

# 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

        "LineString": MultiLineString,
        "Polygon": MultiPolygon,
        "MultiPoint": MultiPoint,
        "MultiLineString": MultiLineString,
        "MultiPolygon": MultiPolygon,
    }
    if target_type not in multipart_geoms.keys():
        raise TypeError("target type is not supported: %s" % target_type)

    if geometry.geom_type == target_type:
        return geometry

    elif allow_multipart:
        target_multipart_type = multipart_geoms[target_type]
        if geometry.geom_type == "GeometryCollection":
            return target_multipart_type(
                [
                    clean_geometry_type(
                        g, target_type, allow_multipart, raise_exception=raise_exception
                    )
                    for g in geometry.geoms
                ]
            )
        elif (
            isinstance(geometry, target_multipart_type)
            or multipart_geoms[geometry.geom_type] == target_multipart_type
        ):
            return geometry

    if raise_exception:

        raise GeometryTypeError(