Пример #1
0
 def tearDownClass(cls):
     """Run after all tests"""
     TestQgsPalLabeling.tearDownClass()
     cls.removeMapLayer(cls.layer)
     cls.layer = None
     # avoid crash on finish, probably related to https://bugreports.qt.io/browse/QTBUG-35760
     QThreadPool.globalInstance().waitForDone()
 def setUpClass(cls):
     TestQgsPalLabeling.setUpClass()
     cls.setUpServerProjectAndDir(TESTPROJPATH, TESTPROJDIR)
     cls.layer = TestQgsPalLabeling.loadFeatureLayer('background')
     cls.layer = TestQgsPalLabeling.loadFeatureLayer('point')
     cls.checkmismatch = 1000
     cls.checkgroup = ''
Пример #3
0
 def setUp(self):
     """Run before each test."""
     self.configTest('pal_server', 'sp')
     TestQgsPalLabeling.setDefaultEngineSettings()
     self.lyr = self.defaultSettings()
     self.params = self.defaultWmsParams('point')
     self._TestImage = ''
 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_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_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
Пример #7
0
 def tearDownClass(cls):
     """Run after all tests"""
     TestQgsPalLabeling.tearDownClass()
     # layers removed, save empty project file
     cls._TestProj.write()
     if "PAL_SERVER_TEMP" in os.environ:
         MAPSERV.stop_processes()
         MAPSERV.open_temp_dir()
     else:
         MAPSERV.shutdown()
 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
Пример #11
0
    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 setUpClass(cls):
        TestQgsPalLabeling.setUpClass()

        cls._TestProj = QgsProject.instance()
        cls._TestProj.setFileName(str(TESTPROJPATH).strip())
        if not cls._TestProjSetup:
            try:
                shutil.copy(cls._PalFeaturesDb, TESTPROJDIR)
                for qml in glob.glob(cls._PalDataDir + os.sep + '*.qml'):
                    shutil.copy(qml, TESTPROJDIR)
            except IOError, e:
                raise IOError(str(e) +
                              '\nCould not set up test server directory')
            cls._TestProjSetup = True
 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_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_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_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_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_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_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_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_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_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 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_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_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_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 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_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_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 tearDownClass(cls):
     TestQgsPalLabeling.tearDownClass()
 def tearDownClass(cls):
     """Run after all tests"""
     TestQgsPalLabeling.tearDownClass()
     cls.removeMapLayer(cls.layer)
     cls.layer = None
Пример #33
0
 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)
Пример #34
0
 def setUpClass(cls):
     if not cls._BaseSetup:
         TestQgsPalLabeling.setUpClass()
     cls._Pal.setDrawLabelRectOnly(True)
     cls._Pal.saveEngineSettings()
Пример #35
0
 def setUpClass(cls):
     if not cls._BaseSetup:
         TestQgsPalLabeling.setUpClass()
Пример #36
0
 def tearDownClass(cls):
     TestQgsPalLabeling.tearDownClass()
     cls.removeMapLayer(cls.layer)
     cls.layer = None
     # avoid crash on finish, probably related to https://bugreports.qt.io/browse/QTBUG-35760
     QThreadPool.globalInstance().waitForDone()
Пример #37
0
 def setUpClass(cls):
     TestCanvasBase.setUpClass()
     cls.layer = TestQgsPalLabeling.loadFeatureLayer('point')
Пример #38
0
 def setUpClass(cls):
     TestComposerBase.setUpClass()
     cls.layer = TestQgsPalLabeling.loadFeatureLayer('line')
Пример #39
0
 def setUp(self):
     """Run before each test."""
     self.configTest('pal_canvas', 'sp')
     TestQgsPalLabeling.setDefaultEngineSettings()
     self.lyr = self.defaultSettings()