def _extract_layer_style(self, symbol: QgsSymbol) -> Tuple[List[int], VisConfig]: symbol_opacity: float = symbol.opacity() symbol_layer: QgsSymbolLayer = symbol.symbolLayers()[0] if symbol_layer.subSymbol() is not None: return self._extract_layer_style(symbol_layer.subSymbol()) sym_type = SymbolLayerType[symbol_layer.layerType()] properties = symbol_layer.properties() # Default values radius = VisConfig.radius color_range = ColorRange.create_default() radius_range = VisConfig.radius_range if isinstance(symbol, QgsMarkerSymbol) or isinstance( symbol, QgsFillSymbol): fill_rgb, alpha = extract_color(properties['color']) opacity = round(symbol_opacity * alpha, 2) stroke_rgb, stroke_alpha = extract_color( properties['outline_color']) stroke_opacity = round(symbol_opacity * stroke_alpha, 2) thickness = self._convert_to_pixels( float(properties['outline_width']), properties['outline_width_unit']) outline = stroke_opacity > 0.0 and properties[ 'outline_style'] != 'no' stroke_opacity = stroke_opacity if outline else None stroke_color = stroke_rgb if outline else None filled = opacity > 0.0 and properties.get('style', 'solid') != 'no' if isinstance(symbol, QgsMarkerSymbol): size_range, height_range, elevation_scale, stroked, enable3_d, wireframe = [ None ] * 6 # Fixed radius seems to always be False with point types fixed_radius = False radius = self._convert_to_pixels(float(properties['size']), properties['size_unit'], radius=True) thickness = thickness if thickness > 0.0 else 1.0 # Hairline in QGIS else: size_range = VisConfig.size_range height_range = VisConfig.height_range elevation_scale = VisConfig.elevation_scale if outline: stroked = True else: stroked = False stroke_color = None wireframe, enable3_d = [False] * 2 fixed_radius, outline = [None] * 2 elif isinstance(symbol, QgsLineSymbol): fill_rgb, stroke_alpha = extract_color(properties['line_color']) opacity = round(symbol_opacity * stroke_alpha, 2) stroke_opacity = opacity thickness = self._convert_to_pixels( float(properties['line_width']), properties['line_width_unit']) size_range = VisConfig.size_range height_range = VisConfig.height_range elevation_scale = VisConfig.elevation_scale stroked = True wireframe, enable3_d, filled = [False] * 3 stroke_color, fixed_radius, outline = [None] * 3 else: raise QgsPluginNotImplementedException(tr( 'Symbol type {} is not supported yet', symbol.type()), bar_msg=bar_msg()) thickness = thickness if thickness > 0.0 else VisConfig.thickness vis_config = VisConfig(opacity, stroke_opacity, thickness, stroke_color, color_range, color_range, radius, size_range, radius_range, height_range, elevation_scale, stroked, filled, enable3_d, wireframe, fixed_radius, outline) return fill_rgb, vis_config