Exemplo n.º 1
0
    def testSizeMapUnitScale(self):
        # test sizeMapUnitScale and setSizeMapUnitScale

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.symbolLayer(0).setSizeMapUnitScale(QgsMapUnitScale(10000, 20000))
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(10000, 20000))
        markerSymbol.setSizeMapUnitScale(QgsMapUnitScale(1000, 2000))
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(1000, 2000))
        self.assertEqual(markerSymbol.symbolLayer(0).sizeMapUnitScale(), QgsMapUnitScale(1000, 2000))

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        # should take first layer's map unit scale
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(1000, 2000))
        markerSymbol.setSizeMapUnitScale(QgsMapUnitScale(3000, 4000))
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
        # all layers should have size unit set
        self.assertEqual(markerSymbol.symbolLayer(0).sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
        self.assertEqual(markerSymbol.symbolLayer(1).sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
        self.assertEqual(markerSymbol.symbolLayer(2).sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
Exemplo n.º 2
0
    def testAngle(self):
        # test angle and setAngle

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10, angle=90))
        self.assertEqual(markerSymbol.angle(), 90)
        markerSymbol.setAngle(100)
        self.assertEqual(markerSymbol.angle(), 100)
        self.assertEqual(markerSymbol.symbolLayer(0).angle(), 100)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10, angle=130))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10, angle=150))
        # should take first layer's angle
        self.assertEqual(markerSymbol.angle(), 100)
        markerSymbol.setAngle(10)
        self.assertEqual(markerSymbol.angle(), 10)
        # layer angles should maintain relative angle
        self.assertEqual(markerSymbol.symbolLayer(0).angle(), 10)
        self.assertEqual(markerSymbol.symbolLayer(1).angle(), 40)
        self.assertEqual(markerSymbol.symbolLayer(2).angle(), 60)
Exemplo n.º 3
0
    def testSizeUnit(self):
        # test sizeUnit and setSizeUnit

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderMillimeters)
        markerSymbol.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderMapUnits)
        self.assertEqual(markerSymbol.symbolLayer(0).sizeUnit(), QgsUnitTypes.RenderMapUnits)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        # should now be mixed size units
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderUnknownUnit)
        markerSymbol.setSizeUnit(QgsUnitTypes.RenderPixels)
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderPixels)
        # all layers should have size unit set
        self.assertEqual(markerSymbol.symbolLayer(0).sizeUnit(), QgsUnitTypes.RenderPixels)
        self.assertEqual(markerSymbol.symbolLayer(1).sizeUnit(), QgsUnitTypes.RenderPixels)
        self.assertEqual(markerSymbol.symbolLayer(2).sizeUnit(), QgsUnitTypes.RenderPixels)
Exemplo n.º 4
0
    def testSize(self):
        # test size and setSize

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star,
                                       color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0),
                                       size=10))
        self.assertEqual(markerSymbol.size(), 10)
        markerSymbol.setSize(20)
        self.assertEqual(markerSymbol.size(), 20)
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 20)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star,
                                       color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0),
                                       size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star,
                                       color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0),
                                       size=30))
        self.assertEqual(markerSymbol.size(), 30)
        markerSymbol.setSize(3)
        self.assertEqual(markerSymbol.size(), 3)
        # layer sizes should maintain relative size
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 2)
        self.assertEqual(markerSymbol.symbolLayer(1).size(), 1)
        self.assertEqual(markerSymbol.symbolLayer(2).size(), 3)
Exemplo n.º 5
0
    def testSize(self):
        # test size and setSize

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        self.assertEqual(markerSymbol.size(), 10)
        markerSymbol.setSize(20)
        self.assertEqual(markerSymbol.size(), 20)
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 20)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        self.assertEqual(markerSymbol.size(), 30)
        markerSymbol.setSize(3)
        self.assertEqual(markerSymbol.size(), 3)
        # layer sizes should maintain relative size
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 2)
        self.assertEqual(markerSymbol.symbolLayer(1).size(), 1)
        self.assertEqual(markerSymbol.symbolLayer(2).size(), 3)
