Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Average line angles for marker and hashed line symbology
Previously, when marker or hash lines were rendered using interval
or center point place placement, the symbol angles were determined
by taking the exact line orientation at the position of the symbol.

This often leads to undesirable rendering effects, where little
jaggies or corners in lines which occur at the position of the
symbol cause the marker or hash line to be oriented at a very
different angle to what the eye expects to see.

With this new option, the angle is instead calculated by averaging
the line over a specified distance either side of the symbol. E.g.
averaging the line angle over 4mm means we take the points along
the line 2mm from either side of the symbol placement, and use these
instead to calculate the line angle for that symbol. This has the
effect of smoothing (or removing) any tiny local deviations from
the overall line direction, resulting in much nicer visual
orientation of marker or hash lines.

Like all symbol settings, the average angle smoothing distance
can be set using mm/pixels/map units/etc, and supports data-defined
values.

Closed rings also correctly consider wrapping around these average
angles from the start/end vertex.

(Sponsored by an anonymous corporate backer)
  • Loading branch information
nyalldawson committed Apr 5, 2019
1 parent 4d7f0c2 commit 426382c
Show file tree
Hide file tree
Showing 25 changed files with 1,169 additions and 164 deletions.
76 changes: 76 additions & 0 deletions python/core/auto_generated/symbology/qgslinesymbollayer.sip.in
Expand Up @@ -425,6 +425,82 @@ Returns the map unit scale used for calculating the offset in map units along li
Sets the map unit ``scale`` used for calculating the offset in map units along line for symbols.

.. seealso:: :py:func:`offsetAlongLineMapUnitScale`
%End

double averageAngleLength() const;
%Docstring
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()

.. seealso:: :py:func:`setAverageAngleLength`

.. seealso:: :py:func:`averageAngleUnit`

.. seealso:: :py:func:`averageAngleMapUnitScale`
%End

void setAverageAngleLength( double length );
%Docstring
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()

.. seealso:: :py:func:`averageAngleLength`

.. seealso:: :py:func:`setAverageAngleUnit`

.. seealso:: :py:func:`setAverageAngleMapUnitScale`
%End

void setAverageAngleUnit( QgsUnitTypes::RenderUnit unit );
%Docstring
Sets the ``unit`` for the length over which the line's direction is averaged when
calculating individual symbol angles.

.. seealso:: :py:func:`averageAngleUnit`

.. seealso:: :py:func:`setAverageAngleLength`

.. seealso:: :py:func:`setAverageAngleMapUnitScale`
%End

QgsUnitTypes::RenderUnit averageAngleUnit() const;
%Docstring
Returns the unit for the length over which the line's direction is averaged when
calculating individual symbol angles.

.. seealso:: :py:func:`setAverageAngleUnit`

.. seealso:: :py:func:`averageAngleLength`

.. seealso:: :py:func:`averageAngleMapUnitScale`
%End

void setAverageAngleMapUnitScale( const QgsMapUnitScale &scale );
%Docstring
Sets the map unit ``scale`` for the length over which the line's direction is averaged when
calculating individual symbol angles.

.. seealso:: :py:func:`averageAngleMapUnitScale`

.. seealso:: :py:func:`setAverageAngleLength`

.. seealso:: :py:func:`setAverageAngleUnit`
%End

const QgsMapUnitScale &averageAngleMapUnitScale() const;
%Docstring
Returns the map unit scale for the length over which the line's direction is averaged when
calculating individual symbol angles.

.. seealso:: :py:func:`setAverageAngleMapUnitScale`

.. seealso:: :py:func:`averageAngleLength`

.. seealso:: :py:func:`averageAngleUnit`
%End

virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) ${SIP_FINAL};
Expand Down
1 change: 1 addition & 0 deletions python/core/auto_generated/symbology/qgssymbollayer.sip.in
Expand Up @@ -123,6 +123,7 @@ class QgsSymbolLayer
PropertyPlacement,
PropertyInterval,
PropertyOffsetAlongLine,
PropertyAverageAngleLength,
PropertyHorizontalAnchor,
PropertyVerticalAnchor,
PropertyLayerEnabled,
Expand Down

0 comments on commit 426382c

Please sign in to comment.