def icon_per_geometry_type(geometry_type: str):
    """Return the icon for a geometry type.

    If not found, it will return the default icon.

    :param geometry_type: The geometry as a string.
    :type geometry_type: basestring

    :return: The icon.
    :rtype: QIcon
    """
    geometry_type = geometry_type.lower()
    if geometry_type == "raster":
        return QgsLayerItem.iconRaster()
    elif geometry_type == "mesh":
        return QgsLayerItem.iconMesh()
    elif geometry_type == "point":
        return QgsLayerItem.iconPoint()
    elif geometry_type == "line":
        return QgsLayerItem.iconLine()
    elif geometry_type == "polygon":
        return QgsLayerItem.iconPolygon()
    elif geometry_type == "no geometry":
        return QgsLayerItem.iconTable()
    else:
        return QgsLayerItem.iconDefault()
示例#2
0
def icon_for_geometry_type(geometry_type: str) -> QIcon():
    """ Return the correct icon according to the geometry type. """
    if geometry_type == NULL:
        return QgsLayerItem.iconTable()

    elif geometry_type == 'POINT':
        return QgsLayerItem.iconPoint()

    elif geometry_type == 'LINESTRING':
        return QgsLayerItem.iconLine()

    elif geometry_type == 'MULTIPOLYGON':
        return QgsLayerItem.iconPolygon()

    # Default icon
    return QIcon(resources_path('icons', 'icon.png'))