def is_geometry(value, epsg=None, expected_geom_type=None, expected_epsg=None):
    """Returns ``True`` if the given value and srid are valid according to the expected parameters.
    """
    from osgeo import ogr
    ogr.UseExceptions()
    if epsg is not None and not isinstance(epsg, int):
        return False
    if expected_epsg is not None and (epsg is None or epsg != expected_epsg):
        return False
    try:
        geom = ogr.CreateGeometryFromWkt(value)
        geom.IsValid()
    except RuntimeError:
        return False
    if expected_geom_type is not None and geom.GetGeometryName().upper(
        ) != expected_geom_type.upper():
        return False
    return True