Exemplo n.º 6
0
    def testSizeMapUnitScale(self):
        # test sizeMapUnitScale and setSizeMapUnitScale

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.symbolLayer(0).setSizeMapUnitScale(QgsMapUnitScale(10000, 20000))
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(10000, 20000))
        markerSymbol.setSizeMapUnitScale(QgsMapUnitScale(1000, 2000))
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(1000, 2000))
        self.assertEqual(markerSymbol.symbolLayer(0).sizeMapUnitScale(), QgsMapUnitScale(1000, 2000))

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        # should take first layer's map unit scale
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(1000, 2000))
        markerSymbol.setSizeMapUnitScale(QgsMapUnitScale(3000, 4000))
        self.assertEqual(markerSymbol.sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
        # all layers should have size unit set
        self.assertEqual(markerSymbol.symbolLayer(0).sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
        self.assertEqual(markerSymbol.symbolLayer(1).sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
        self.assertEqual(markerSymbol.symbolLayer(2).sizeMapUnitScale(), QgsMapUnitScale(3000, 4000))
Exemplo n.º 7
0
    def testSizeUnit(self):
        # test sizeUnit and setSizeUnit

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderMillimeters)
        markerSymbol.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderMapUnits)
        self.assertEqual(markerSymbol.symbolLayer(0).sizeUnit(), QgsUnitTypes.RenderMapUnits)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        # should now be mixed size units
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderUnknownUnit)
        markerSymbol.setSizeUnit(QgsUnitTypes.RenderPixels)
        self.assertEqual(markerSymbol.sizeUnit(), QgsUnitTypes.RenderPixels)
        # all layers should have size unit set
        self.assertEqual(markerSymbol.symbolLayer(0).sizeUnit(), QgsUnitTypes.RenderPixels)
        self.assertEqual(markerSymbol.symbolLayer(1).sizeUnit(), QgsUnitTypes.RenderPixels)
        self.assertEqual(markerSymbol.symbolLayer(2).sizeUnit(), QgsUnitTypes.RenderPixels)
Exemplo n.º 8
0
    def testAngle(self):
        # test angle and setAngle

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10, angle=90))
        self.assertEqual(markerSymbol.angle(), 90)
        markerSymbol.setAngle(100)
        self.assertEqual(markerSymbol.angle(), 100)
        self.assertEqual(markerSymbol.symbolLayer(0).angle(), 100)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10, angle=130))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10, angle=150))
        # should take first layer's angle
        self.assertEqual(markerSymbol.angle(), 100)
        markerSymbol.setAngle(10)
        self.assertEqual(markerSymbol.angle(), 10)
        # layer angles should maintain relative angle
        self.assertEqual(markerSymbol.symbolLayer(0).angle(), 10)
        self.assertEqual(markerSymbol.symbolLayer(1).angle(), 40)
        self.assertEqual(markerSymbol.symbolLayer(2).angle(), 60)
Exemplo n.º 9
0
    def testSize(self):
        # test size and setSize
        ms = QgsMapSettings()
        extent = QgsRectangle(100, 200, 100, 200)
        ms.setExtent(extent)
        ms.setOutputSize(QSize(400, 400))
        context = QgsRenderContext.fromMapSettings(ms)
        context.setScaleFactor(96 / 25.4)  # 96 DPI
        ms.setExtent(QgsRectangle(100, 150, 100, 150))
        ms.setOutputDpi(ms.outputDpi() * 2)
        context2 = QgsRenderContext.fromMapSettings(ms)
        context2.setScaleFactor(300 / 25.4)

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        self.assertEqual(markerSymbol.size(), 10)
        self.assertAlmostEqual(markerSymbol.size(context), 37.795275590551185, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 118.11023622047244, 3)
        markerSymbol.setSize(20)
        self.assertEqual(markerSymbol.size(), 20)
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 20)
        self.assertAlmostEqual(markerSymbol.size(context), 75.59055118, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 236.2204724409449, 3)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        self.assertEqual(markerSymbol.size(), 30)
        self.assertAlmostEqual(markerSymbol.size(context), 113.38582677165356, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 354.33070866141736, 3)

        markerSymbol.setSize(3)
        self.assertEqual(markerSymbol.size(), 3)
        # layer sizes should maintain relative size
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 2)
        self.assertEqual(markerSymbol.symbolLayer(1).size(), 1)
        self.assertEqual(markerSymbol.symbolLayer(2).size(), 3)

        # symbol layer in different size
        markerSymbol.symbolLayer(1).setSize(15)
        self.assertAlmostEqual(markerSymbol.size(context), 56.69291338582678, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 177.16535433070868, 3)
        markerSymbol.symbolLayer(1).setSizeUnit(QgsUnitTypes.RenderPixels)
        self.assertAlmostEqual(markerSymbol.size(context), 15, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 35.43307086614173, 3)
        markerSymbol.symbolLayer(1).setSize(45)
        self.assertAlmostEqual(markerSymbol.size(context), 45, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 45, 3)
