Class: QgsTemplatedLineSymbolLayerBase

Base class for templated line symbols, e.g. line symbols which draw markers or hash lines at intervals along the line feature.

Added in version 3.8.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: QgsSymbolLayer.clone(), QgsSymbolLayer.layerType(), renderSymbol(), setSymbolAngle(), setSymbolLineAngle(), QgsSymbolLayer.startRender(), QgsSymbolLayer.stopRender(), symbolAngle()

Class Hierarchy

Inheritance diagram of qgis.core.QgsTemplatedLineSymbolLayerBase

Base classes

QgsLineSymbolLayer

Abstract base class for line symbol layers.

QgsSymbolLayer

Abstract base class for symbol layers.

Subclasses

QgsHashedLineSymbolLayer

Line symbol layer type which draws repeating line sections along a line feature.

QgsMarkerLineSymbolLayer

Line symbol layer type which draws repeating marker symbols along a line feature.

Enums

Placement

alias of MarkerLinePlacement

Abstract Methods

renderSymbol

Renders the templated symbol at the specified point, using the given render context.

setSymbolAngle

Sets the symbol's angle, in degrees clockwise.

setSymbolLineAngle

Sets the line angle modification for the symbol's angle.

symbolAngle

Returns the symbol's current angle, in degrees clockwise.

Methods

averageAngleLength

Returns the length of line over which the line's direction is averaged when calculating individual symbol angles.

averageAngleMapUnitScale

Returns the map unit scale for the length over which the line's direction is averaged when calculating individual symbol angles.

averageAngleUnit

Returns the unit for the length over which the line's direction is averaged when calculating individual symbol angles.

copyTemplateSymbolProperties

Copies all common properties of this layer to another templated symbol layer.

interval

Returns the interval between individual symbols.

intervalMapUnitScale

Returns the map unit scale for the interval between symbols.

intervalUnit

Returns the units for the interval between symbols.

offsetAlongLine

Returns the offset along the line for the symbol placement.

offsetAlongLineMapUnitScale

Returns the map unit scale used for calculating the offset in map units along line for symbols.

offsetAlongLineUnit

Returns the unit used for calculating the offset along line for symbols.

placeOnEveryPart

Returns True if the placement applies for every part of multi-part feature geometries.

placement

Returns the placement of the symbols.

placements

Returns the placement of the symbols.

rotateSymbols

Returns True if the repeating symbols be rotated to match their line segment orientation.

setAverageAngleLength

Sets the length of line over which the line's direction is averaged when calculating individual symbol angles.

setAverageAngleMapUnitScale

Sets the map unit scale for the length over which the line's direction is averaged when calculating individual symbol angles.

setAverageAngleUnit

Sets the unit for the length over which the line's direction is averaged when calculating individual symbol angles.

setInterval

Sets the interval between individual symbols.

setIntervalMapUnitScale

Sets the map unit scale for the interval between symbols.

setIntervalUnit

Sets the units for the interval between symbols.

setOffsetAlongLine

Sets the the offset along the line for the symbol placement.

setOffsetAlongLineMapUnitScale

Sets the map unit scale used for calculating the offset in map units along line for symbols.

setOffsetAlongLineUnit

Sets the unit used for calculating the offset along line for symbols.

setPlaceOnEveryPart

Sets whether the placement applies for every part of multi-part feature geometries.

setPlacement

Sets the placement of the symbols.

setPlacements

Sets the placement of the symbols.

setRotateSymbols

Sets whether the repeating symbols should be rotated to match their line segment orientation.

Static Methods

setCommonProperties

Sets all common symbol properties in the destLayer, using the settings serialized in the properties map.

class qgis.core.QgsTemplatedLineSymbolLayerBase[source]

Bases: QgsLineSymbolLayer

__init__(rotateSymbol: bool = True, interval: float = 3)

Constructor for QgsTemplatedLineSymbolLayerBase. Creates a template line placed at the specified interval (in millimeters).

