def filter_geometry_by_type(geometry, geom_type):
    if geometry.type == geom_type:
        # same type is fine
        return geometry

    if geometry.type == 'Polygon' and geom_type == 'MultiPolygon':
        # multipolygon mappings also support polygons
        return geometry

    if geometry.type == 'MultiPolygon' and geom_type == 'Polygon':
        # polygon mappings should also support multipolygons
        return geometry

    if hasattr(geometry, 'geoms'):
        # GeometryCollection or MultiLineString? return list of geometries
        geoms = []
        for part in geometry.geoms:
            # only parts with same type
            if part.type == geom_type:
                geoms.append(part)

        if geoms:
            return geoms

    return None
Parse one line of the XFS info output.
dataset/ETHPy150Open omniscale/imposm/imposm/geom.py/filter_geometry_by_type--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/xfs.py/_xfs_info_get_kv