Exemplo n.º 10
0
    def testSize(self):
        # test size and setSize
        ms = QgsMapSettings()
        extent = QgsRectangle(100, 200, 100, 200)
        ms.setExtent(extent)
        ms.setOutputSize(QSize(400, 400))
        context = QgsRenderContext.fromMapSettings(ms)
        context.setScaleFactor(96 / 25.4)  # 96 DPI
        ms.setExtent(QgsRectangle(100, 150, 100, 150))
        ms.setOutputDpi(ms.outputDpi() * 2)
        context2 = QgsRenderContext.fromMapSettings(ms)
        context2.setScaleFactor(300 / 25.4)

        # create a marker symbol with a single layer
        markerSymbol = QgsMarkerSymbol()
        markerSymbol.deleteSymbolLayer(0)
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        self.assertEqual(markerSymbol.size(), 10)
        self.assertAlmostEqual(markerSymbol.size(context), 37.795275590551185, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 118.11023622047244, 3)
        markerSymbol.setSize(20)
        self.assertEqual(markerSymbol.size(), 20)
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 20)
        self.assertAlmostEqual(markerSymbol.size(context), 75.59055118, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 236.2204724409449, 3)

        # add additional layers
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=10))
        markerSymbol.appendSymbolLayer(
            QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase.Star, color=QColor(255, 0, 0),
                                       strokeColor=QColor(0, 255, 0), size=30))
        self.assertEqual(markerSymbol.size(), 30)
        self.assertAlmostEqual(markerSymbol.size(context), 113.38582677165356, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 354.33070866141736, 3)

        markerSymbol.setSize(3)
        self.assertEqual(markerSymbol.size(), 3)
        # layer sizes should maintain relative size
        self.assertEqual(markerSymbol.symbolLayer(0).size(), 2)
        self.assertEqual(markerSymbol.symbolLayer(1).size(), 1)
        self.assertEqual(markerSymbol.symbolLayer(2).size(), 3)

        # symbol layer in different size
        markerSymbol.symbolLayer(1).setSize(15)
        self.assertAlmostEqual(markerSymbol.size(context), 56.69291338582678, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 177.16535433070868, 3)
        markerSymbol.symbolLayer(1).setSizeUnit(QgsUnitTypes.RenderPixels)
        self.assertAlmostEqual(markerSymbol.size(context), 15, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 35.43307086614173, 3)
        markerSymbol.symbolLayer(1).setSize(45)
        self.assertAlmostEqual(markerSymbol.size(context), 45, 3)
        self.assertAlmostEqual(markerSymbol.size(context2), 45, 3)
    def testMapRotation(self):
        # test rendering with map rotation
        s = QgsMarkerSymbol()
        s.deleteSymbolLayer(0)

        field_marker = QgsVectorFieldSymbolLayer()
        field_marker.setXAttribute('x')
        field_marker.setYAttribute('y')
        field_marker.setScale(4)

        field_marker.setSubSymbol(QgsLineSymbol.createSimple({'color': '#ff0000', 'width': '2'}))

        s.appendSymbolLayer(field_marker.clone())

        g = QgsGeometry.fromWkt('Point(5 4)')
        fields = QgsFields()
        fields.append(QgsField('x', QVariant.Double))
        fields.append(QgsField('y', QVariant.Double))
        f = QgsFeature(fields)
        f.setAttributes([2, 3])
        f.setGeometry(g)

        rendered_image = self.renderFeature(s, f, map_rotation=45)
        assert self.imageCheck('rotated_map', 'rotated_map', rendered_image)
