Skip to content

Commit

Permalink
Add more labeling tests covering different label/obstacle combinations
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 27, 2019
1 parent 175a075 commit a997ab8
Show file tree
Hide file tree
Showing 25 changed files with 971 additions and 0 deletions.
444 changes: 444 additions & 0 deletions tests/src/python/test_qgspallabeling_placement.py

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line_short.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line_short",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "text": "Line" }, "geometry": { "type": "LineString", "coordinates": [ [ 608958.730627775425091, 4824876.642987097613513 ], [ 610159.681509669870138, 4824876.642987097613513 ] ] } }
]
}
262 changes: 262 additions & 0 deletions tests/testdata/labeling/line_short.qml
@@ -0,0 +1,262 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis simplifyMaxScale="1" readOnly="0" hasScaleBasedVisibilityFlag="0" maxScale="-4.65661e-10" simplifyDrawingTol="1" minScale="1e+08" simplifyLocal="1" labelsEnabled="0" version="3.11.0-Master" simplifyDrawingHints="1" styleCategories="AllStyleCategories" simplifyAlgorithm="0">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
</flags>
<renderer-v2 symbollevels="0" forceraster="0" type="singleSymbol" enableorderby="0">
<symbols>
<symbol name="0" clip_to_extent="1" type="line" alpha="1" force_rhr="0">
<layer pass="0" class="SimpleLine" enabled="1" locked="0">
<prop v="square" k="capstyle"/>
<prop v="5;2" k="customdash"/>
<prop v="3x:0,0,0,0,0,0" k="customdash_map_unit_scale"/>
<prop v="MM" k="customdash_unit"/>
<prop v="0" k="draw_inside_polygon"/>
<prop v="bevel" k="joinstyle"/>
<prop v="227,26,28,255" k="line_color"/>
<prop v="solid" k="line_style"/>
<prop v="0.5" k="line_width"/>
<prop v="MM" k="line_width_unit"/>
<prop v="0" k="offset"/>
<prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/>
<prop v="MM" k="offset_unit"/>
<prop v="0" k="ring_filter"/>
<prop v="0" k="use_custom_dash"/>
<prop v="3x:0,0,0,0,0,0" k="width_map_unit_scale"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</symbols>
<rotation/>
<sizescale/>
</renderer-v2>
<labeling type="simple">
<settings calloutType="simple">
<text-style fontUnderline="0" fontLetterSpacing="0" fieldName="text" multilineHeight="1" textColor="0,0,0,255" textOrientation="horizontal" useSubstitutions="0" blendMode="0" fontKerning="1" textOpacity="1" fontFamily="Cantarell" isExpression="0" fontItalic="0" fontWordSpacing="0" fontSizeUnit="Point" fontSizeMapUnitScale="3x:0,0,0,0,0,0" namedStyle="Regular" fontStrikeout="0" fontWeight="50" fontCapitals="0" previewBkgrdColor="255,255,255,255" fontSize="32">
<text-buffer bufferBlendMode="0" bufferSize="1" bufferNoFill="1" bufferOpacity="1" bufferSizeMapUnitScale="3x:0,0,0,0,0,0" bufferDraw="0" bufferJoinStyle="128" bufferColor="255,255,255,255" bufferSizeUnits="MM"/>
<text-mask maskEnabled="0" maskOpacity="1" maskSize="1.5" maskType="0" maskSizeUnits="MM" maskedSymbolLayers="" maskJoinStyle="128" maskSizeMapUnitScale="3x:0,0,0,0,0,0"/>
<background shapeOffsetY="0" shapeOffsetUnit="MM" shapeSizeType="0" shapeType="0" shapeSizeUnit="MM" shapeRadiiY="0" shapeRotation="0" shapeRotationType="0" shapeFillColor="255,255,255,255" shapeSizeMapUnitScale="3x:0,0,0,0,0,0" shapeRadiiUnit="MM" shapeSizeY="0" shapeRadiiX="0" shapeBorderWidthMapUnitScale="3x:0,0,0,0,0,0" shapeBlendMode="0" shapeSizeX="0" shapeOffsetMapUnitScale="3x:0,0,0,0,0,0" shapeBorderWidthUnit="MM" shapeOffsetX="0" shapeBorderColor="128,128,128,255" shapeSVGFile="" shapeJoinStyle="64" shapeRadiiMapUnitScale="3x:0,0,0,0,0,0" shapeDraw="0" shapeBorderWidth="0" shapeOpacity="1">
<symbol name="markerSymbol" clip_to_extent="1" type="marker" alpha="1" force_rhr="0">
<layer pass="0" class="SimpleMarker" enabled="1" locked="0">
<prop v="0" k="angle"/>
<prop v="243,166,178,255" k="color"/>
<prop v="1" k="horizontal_anchor_point"/>
<prop v="bevel" k="joinstyle"/>
<prop v="circle" k="name"/>
<prop v="0,0" k="offset"/>
<prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/>
<prop v="MM" k="offset_unit"/>
<prop v="35,35,35,255" k="outline_color"/>
<prop v="solid" k="outline_style"/>
<prop v="0" k="outline_width"/>
<prop v="3x:0,0,0,0,0,0" k="outline_width_map_unit_scale"/>
<prop v="MM" k="outline_width_unit"/>
<prop v="diameter" k="scale_method"/>
<prop v="2" k="size"/>
<prop v="3x:0,0,0,0,0,0" k="size_map_unit_scale"/>
<prop v="MM" k="size_unit"/>
<prop v="1" k="vertical_anchor_point"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</background>
<shadow shadowRadiusUnit="MM" shadowDraw="0" shadowOffsetDist="1" shadowRadiusMapUnitScale="3x:0,0,0,0,0,0" shadowRadius="1.5" shadowColor="0,0,0,255" shadowRadiusAlphaOnly="0" shadowOffsetUnit="MM" shadowUnder="0" shadowOffsetGlobal="1" shadowScale="100" shadowBlendMode="6" shadowOffsetAngle="135" shadowOpacity="0.7" shadowOffsetMapUnitScale="3x:0,0,0,0,0,0"/>
<dd_properties>
<Option type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
</dd_properties>
<substitutions/>
</text-style>
<text-format leftDirectionSymbol="&lt;" formatNumbers="0" plussign="0" placeDirectionSymbol="0" multilineAlign="0" useMaxLineLengthForAutoWrap="1" rightDirectionSymbol=">" wrapChar="" autoWrapLength="0" decimals="3" reverseDirectionSymbol="0" addDirectionSymbol="0"/>
<placement overrunDistance="0" priority="5" dist="0" fitInPolygonOnly="0" distMapUnitScale="3x:0,0,0,0,0,0" yOffset="0" xOffset="0" offsetUnits="MM" preserveRotation="1" quadOffset="4" geometryGeneratorEnabled="0" maxCurvedCharAngleIn="25" geometryGeneratorType="PointGeometry" repeatDistance="0" placementFlags="10" repeatDistanceUnits="MM" predefinedPositionOrder="TR,TL,BR,BL,R,L,TSR,BSR" centroidInside="0" maxCurvedCharAngleOut="-25" repeatDistanceMapUnitScale="3x:0,0,0,0,0,0" geometryGenerator="" labelOffsetMapUnitScale="3x:0,0,0,0,0,0" rotationAngle="0" offsetType="0" centroidWhole="0" layerType="LineGeometry" overrunDistanceUnit="MM" placement="2" distUnits="MM" overrunDistanceMapUnitScale="3x:0,0,0,0,0,0"/>
<rendering obstacleType="0" obstacle="1" scaleVisibility="0" scaleMin="0" fontLimitPixelSize="0" obstacleFactor="1" zIndex="0" fontMinPixelSize="3" labelPerPart="0" maxNumLabels="2000" upsidedownLabels="0" displayAll="0" limitNumLabels="0" mergeLines="0" minFeatureSize="0" drawLabels="1" scaleMax="0" fontMaxPixelSize="10000"/>
<dd_properties>
<Option type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
</dd_properties>
<callout type="simple">
<Option type="Map">
<Option name="anchorPoint" type="QString" value="pole_of_inaccessibility"/>
<Option name="ddProperties" type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
<Option name="drawToAllParts" type="bool" value="false"/>
<Option name="enabled" type="QString" value="0"/>
<Option name="lineSymbol" type="QString" value="&lt;symbol name=&quot;symbol&quot; clip_to_extent=&quot;1&quot; type=&quot;line&quot; alpha=&quot;1&quot; force_rhr=&quot;0&quot;>&lt;layer pass=&quot;0&quot; class=&quot;SimpleLine&quot; enabled=&quot;1&quot; locked=&quot;0&quot;>&lt;prop v=&quot;square&quot; k=&quot;capstyle&quot;/>&lt;prop v=&quot;5;2&quot; k=&quot;customdash&quot;/>&lt;prop v=&quot;3x:0,0,0,0,0,0&quot; k=&quot;customdash_map_unit_scale&quot;/>&lt;prop v=&quot;MM&quot; k=&quot;customdash_unit&quot;/>&lt;prop v=&quot;0&quot; k=&quot;draw_inside_polygon&quot;/>&lt;prop v=&quot;bevel&quot; k=&quot;joinstyle&quot;/>&lt;prop v=&quot;60,60,60,255&quot; k=&quot;line_color&quot;/>&lt;prop v=&quot;solid&quot; k=&quot;line_style&quot;/>&lt;prop v=&quot;0.3&quot; k=&quot;line_width&quot;/>&lt;prop v=&quot;MM&quot; k=&quot;line_width_unit&quot;/>&lt;prop v=&quot;0&quot; k=&quot;offset&quot;/>&lt;prop v=&quot;3x:0,0,0,0,0,0&quot; k=&quot;offset_map_unit_scale&quot;/>&lt;prop v=&quot;MM&quot; k=&quot;offset_unit&quot;/>&lt;prop v=&quot;0&quot; k=&quot;ring_filter&quot;/>&lt;prop v=&quot;0&quot; k=&quot;use_custom_dash&quot;/>&lt;prop v=&quot;3x:0,0,0,0,0,0&quot; k=&quot;width_map_unit_scale&quot;/>&lt;data_defined_properties>&lt;Option type=&quot;Map&quot;>&lt;Option name=&quot;name&quot; type=&quot;QString&quot; value=&quot;&quot;/>&lt;Option name=&quot;properties&quot;/>&lt;Option name=&quot;type&quot; type=&quot;QString&quot; value=&quot;collection&quot;/>&lt;/Option>&lt;/data_defined_properties>&lt;/layer>&lt;/symbol>"/>
<Option name="minLength" type="double" value="0"/>
<Option name="minLengthMapUnitScale" type="QString" value="3x:0,0,0,0,0,0"/>
<Option name="minLengthUnit" type="QString" value="MM"/>
<Option name="offsetFromAnchor" type="double" value="0"/>
<Option name="offsetFromAnchorMapUnitScale" type="QString" value="3x:0,0,0,0,0,0"/>
<Option name="offsetFromAnchorUnit" type="QString" value="MM"/>
<Option name="offsetFromLabel" type="double" value="0"/>
<Option name="offsetFromLabelMapUnitScale" type="QString" value="3x:0,0,0,0,0,0"/>
<Option name="offsetFromLabelUnit" type="QString" value="MM"/>
</Option>
</callout>
</settings>
</labeling>
<customproperties>
<property key="embeddedWidgets/count" value="0"/>
<property key="variableNames"/>
<property key="variableValues"/>
</customproperties>
<blendMode>0</blendMode>
<featureBlendMode>0</featureBlendMode>
<layerOpacity>1</layerOpacity>
<SingleCategoryDiagramRenderer diagramType="Pie" attributeLegend="1">
<DiagramCategory sizeScale="3x:0,0,0,0,0,0" barWidth="5" opacity="1" penAlpha="255" scaleDependency="Area" minScaleDenominator="-4.65661e-10" showAxis="0" rotationOffset="270" backgroundAlpha="255" penColor="#000000" spacing="0" spacingUnitScale="3x:0,0,0,0,0,0" scaleBasedVisibility="0" sizeType="MM" height="15" width="15" penWidth="0" backgroundColor="#ffffff" enabled="0" lineSizeType="MM" diagramOrientation="Up" labelPlacementMethod="XHeight" direction="1" lineSizeScale="3x:0,0,0,0,0,0" spacingUnit="MM" maxScaleDenominator="1e+08" minimumSize="0">
<fontProperties style="" description="Ubuntu,11,-1,5,50,0,0,0,0,0"/>
<attribute label="" field="" color="#000000"/>
<axisSymbol>
<symbol name="" clip_to_extent="1" type="line" alpha="1" force_rhr="0">
<layer pass="0" class="SimpleLine" enabled="1" locked="0">
<prop v="square" k="capstyle"/>
<prop v="5;2" k="customdash"/>
<prop v="3x:0,0,0,0,0,0" k="customdash_map_unit_scale"/>
<prop v="MM" k="customdash_unit"/>
<prop v="0" k="draw_inside_polygon"/>
<prop v="bevel" k="joinstyle"/>
<prop v="35,35,35,255" k="line_color"/>
<prop v="solid" k="line_style"/>
<prop v="0.26" k="line_width"/>
<prop v="MM" k="line_width_unit"/>
<prop v="0" k="offset"/>
<prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/>
<prop v="MM" k="offset_unit"/>
<prop v="0" k="ring_filter"/>
<prop v="0" k="use_custom_dash"/>
<prop v="3x:0,0,0,0,0,0" k="width_map_unit_scale"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</axisSymbol>
</DiagramCategory>
</SingleCategoryDiagramRenderer>
<DiagramLayerSettings placement="2" dist="0" showAll="1" priority="0" zIndex="0" linePlacementFlags="2" obstacle="0">
<properties>
<Option type="Map">
<Option name="name" type="QString" value=""/>
<Option name="properties"/>
<Option name="type" type="QString" value="collection"/>
</Option>
</properties>
</DiagramLayerSettings>
<geometryOptions geometryPrecision="0" removeDuplicateNodes="0">
<activeChecks/>
<checkConfiguration/>
</geometryOptions>
<fieldConfiguration>
<field name="text">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="text_1">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
</fieldConfiguration>
<aliases>
<alias field="text" name="" index="0"/>
<alias field="text_1" name="" index="1"/>
</aliases>
<excludeAttributesWMS/>
<excludeAttributesWFS/>
<defaults>
<default field="text" expression="" applyOnUpdate="0"/>
<default field="text_1" expression="" applyOnUpdate="0"/>
</defaults>
<constraints>
<constraint notnull_strength="0" exp_strength="0" field="text" unique_strength="0" constraints="0"/>
<constraint notnull_strength="0" exp_strength="0" field="text_1" unique_strength="0" constraints="0"/>
</constraints>
<constraintExpressions>
<constraint desc="" field="text" exp=""/>
<constraint desc="" field="text_1" exp=""/>
</constraintExpressions>
<expressionfields/>
<attributeactions>
<defaultAction key="Canvas" value="{00000000-0000-0000-0000-000000000000}"/>
</attributeactions>
<attributetableconfig sortOrder="0" actionWidgetStyle="dropDown" sortExpression="">
<columns>
<column width="-1" name="text" hidden="0" type="field"/>
<column width="-1" name="text_1" hidden="0" type="field"/>
<column width="-1" hidden="1" type="actions"/>
</columns>
</attributetableconfig>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
</conditionalstyles>
<storedexpressions/>
<editform tolerant="1"></editform>
<editforminit/>
<editforminitcodesource>0</editforminitcodesource>
<editforminitfilepath></editforminitfilepath>
<editforminitcode><![CDATA[# -*- coding: utf-8 -*-
"""
QGIS forms can have a Python function that is called when the form is
opened.
Use this function to add extra logic to your forms.
Enter the name of the function in the "Python Init function"
field.
An example follows:
"""
from qgis.PyQt.QtWidgets import QWidget

def my_form_open(dialog, layer, feature):
geom = feature.geometry()
control = dialog.findChild(QWidget, "MyLineEdit")
]]></editforminitcode>
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<editable>
<field name="text" editable="1"/>
<field name="text_1" editable="1"/>
</editable>
<labelOnTop>
<field labelOnTop="0" name="text"/>
<field labelOnTop="0" name="text_1"/>
</labelOnTop>
<widgets/>
<previewExpression>"pkuid"</previewExpression>
<mapTip></mapTip>
<layerGeometryType>1</layerGeometryType>
</qgis>
8 changes: 8 additions & 0 deletions tests/testdata/labeling/polygon_center.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "polygon_center",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "text": "Label" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 608809.940253027365543, 4824812.875683634541929 ], [ 610393.494955702451989, 4824759.736264081671834 ], [ 610393.494955702451989, 4825386.781414804980159 ], [ 608788.684485206264071, 4825376.153530894778669 ], [ 608809.940253027365543, 4824812.875683634541929 ] ] ] } }
]
}

0 comments on commit a997ab8

Please sign in to comment.