The rotateSymbol argument specifies whether individual symbols should be rotated to match the line segment alignment.

Parameters:
  • rotateSymbol (bool = True)

  • interval (float = 3)

Placement

alias of MarkerLinePlacement

averageAngleLength(self) float[source]

Returns the length of line over which the line’s direction is averaged when calculating individual symbol angles. Longer lengths smooth out angles from jagged lines to a greater extent.

Units are retrieved through averageAngleUnit()

Return type:

float

averageAngleMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the length over which the line’s direction is averaged when calculating individual symbol angles.

Return type:

QgsMapUnitScale

averageAngleUnit(self) Qgis.RenderUnit[source]

Returns the unit for the length over which the line’s direction is averaged when calculating individual symbol angles.

Return type:

Qgis.RenderUnit

copyTemplateSymbolProperties(self, destLayer: QgsTemplatedLineSymbolLayerBase | None)[source]

Copies all common properties of this layer to another templated symbol layer.

Parameters:

destLayer (Optional[QgsTemplatedLineSymbolLayerBase])

interval(self) float[source]

Returns the interval between individual symbols. Units are specified through intervalUnits().

See also

setInterval()

See also

intervalUnit()

Return type:

float

intervalMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the interval between symbols.

See also

intervalUnit()

See also

interval()

Return type:

QgsMapUnitScale

intervalUnit(self) Qgis.RenderUnit[source]

Returns the units for the interval between symbols.

See also

interval()

Return type:

Qgis.RenderUnit

offsetAlongLine(self) float[source]

Returns the offset along the line for the symbol placement. For Interval placements, this is the distance between the start of the line and the first symbol. For FirstVertex and LastVertex placements, this is the distance between the symbol and the start of the line or the end of the line respectively. This setting has no effect for Vertex or CentralPoint placements.

Return type:

float

Returns:

The offset along the line. The unit for the offset is retrievable via offsetAlongLineUnit.

See also

placement()

offsetAlongLineMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale used for calculating the offset in map units along line for symbols.

Return type:

QgsMapUnitScale

offsetAlongLineUnit(self) Qgis.RenderUnit[source]

Returns the unit used for calculating the offset along line for symbols.

Return type:

Qgis.RenderUnit

Returns:

Offset along line unit type.

placeOnEveryPart(self) bool[source]

Returns True if the placement applies for every part of multi-part feature geometries.

The default is True, which means that Qgis.MarkerLinePlacement.FirstVertex or Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on the first/last vertex of EVERY part of a multipart feature.

If False, then Qgis.MarkerLinePlacement.FirstVertex or Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on the first/last vertex of the overall multipart geometry only.

Added in version 3.24.

Return type:

bool

placement(self) Qgis.MarkerLinePlacement[source]

Returns the placement of the symbols.

See also

setPlacement()

Deprecated since version 3.40: Use placements() instead.

Return type:

Qgis.MarkerLinePlacement

placements(self) Qgis.MarkerLinePlacements[source]

Returns the placement of the symbols.

See also

setPlacements()

Added in version 3.24.

Return type:

Qgis.MarkerLinePlacements

abstract renderSymbol(self, point: QPointF | QPoint, feature: QgsFeature | None, context: QgsRenderContext, layer: int = -1, selected: bool = False)[source]

Renders the templated symbol at the specified point, using the given render context.

The feature argument is used to pass the feature currently being rendered (when available).

If only a single symbol layer from the symbol should be rendered, it should be specified in the layer argument. A layer of -1 indicates that all symbol layers should be rendered.

If selected is True then the symbol will be drawn using the “selected feature” style and colors instead of the symbol’s normal style.

Parameters:
  • point (Union[QPointF, QPoint])

  • feature (Optional[QgsFeature])

  • context (QgsRenderContext)

  • layer (int = -1)

  • selected (bool = False)

rotateSymbols(self) bool[source]

Returns True if the repeating symbols be rotated to match their line segment orientation.

Return type:

bool

