def setUpClass(cls): TestQgsPalLabeling.setUpClass() cls.setUpServerProjectAndDir(TESTPROJPATH, TESTPROJDIR) cls.layer = TestQgsPalLabeling.loadFeatureLayer('background') cls.layer = TestQgsPalLabeling.loadFeatureLayer('point') cls.checkmismatch = 1000 cls.checkgroup = ''
def test_multipolygon_obstacle(self): # Test that all parts of multipolygon are used as an obstacle self.layer = TestQgsPalLabeling.loadFeatureLayer('point') polyLayer = TestQgsPalLabeling.loadFeatureLayer('multi_polygon') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest() self.removeMapLayer(self.layer) self.removeMapLayer(polyLayer) self.layer = None
def test_polygon_placement_with_hole_and_point(self): # Testing that hole from a feature is not treated as an obstacle for other feature's labels self.layer = TestQgsPalLabeling.loadFeatureLayer('point') polyLayer = TestQgsPalLabeling.loadFeatureLayer('polygon_with_hole') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest() self.removeMapLayer(self.layer) self.removeMapLayer(polyLayer) self.layer = None
def test_point_placement_narrow_polygon_obstacle(self): # Default point label placement with narrow polygon obstacle self.layer = TestQgsPalLabeling.loadFeatureLayer('point') polyLayer = TestQgsPalLabeling.loadFeatureLayer('narrow_polygon') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest() self.removeMapLayer(self.layer) self.removeMapLayer(polyLayer) self.layer = None
def test_point_ordered_placement4(self): # Test ordered placements for point (3 obstacle) self.layer = TestQgsPalLabeling.loadFeatureLayer('point_ordered_placement') obstacleLayer = TestQgsPalLabeling.loadFeatureLayer('point_ordered_obstacle3') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.OrderedPositionsAroundPoint self.lyr.dist = 2 self.checkTest() self.removeMapLayer(obstacleLayer) self.removeMapLayer(self.layer) self.layer = None
def test_point_dd_ordered_placement1(self): # Test ordered placements for point with data defined order and obstacle self.layer = TestQgsPalLabeling.loadFeatureLayer("point_ordered_placement") obstacleLayer = TestQgsPalLabeling.loadFeatureLayer("point_ordered_obstacle_top") self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.OrderedPositionsAroundPoint self.lyr.dist = 2 self.lyr.setDataDefinedProperty(QgsPalLayerSettings.PredefinedPositionOrder, True, True, "'T,B'", None) self.checkTest() self.removeMapLayer(obstacleLayer) self.removeMapLayer(self.layer) self.lyr.removeDataDefinedProperty(QgsPalLayerSettings.PredefinedPositionOrder) self.layer = None
def test_point_dd_ordered_placement1(self): # Test ordered placements for point with data defined order and obstacle self.layer = TestQgsPalLabeling.loadFeatureLayer('point_ordered_placement') obstacleLayer = TestQgsPalLabeling.loadFeatureLayer('point_ordered_obstacle_top') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.OrderedPositionsAroundPoint self.lyr.dist = 2 self.lyr.dataDefinedProperties().setProperty(QgsPalLayerSettings.PredefinedPositionOrder, QgsProperty.fromExpression("'T,B'")) self.checkTest() self.removeMapLayer(obstacleLayer) self.removeMapLayer(self.layer) self.lyr.dataDefinedProperties().setProperty(QgsPalLayerSettings.PredefinedPositionOrder, QgsProperty()) self.layer = None
def test_point_placement_around_obstacle_large_symbol(self): # Default point label placement with obstacle and large symbols self.layer = TestQgsPalLabeling.loadFeatureLayer('point3') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_point_placement_around(self): # Default point label placement self.layer = TestQgsPalLabeling.loadFeatureLayer('point') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_point_placement_around_obstacle(self): # Default point label placement with obstacle self.layer = TestQgsPalLabeling.loadFeatureLayer("point2") self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_small_polygon_placement_perimeter(self): # Default polygon perimeter placement for small polygon self.layer = TestQgsPalLabeling.loadFeatureLayer('polygon_small') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_prefer_more_horizontal_lines(self): # Test that labeling a line using parallel labels will tend to place the labels over more horizontal sections self.layer = TestQgsPalLabeling.loadFeatureLayer('line_placement_2') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_label_line_over_small_angles(self): # Test that labeling a line using parallel labels will place labels near center of straightish line self.layer = TestQgsPalLabeling.loadFeatureLayer('line_placement_3') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_label_line_toward_center(self): # Test that labeling a line using parallel labels will try to place labels as close to center of line as possible self.layer = TestQgsPalLabeling.loadFeatureLayer('line_placement_4') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_label_line_avoid_jaggy(self): # Test that labeling a line using parallel labels won't place labels over jaggy bits of line self.layer = TestQgsPalLabeling.loadFeatureLayer('line_placement_5') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_polygon_placement_perimeter(self): # Default polygon perimeter placement self.layer = TestQgsPalLabeling.loadFeatureLayer("polygon_perimeter") self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.lyr.placementFlags = QgsPalLayerSettings.AboveLine self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_prefer_longer_lines_over_shorter(self): # Test that labeling a line using parallel labels will tend to place the labels over the longer straight parts of # the line self.layer = TestQgsPalLabeling.loadFeatureLayer('line_placement_1') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_small_polygon_over_point_only_fit(self): # Polygon over point placement for small polygon when set to only show labels which fit in polygon self.layer = TestQgsPalLabeling.loadFeatureLayer('polygon_small') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.OverPoint self.lyr.fitInPolygonOnly = True self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_small_polygon_curvedperimeter_only_fit(self): # Polygon perimeter placement for small polygon when set to only show labels which fit in polygon self.layer = TestQgsPalLabeling.loadFeatureLayer("polygon_small") self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.PerimeterCurved self.lyr.fitInPolygonOnly = True self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def setUpClass(cls): if not cls._BaseSetup: TestQgsPalLabeling.setUpClass() MAPSERV.startup() MAPSERV.web_dir_install(glob.glob(cls._PalDataDir + os.sep + '*.qml')) # noinspection PyArgumentList cls._TestProj = QgsProject.instance() cls._TestProjName = 'pal_test.qgs' cls._TestProj.setFileName( os.path.join(MAPSERV.web_dir(), cls._TestProjName)) # the blue background (set via layer style) to match renderchecker's TestQgsPalLabeling.loadFeatureLayer('background', True) settings = QSettings() # noinspection PyArgumentList cls._CacheDir = settings.value( "cache/directory", QgsApplication.qgisSettingsDirPath() + "cache")
def test_prefer_line_curved_above_instead_of_online(self): # Test that labeling a line using curved labels when both above and online placement are allowed that above # is preferred self.layer = TestQgsPalLabeling.loadFeatureLayer('line') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Curved self.lyr.placementFlags = QgsPalLayerSettings.AboveLine | QgsPalLayerSettings.OnLine | QgsPalLayerSettings.MapOrientation self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_prefer_line_below_instead_of_online(self): # Test that labeling a line using parallel labels when both below and online placement are allowed that below # is preferred self.layer = TestQgsPalLabeling.loadFeatureLayer('line') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.lyr.placementFlags = QgsPalLayerSettings.BelowLine | QgsPalLayerSettings.OnLine | QgsPalLayerSettings.MapOrientation self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_polygon_multiple_labels(self): # Horizontal label placement for polygon with hole # Note for this test, the mask is used to check only pixels outside of the polygon. # We don't care where in the polygon the label is, just that it # is INSIDE the polygon self.layer = TestQgsPalLabeling.loadFeatureLayer('polygon_rule_based') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.checkTest(apply_simple_labeling=False) self.removeMapLayer(self.layer) self.layer = None
def test_label_curved_zero_width_char(self): # Test that curved label work with zero-width characters self.layer = TestQgsPalLabeling.loadFeatureLayer('line') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Curved self.lyr.placementFlags = QgsPalLayerSettings.OnLine self.lyr.fieldName = "'invisible​space'" self.lyr.isExpression = True self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_polygon_placement_with_hole(self): # Horizontal label placement for polygon with hole # Note for this test, the mask is used to check only pixels outside of the polygon. # We don't care where in the polygon the label is, just that it # is INSIDE the polygon self.layer = TestQgsPalLabeling.loadFeatureLayer('polygon_with_hole') self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Horizontal self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def test_prefer_line_above_instead_of_below(self): # Test that labeling a line using parallel labels when both above and below placement are allowed that above # is preferred self.layer = TestQgsPalLabeling.loadFeatureLayer("line") self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.Line self.lyr.placementFlags = ( QgsPalLayerSettings.AboveLine | QgsPalLayerSettings.BelowLine | QgsPalLayerSettings.MapOrientation ) self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def setUpClass(cls): TestQgsPalLabeling.setUpClass() MAPSERV.startup() MAPSERV.web_dir_install(os.listdir(cls._PalDataDir), cls._PalDataDir) cls._TestProj = QgsProject.instance() cls._TestProjName = 'pal_test.qgs' cls._TestProj.setFileName( os.path.join(MAPSERV.web_dir(), cls._TestProjName)) # the blue background (set via layer style) to match renderchecker's cls._BkgrdLayer = TestQgsPalLabeling.loadFeatureLayer('background') cls._CheckMismatch = 200 # default for server tests; mismatch expected cls._CheckGroup = '' # default '' will check against server control
def test_point_ordered_symbol_bound_offset(self): # Test ordered placements for point using symbol bounds offset self.layer = TestQgsPalLabeling.loadFeatureLayer('point_ordered_placement') # Make a big symbol symbol = QgsMarkerSymbol.createSimple({'color': '31,120,180,255', 'outline_color': '0,0,0,0', 'outline_style': 'solid', 'size': '10', 'name': 'rectangle', 'size_unit': 'MM'}) renderer = QgsSingleSymbolRenderer(symbol) self.layer.setRenderer(renderer) self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.OrderedPositionsAroundPoint self.lyr.dist = 2 self.lyr.offsetType = QgsPalLayerSettings.FromSymbolBounds self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def setUpClass(cls): TestQgsPalLabeling.setUpClass() MAPSERV.startup() MAPSERV.web_dir_install(glob.glob(cls._PalDataDir + os.sep + '*.qml')) # noinspection PyArgumentList cls._TestProj = QgsProject.instance() cls._TestProjName = 'pal_test.qgs' cls._TestProj.setFileName( os.path.join(MAPSERV.web_dir(), cls._TestProjName)) # the blue background (set via layer style) to match renderchecker's cls._BkgrdLayer = TestQgsPalLabeling.loadFeatureLayer('background') cls._CheckMismatch = 200 # default for server tests; mismatch expected cls._CheckGroup = '' # default '' will check against server control settings = QSettings() # noinspection PyArgumentList cls._CacheDir = settings.value( "cache/directory", QgsApplication.qgisSettingsDirPath() + "cache")
def test_point_ordered_symbol_bound_offset(self): # Test ordered placements for point using symbol bounds offset self.layer = TestQgsPalLabeling.loadFeatureLayer("point_ordered_placement") # Make a big symbol symbol = QgsMarkerSymbol.createSimple( { "color": "31,120,180,255", "outline_color": "0,0,0,0", "outline_style": "solid", "size": "10", "name": "rectangle", "size_unit": "MM", } ) renderer = QgsSingleSymbolRenderer(symbol) self.layer.setRenderer(renderer) self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self.lyr.placement = QgsPalLayerSettings.OrderedPositionsAroundPoint self.lyr.dist = 2 self.lyr.offsetType = QgsPalLayerSettings.FromSymbolBounds self.checkTest() self.removeMapLayer(self.layer) self.layer = None
def setUpClass(cls): if not cls._BaseSetup: TestQgsPalLabeling.setUpClass() # the blue background (set via layer style) to match renderchecker's TestQgsPalLabeling.loadFeatureLayer('background', True) cls._TestKind = 0 # OutputKind.(Img|Svg|Pdf)
def setUpClass(cls): TestServerBase.setUpClass() cls.layer = TestQgsPalLabeling.loadFeatureLayer('point')
def setUpClass(cls): TestCanvasBase.setUpClass() cls.layer = TestQgsPalLabeling.loadFeatureLayer('line')