Exemplo n.º 12
0
    def test_renderer_frame_rate(self):
        # renderer without an animated symbol
        marker_symbol = QgsMarkerSymbol.createSimple({})
        renderer = QgsSingleSymbolRenderer(marker_symbol)
        self.assertEqual(QgsSymbolLayerUtils.rendererFrameRate(renderer), -1)

        # renderer with an animated symbol
        marker_symbol = QgsMarkerSymbol()
        animated_marker = QgsAnimatedMarkerSymbolLayer()
        animated_marker.setFrameRate(30)
        marker_symbol.appendSymbolLayer(animated_marker)
        renderer = QgsSingleSymbolRenderer(marker_symbol)
        self.assertEqual(QgsSymbolLayerUtils.rendererFrameRate(renderer), 30)

        # renderer with two animated symbol layers
        marker_symbol = QgsMarkerSymbol()
        animated_marker = QgsAnimatedMarkerSymbolLayer()
        animated_marker.setFrameRate(30)
        marker_symbol.appendSymbolLayer(animated_marker)
        animated_marker = QgsAnimatedMarkerSymbolLayer()
        animated_marker.setFrameRate(60)
        marker_symbol.appendSymbolLayer(animated_marker)
        renderer = QgsSingleSymbolRenderer(marker_symbol)
        self.assertEqual(QgsSymbolLayerUtils.rendererFrameRate(renderer), 60)
    def processAlgorithm(self, parameters, context, feedback):

        t_file = self.parameterAsVectorLayer(
            parameters,
            self.FILE_TABLE,
            context
        )
        t_troncon = self.parameterAsVectorLayer(
            parameters,
            self.SEGMENTS_TABLE,
            context
        )
        t_obs = self.parameterAsVectorLayer(
            parameters,
            self.OBSERVATIONS_TABLE,
            context
        )
        t_regard = self.parameterAsVectorLayer(
            parameters,
            self.MANHOLES_TABLE,
            context
        )

        g_regard = self.parameterAsVectorLayer(
            parameters,
            self.GEOM_MANHOLES,
            context
        )
        g_troncon = self.parameterAsVectorLayer(
            parameters,
            self.GEOM_SEGMENT,
            context
        )
        g_obs = self.parameterAsVectorLayer(
            parameters,
            self.GEOM_OBSERVATION,
            context
        )

        v_regard = self.parameterAsVectorLayer(
            parameters,
            self.VIEW_MANHOLES_GEOLOCALIZED,
            context
        )

        # define variables
        variables = context.project().customVariables()
        variables['itv_rerau_t_file'] = t_file.id()
        variables['itv_rerau_t_troncon'] = t_troncon.id()
        variables['itv_rerau_t_obs'] = t_obs.id()
        variables['itv_rerau_t_regard'] = t_regard.id()

        variables['itv_rerau_g_regard'] = g_regard.id()
        variables['itv_rerau_g_troncon'] = g_troncon.id()
        variables['itv_rerau_g_obs'] = g_obs.id()

        context.project().setCustomVariables(variables)

        # define relations
        relations = [
            {
                'id': 'fk_obs_id_file',
                'name': tr('Link File - Observation'),
                'referencingLayer': t_obs.id(),
                'referencingField': 'id_file',
                'referencedLayer': t_file.id(),
                'referencedField': 'id'
            }, {
                'id': 'fk_regard_id_file',
                'name': tr('Link File - Manhole'),
                'referencingLayer': t_regard.id(),
                'referencingField': 'id_file',
                'referencedLayer': t_file.id(),
                'referencedField': 'id'
            }, {
                'id': 'fk_troncon_id_file',
                'name': tr('Link File - Pipe segment'),
                'referencingLayer': t_troncon.id(),
                'referencingField': 'id_file',
                'referencedLayer': t_file.id(),
                'referencedField': 'id'
            }, {
                'id': 'fk_obs_id_troncon',
                'name': tr('Link Pipe segment - Observation'),
                'referencingLayer': t_obs.id(),
                'referencingField': 'id_troncon',
                'referencedLayer': t_troncon.id(),
                'referencedField': 'id'
            }, {
                'id': 'fk_regard_id_geom_regard',
                'name': tr('Link Manhole inspection - Reference'),
                'referencingLayer': t_regard.id(),
                'referencingField': 'id_geom_regard',
                'referencedLayer': g_regard.id(),
                'referencedField': 'id'
            }, {
                'id': 'fk_troncon_id_geom_trononc',
                'name': tr('Link Pipe segment inspection - Reference'),
                'referencingLayer': t_troncon.id(),
                'referencingField': 'id_geom_troncon',
                'referencedLayer': g_troncon.id(),
                'referencedField': 'id'
            }
        ]

        relation_manager = context.project().relationManager()
        for rel_def in relations:
            feedback.pushInfo(
                'Link: {}'.format(rel_def['name'])
            )
            rel = QgsRelation()
            rel.setId(rel_def['id'])
            rel.setName(rel_def['name'])
            rel.setReferencingLayer(rel_def['referencingLayer'])
            rel.setReferencedLayer(rel_def['referencedLayer'])
            rel.addFieldPair(
                rel_def['referencingField'],
                rel_def['referencedField']
            )
            rel.setStrength(QgsRelation.Association)
            relation_manager.addRelation(rel)
            feedback.pushInfo(
                'Count relations {}'.format(
                    len(relation_manager.relations())
                )
            )

        joins = [
            {
                'layer': t_obs,
                'targetField': 'id_troncon',
                'joinLayer': t_troncon,
                'joinField': 'id',
                'fieldNamesSubset': ['ack']
            }, {
                'layer': g_obs,
                'targetField': 'id',
                'joinLayer': t_obs,
                'joinField': 'id',
                'fieldNamesSubset': []
            }
        ]
        for j_def in joins:
            layer = j_def['layer']

            join = QgsVectorLayerJoinInfo()
            join.setJoinFieldName(j_def['joinField'])
            join.setJoinLayerId(j_def['joinLayer'].id())
            join.setTargetFieldName(j_def['targetField'])

            if j_def['fieldNamesSubset']:
                join.setJoinFieldNamesSubset(j_def['fieldNamesSubset'])

            join.setUsingMemoryCache(False)
            join.setPrefix('')
            join.setEditable(False)
            join.setCascadedDelete(False)

            join.setJoinLayer(j_def['joinLayer'])

            layer.addJoin(join)
            layer.updateFields()

        # load styles
        styles = [
            {
                'layer': t_file,
                'namedStyles': [
                    {
                        'file': 'itv_file_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_file_actions.qml',
                        'type': QgsMapLayer.Actions
                    }
                ]
            }, {
                'layer': t_troncon,
                'namedStyles': [
                    {
                        'file': 'itv_troncon_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_troncon_table.qml',
                        'type': QgsMapLayer.AttributeTable
                    }
                ]
            }, {
                'layer': t_obs,
                'namedStyles': [
                    {
                        'file': 'itv_obs_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_obs_table.qml',
                        'type': QgsMapLayer.AttributeTable
                    }
                ]
            }, {
                'layer': t_regard,
                'namedStyles': [
                    {
                        'file': 'itv_regard_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_regard_forms.qml',
                        'type': QgsMapLayer.Forms
                    }, {
                        'file': 'itv_regard_table.qml',
                        'type': QgsMapLayer.AttributeTable
                    }
                ]
            }, {
                'layer': g_regard,
                'namedStyles': [
                    {
                        'file': 'itv_geom_regard_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_geom_regard_symbology.qml',
                        'type': QgsMapLayer.Symbology
                    }
                ]
            }, {
                'layer': g_troncon,
                'namedStyles': [
                    {
                        'file': 'itv_geom_troncon_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_geom_troncon_symbology.qml',
                        'type': QgsMapLayer.Symbology
                    }, {
                        'file': 'itv_geom_troncon_actions.qml',
                        'type': QgsMapLayer.Actions
                    }
                ]
            }, {
                'layer': g_obs,
                'namedStyles': [
                    {
                        'file': 'itv_geom_obs_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_geom_obs_symbology.qml',
                        'type': QgsMapLayer.Symbology
                    }
                ]
            }, {
                'layer': v_regard,
                'namedStyles': [
                    {
                        'file': 'itv_view_regard_fields.qml',
                        'type': QgsMapLayer.Fields
                    }, {
                        'file': 'itv_view_regard_symbology.qml',
                        'type': QgsMapLayer.Symbology
                    }, {
                        'file': 'itv_view_regard_labeling.qml',
                        'type': QgsMapLayer.Labeling
                    }
                ]
            }
        ]
        for style in styles:
            layer = style['layer']
            for n_style in style['namedStyles']:
                layer.loadNamedStyle(
                    resources_path('styles', n_style['file']),
                    categories=n_style['type']
                )
                # layer.saveStyleToDatabase('style', 'default style', True, '')
                layer.triggerRepaint()

        # Creation de la symbologie g_obs
        g_obs_rules = (
            'BAA', 'BAB', 'BAC', 'BAD', 'BAE', 'BAF', 'BAG', 'BAH',
            'BAI', 'BAJ', 'BAK', 'BAL', 'BAM', 'BAN', 'BAO', 'BAP',
            'BBA', 'BBB', 'BBC', 'BBD', 'BBE', 'BBF', 'BBG', 'BBH',
            'BCA', 'BCB', 'BCC', 'BDA', 'BDB', 'BDC', 'BDD', 'BDE',
            'BDF', 'BDG'
        )
        g_obs_rule_descs = {
            'BAA': 'Déformation',
            'BAB': 'Fissure',
            'BAC': 'Rupture/Effondrement',
            'BAD': 'Elt maçonnerie',
            'BAE': 'Mortier manquant',
            'BAF': 'Dégradation de surface',
            'BAG': 'Branchement pénétrant',
            'BAH': 'Raccordement défectueux',
            'BAI': 'Joint étanchéité apparent',
            'BAJ': 'Déplacement d\'assemblage',
            'BAK': 'Défaut de révêtement',
            'BAL': 'Réparation défectueuse',
            'BAM': 'Défaut soudure',
            'BAN': 'Conduite poreuse',
            'BAO': 'Sol visible',
            'BAP': 'Trou visible',
            'BBA': 'Racines',
            'BBB': 'Dépots Adhérents',
            'BBC': 'Dépôts',
            'BBD': 'Entrée de terre',
            'BBE': 'Autres obstacles',
            'BBF': 'Infiltration',
            'BBG': 'Exfiltration',
            'BBH': 'Vermine',
            'BCA': 'Raccordement',
            'BCB': 'Réparation',
            'BCC': 'Courbure de collecteur',
            'BDA': 'Photographie générale',
            'BDB': 'Remarque générale',
            'BDC': 'Inspection abandonnée',
            'BDD': 'Niveau d\'eau',
            'BDE': 'Ecoulement dans une canlisation entrante',
            'BDF': 'Atmosphère canalisation',
            'BDG': 'Perte de visibilité'
        }
        g_obs_rootrule = QgsRuleBasedRenderer.Rule(None)
        rendering_pass_idx = len(g_obs_rules)
        for rule in g_obs_rules:
            # get svg path
            svg_path = resources_path('styles', 'img_obs', rule + '.svg')
            # create svg symbol layer
            svg_symbol_layer = QgsSvgMarkerSymbolLayer(svg_path)
            svg_symbol_layer.setRenderingPass(rendering_pass_idx)
            # create white square symbol layer for the backend
            simple_symbol_layer = QgsSimpleMarkerSymbolLayer(
                shape=QgsSimpleMarkerSymbolLayerBase.Circle,
                size=svg_symbol_layer.size(),
                color=QColor('white'),
                strokeColor=QColor('white')
            )
            simple_symbol_layer.setRenderingPass(rendering_pass_idx)
            # create marker
            svg_marker = QgsMarkerSymbol()
            # set the backend symbol layer
            svg_marker.changeSymbolLayer(0, simple_symbol_layer)
            # add svg symbol layer
            svg_marker.appendSymbolLayer(svg_symbol_layer)
            # create rule
            svg_rule = QgsRuleBasedRenderer.Rule(
                svg_marker, 0, 10000,
                QgsExpression.createFieldEqualityExpression('a', rule),
                rule
            )
            if rule in g_obs_rule_descs:
                svg_rule.setLabel(g_obs_rule_descs[rule])
                svg_rule.setDescription('{}: {}'.format(
                    rule,
                    g_obs_rule_descs[rule]
                ))
            # add rule
            g_obs_rootrule.appendChild(svg_rule)
            rendering_pass_idx -= 1
        g_obs_rootrule.appendChild(
            QgsRuleBasedRenderer.Rule(
                QgsMarkerSymbol.createSimple(
                    {
                        'name': 'circle',
                        'color': '#0000b2',
                        'outline_color': '#0000b2',
                        'size': '1'
                    }
                ),
                0, 10000, 'ELSE', 'Autres'
            )
        )
        g_obs.setRenderer(QgsRuleBasedRenderer(g_obs_rootrule))
        feedback.pushInfo('Project has been setup')
        return {}