setAverageAngleLength(self, length: float)[source]

Sets the length of line over which the line’s direction is averaged when calculating individual symbol angles. Longer lengths smooth out angles from jagged lines to a greater extent.

Units are set through setAverageAngleUnit()

Parameters:

length (float)

setAverageAngleMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the length over which the line’s direction is averaged when calculating individual symbol angles.

Parameters:

scale (QgsMapUnitScale)

setAverageAngleUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the length over which the line’s direction is averaged when calculating individual symbol angles.

Parameters:

unit (Qgis.RenderUnit)

static setCommonProperties(destLayer: QgsTemplatedLineSymbolLayerBase | None, properties: Dict[str, Any])[source]

Sets all common symbol properties in the destLayer, using the settings serialized in the properties map.

Parameters:
setInterval(self, interval: float)[source]

Sets the interval between individual symbols.

Parameters:

interval (float) – interval size. Units are specified through setIntervalUnit()

See also

interval()

setIntervalMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the interval between symbols.

See also

setInterval()

Parameters:

scale (QgsMapUnitScale)

setIntervalUnit(self, unit: Qgis.RenderUnit)[source]

Sets the units for the interval between symbols.

Parameters:

unit (Qgis.RenderUnit) – interval units

See also

intervalUnit()

See also

setInterval()

setOffsetAlongLine(self, offsetAlongLine: float)[source]

Sets the the offset along the line for the symbol placement. For Interval placements, this is the distance between the start of the line and the first symbol. For FirstVertex and LastVertex placements, this is the distance between the symbol and the start of the line or the end of the line respectively. This setting has no effect for Vertex or CentralPoint placements.

Parameters:

offsetAlongLine (float) – Distance to offset markers along the line. The offset unit is set via setOffsetAlongLineUnit.

See also

setPlacement()

setOffsetAlongLineMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale used for calculating the offset in map units along line for symbols.

Parameters:

scale (QgsMapUnitScale)

setOffsetAlongLineUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit used for calculating the offset along line for symbols.

Parameters:

unit (Qgis.RenderUnit) – Offset along line unit type.

setPlaceOnEveryPart(self, respect: bool)[source]

Sets whether the placement applies for every part of multi-part feature geometries.

The default is True, which means that Qgis.MarkerLinePlacement.FirstVertex or Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on the first/last vertex of EVERY part of a multipart feature.

If False, then Qgis.MarkerLinePlacement.FirstVertex or Qgis.MarkerLinePlacement.LastVertex placements will result in a symbol on the first/last vertex of the overall multipart geometry only.

Added in version 3.24.

Parameters:

respect (bool)

setPlacement(self, placement: Qgis.MarkerLinePlacement)[source]

Sets the placement of the symbols.

See also

placement()

Deprecated since version 3.40: Use setPlacements() instead.

Parameters:

placement (Qgis.MarkerLinePlacement)

setPlacements(self, placements: Qgis.MarkerLinePlacements | Qgis.MarkerLinePlacement)[source]

Sets the placement of the symbols.

See also

placements()

Added in version 3.24.

Parameters:

placements (Union[Qgis.MarkerLinePlacements, Qgis.MarkerLinePlacement])

setRotateSymbols(self, rotate: bool)[source]

Sets whether the repeating symbols should be rotated to match their line segment orientation.

See also

rotateSymbols()

Parameters:

rotate (bool)

abstract setSymbolAngle(self, angle: float)[source]

Sets the symbol’s angle, in degrees clockwise.

Parameters:

angle (float)

abstract setSymbolLineAngle(self, angle: float)[source]

Sets the line angle modification for the symbol’s angle. This angle is added to the symbol’s rotation and data defined rotation before rendering the symbol, and is used for orienting symbols to match the line’s angle.

Parameters:

angle (float) – Angle in degrees, valid values are between 0 and 360

abstract symbolAngle(self) float[source]

Returns the symbol’s current angle, in degrees clockwise.

Return type:

float