Esempio n. 1
0
 def defaultLayerSettings(self):
     lyr = QgsPalLayerSettings()
     lyr.fieldName = 'text'  # default in test data sources
     font = self.getTestFont()
     font.setPointSize(32)
     format = lyr.format()
     format.setFont(font)
     format.setNamedStyle('Roman')
     format.setSize(32)
     format.setSizeUnit(QgsUnitTypes.RenderPoints)
     format.buffer().setJoinStyle(Qt.BevelJoin)
     lyr.setFormat(format)
     return lyr
Esempio n. 2
0
class TestPointBase(object):

    def __init__(self):
        """Dummy assignments, intended to be overridden in subclasses"""
        self.lyr = QgsPalLayerSettings()
        """:type: QgsPalLayerSettings"""
        # noinspection PyArgumentList
        self._TestFont = QFont()  # will become a standard test font
        self._Canvas = None
        """:type: QgsMapCanvas"""
        # custom mismatches per group/test (should not mask any needed anomaly)
        # e.g. self._Mismatches['TestClassName'] = 300
        # check base output class's checkTest() or sublcasses for any defaults
        self._Mismatches = dict()
        # custom color tolerances per group/test: 1 - 20 (0 default, 20 max)
        # (should not mask any needed anomaly)
        # e.g. self._ColorTols['TestClassName'] = 10
        # check base output class's checkTest() or sublcasses for any defaults
        self._ColorTols = dict()

    # noinspection PyMethodMayBeStatic
    def checkTest(self, **kwargs):
        """Intended to be overridden in subclasses"""
        pass

    def test_default_label(self):
        # Default label placement, with text size in points
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_text_size_map_unit(self):
        # Label text size in map units
        format = self.lyr.format()

        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)
        self.lyr.setFormat(format)
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_text_color(self):
        self._Mismatches['TestCanvasPoint'] = 774
        self._ColorTols['TestComposerPdfPoint'] = 2
        # Label color change
        format = self.lyr.format()
        format.setColor(Qt.blue)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_background_rect(self):
        self._Mismatches['TestComposerImageVsCanvasPoint'] = 800
        self._Mismatches['TestComposerImagePoint'] = 800
        format = self.lyr.format()
        format.background().setEnabled(True)
        self.lyr.setFormat(format)
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 1
        self.checkTest()

    def test_background_rect_w_offset(self):
        # Label rectangular background
        self._Mismatches['TestComposerImageVsCanvasPoint'] = 800
        self._Mismatches['TestComposerImagePoint'] = 800
        # verify fix for issues
        #   https://issues.qgis.org/issues/9057
        #   http://gis.stackexchange.com/questions/86900

        format = self.lyr.format()
        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)

        format.background().setEnabled(True)
        format.background().setOffsetUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setOffset(QPointF(-2900.0, -450.0))

        self.lyr.setFormat(format)

        self._Mismatches['TestCanvasPoint'] = 774
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_background_svg(self):
        # Label SVG background
        format = self.lyr.format()
        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)

        format.background().setEnabled(True)
        format.background().setType(QgsTextBackgroundSettings.ShapeSVG)
        svg = os.path.join(
            svgSymbolsPath(), 'backgrounds', 'background_square.svg')
        format.background().setSvgFile(svg)
        format.background().setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setSizeType(QgsTextBackgroundSettings.SizeBuffer)
        format.background().setSize(QSizeF(100.0, 0.0))
        self.lyr.setFormat(format)

        self._Mismatches['TestComposerPdfVsComposerPoint'] = 580
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_background_svg_w_offset(self):
        # Label SVG background
        format = self.lyr.format()
        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)

        format.background().setEnabled(True)
        format.background().setType(QgsTextBackgroundSettings.ShapeSVG)
        svg = os.path.join(
            svgSymbolsPath(), 'backgrounds', 'background_square.svg')
        format.background().setSvgFile(svg)
        format.background().setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setSizeType(QgsTextBackgroundSettings.SizeBuffer)
        format.background().setSize(QSizeF(100.0, 0.0))
        format.background().setOffsetUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setOffset(QPointF(-2850.0, 500.0))

        self.lyr.setFormat(format)

        self._Mismatches['TestComposerPdfVsComposerPoint'] = 760
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_partials_labels_enabled(self):
        # Set Big font size
        format = self.lyr.format()
        font = QFont(self._TestFont)
        format.setFont(font)
        format.setSize(84)
        self.lyr.setFormat(format)
        # Enable partials labels
        engine_settings = QgsLabelingEngineSettings()
        engine_settings.setFlag(QgsLabelingEngineSettings.UsePartialCandidates, True)
        self._TestMapSettings.setLabelingEngineSettings(engine_settings)
        self._Mismatches['TestCanvasPoint'] = 779
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_partials_labels_disabled(self):
        # Set Big font size
        format = self.lyr.format()
        font = QFont(self._TestFont)
        format.setFont(font)
        format.setSize(84)
        self.lyr.setFormat(format)
        # Disable partials labels
        engine_settings = QgsLabelingEngineSettings()
        engine_settings.setFlag(QgsLabelingEngineSettings.UsePartialCandidates, False)
        self._TestMapSettings.setLabelingEngineSettings(engine_settings)
        self.checkTest()

    def test_buffer(self):
        # Label with buffer
        format = self.lyr.format()
        format.buffer().setEnabled(True)
        format.buffer().setSize(2)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_shadow(self):
        # Label with shadow
        format = self.lyr.format()
        format.shadow().setEnabled(True)
        format.shadow().setOffsetDistance(2)
        format.shadow().setOpacity(1)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_letter_spacing(self):
        # Modified letter spacing
        format = self.lyr.format()
        font = QFont(self._TestFont)
        font.setLetterSpacing(QFont.AbsoluteSpacing, 3.5)
        format.setFont(font)
        format.setSize(30)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_word_spacing(self):
        # Modified word spacing
        format = self.lyr.format()
        font = QFont(self._TestFont)
        font.setWordSpacing(20.5)
        format.setFont(font)
        format.setSize(30)
        self.lyr.setFormat(format)
        self.checkTest()
Esempio n. 3
0
    def saveToLayer(self):
        units = self.unitDesignator()
        canvasCrs = self.canvas.mapSettings().destinationCrs()
        fields = QgsFields()
        fields.append(QgsField("label", QVariant.String))
        fields.append(QgsField("value", QVariant.Double))
        fields.append(QgsField("units", QVariant.String))
        fields.append(QgsField("heading_to", QVariant.Double))
        fields.append(QgsField("heading_from", QVariant.Double))
        fields.append(QgsField("total_dist", QVariant.Double))

        layer = QgsVectorLayer("LineString?crs={}".format(canvasCrs.authid()),
                               "Measurements", "memory")
        dp = layer.dataProvider()
        dp.addAttributes(fields)
        layer.updateFields()

        num = len(self.capturedPoints)
        total = 0.0
        for i in range(1, num):
            (distance, startA,
             endA) = self.calcParameters(self.capturedPoints[i - 1],
                                         self.capturedPoints[i])
            total += distance
        total = self.unitDistance(total)
        for i in range(1, num):
            (distance, startA,
             endA) = self.calcParameters(self.capturedPoints[i - 1],
                                         self.capturedPoints[i])
            pts = self.getLinePts(distance, self.capturedPoints[i - 1],
                                  self.capturedPoints[i])
            distance = self.unitDistance(distance)
            feat = QgsFeature(layer.fields())
            feat.setAttribute(0, "{:.2f} {}".format(distance, units))
            feat.setAttribute(1, distance)
            feat.setAttribute(2, units)
            feat.setAttribute(3, startA)
            feat.setAttribute(4, endA)
            feat.setAttribute(5, total)
            feat.setGeometry(QgsGeometry.fromPolylineXY(pts))
            dp.addFeatures([feat])

        label = QgsPalLayerSettings()
        label.fieldName = 'label'
        try:
            label.placement = QgsPalLayerSettings.Line
        except Exception:
            label.placement = QgsPalLayerSettings.AboveLine
        format = label.format()
        format.setColor(settings.measureTextColor)
        format.setNamedStyle('Bold')
        label.setFormat(format)
        labeling = QgsVectorLayerSimpleLabeling(label)
        layer.setLabeling(labeling)
        layer.setLabelsEnabled(True)
        renderer = layer.renderer()
        renderer.symbol().setColor(settings.measureLineColor)
        renderer.symbol().setWidth(0.5)

        layer.updateExtents()
        QgsProject.instance().addMapLayer(layer)
Esempio n. 4
0
class TestPointBase(object):
    def __init__(self):
        """Dummy assignments, intended to be overridden in subclasses"""
        self.lyr = QgsPalLayerSettings()
        """:type: QgsPalLayerSettings"""
        # noinspection PyArgumentList
        self._TestFont = QFont()  # will become a standard test font
        self._Canvas = None
        """:type: QgsMapCanvas"""
        # custom mismatches per group/test (should not mask any needed anomaly)
        # e.g. self._Mismatches['TestClassName'] = 300
        # check base output class's checkTest() or sublcasses for any defaults
        self._Mismatches = dict()
        # custom color tolerances per group/test: 1 - 20 (0 default, 20 max)
        # (should not mask any needed anomaly)
        # e.g. self._ColorTols['TestClassName'] = 10
        # check base output class's checkTest() or sublcasses for any defaults
        self._ColorTols = dict()

    # noinspection PyMethodMayBeStatic
    def checkTest(self, **kwargs):
        """Intended to be overridden in subclasses"""
        pass

    def test_default_label(self):
        # Default label placement, with text size in points
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_text_size_map_unit(self):
        # Label text size in map units
        format = self.lyr.format()

        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)
        self.lyr.setFormat(format)
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_text_color(self):
        self._Mismatches['TestCanvasPoint'] = 774
        self._ColorTols['TestComposerPdfPoint'] = 2
        # Label color change
        format = self.lyr.format()
        format.setColor(Qt.blue)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_background_rect(self):
        self._Mismatches['TestComposerImageVsCanvasPoint'] = 800
        self._Mismatches['TestComposerImagePoint'] = 800
        format = self.lyr.format()
        format.background().setEnabled(True)
        self.lyr.setFormat(format)
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 1
        self.checkTest()

    def test_background_rect_w_offset(self):
        # Label rectangular background
        self._Mismatches['TestComposerImageVsCanvasPoint'] = 800
        self._Mismatches['TestComposerImagePoint'] = 800
        # verify fix for issues
        #   https://issues.qgis.org/issues/9057
        #   http://gis.stackexchange.com/questions/86900

        format = self.lyr.format()
        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)

        format.background().setEnabled(True)
        format.background().setOffsetUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setOffset(QPointF(-2900.0, -450.0))

        self.lyr.setFormat(format)

        self._Mismatches['TestCanvasPoint'] = 774
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_background_svg(self):
        # Label SVG background
        format = self.lyr.format()
        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)

        format.background().setEnabled(True)
        format.background().setType(QgsTextBackgroundSettings.ShapeSVG)
        svg = os.path.join(svgSymbolsPath(), 'backgrounds',
                           'background_square.svg')
        format.background().setSvgFile(svg)
        format.background().setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setSizeType(QgsTextBackgroundSettings.SizeBuffer)
        format.background().setSize(QSizeF(100.0, 0.0))
        self.lyr.setFormat(format)

        self._Mismatches['TestComposerPdfVsComposerPoint'] = 580
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_background_svg_w_offset(self):
        # Label SVG background
        format = self.lyr.format()
        format.setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.setSize(460)
        font = QFont(self._TestFont)
        format.setFont(font)

        format.background().setEnabled(True)
        format.background().setType(QgsTextBackgroundSettings.ShapeSVG)
        svg = os.path.join(svgSymbolsPath(), 'backgrounds',
                           'background_square.svg')
        format.background().setSvgFile(svg)
        format.background().setSizeUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setSizeType(QgsTextBackgroundSettings.SizeBuffer)
        format.background().setSize(QSizeF(100.0, 0.0))
        format.background().setOffsetUnit(QgsUnitTypes.RenderMapUnits)
        format.background().setOffset(QPointF(-2850.0, 500.0))

        self.lyr.setFormat(format)

        self._Mismatches['TestComposerPdfVsComposerPoint'] = 760
        self._Mismatches['TestCanvasPoint'] = 776
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_partials_labels_enabled(self):
        # Set Big font size
        format = self.lyr.format()
        font = QFont(self._TestFont)
        format.setFont(font)
        format.setSize(84)
        self.lyr.setFormat(format)
        # Enable partials labels
        engine_settings = QgsLabelingEngineSettings()
        engine_settings.setFlag(QgsLabelingEngineSettings.UsePartialCandidates,
                                True)
        self._TestMapSettings.setLabelingEngineSettings(engine_settings)
        self._Mismatches['TestCanvasPoint'] = 779
        self._ColorTols['TestComposerPdfPoint'] = 2
        self.checkTest()

    def test_partials_labels_disabled(self):
        # Set Big font size
        format = self.lyr.format()
        font = QFont(self._TestFont)
        format.setFont(font)
        format.setSize(84)
        self.lyr.setFormat(format)
        # Disable partials labels
        engine_settings = QgsLabelingEngineSettings()
        engine_settings.setFlag(QgsLabelingEngineSettings.UsePartialCandidates,
                                False)
        self._TestMapSettings.setLabelingEngineSettings(engine_settings)
        self.checkTest()

    def test_buffer(self):
        # Label with buffer
        format = self.lyr.format()
        format.buffer().setEnabled(True)
        format.buffer().setSize(2)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_shadow(self):
        # Label with shadow
        format = self.lyr.format()
        format.shadow().setEnabled(True)
        format.shadow().setOffsetDistance(2)
        format.shadow().setOpacity(1)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_letter_spacing(self):
        # Modified letter spacing
        format = self.lyr.format()
        font = QFont(self._TestFont)
        font.setLetterSpacing(QFont.AbsoluteSpacing, 3.5)
        format.setFont(font)
        format.setSize(30)
        self.lyr.setFormat(format)
        self.checkTest()

    def test_word_spacing(self):
        # Modified word spacing
        format = self.lyr.format()
        font = QFont(self._TestFont)
        font.setWordSpacing(20.5)
        format.setFont(font)
        format.setSize(30)
        self.lyr.setFormat(format)
        self.checkTest()
    def get_style(self):
        """Get map styles. Get Fill color, label font, outline color.

        This function takes layer as input and configures style dictionary
        which is sent as HTTP request in order to adequatly represent
        map style on GIS Cloud.
        """
        LOGGER.debug('Started map_styles function')
        if ISQGIS3:
            self.scale_pixels = \
                iface.mapCanvas().mapSettings().outputDpi() / 72
        else:
            self.scale_pixels = \
                iface.mapCanvas().mapRenderer().outputDpi() / 72

        self.unit_to_px = {
            "MM": 3.78 * self.scale_pixels,
            "Point": 1.33 * self.scale_pixels,
            "Inch": 96 * self.scale_pixels,
            # these two aren't yet supported by GC rendering,
            # so defaulting them to value of 1 px
            "MapUnit": None,
            "RenderMetersInMapUnits": None
        }

        layer_fromlevel = 0
        layer_tolevel = 0

        if self.qgis_layer.hasScaleBasedVisibility():
            dpi = iface.mainWindow().physicalDpiX()
            max_scale_per_pixel = 156543.04
            inches_per_meter = 39.37
            factor = dpi * inches_per_meter * max_scale_per_pixel
            if self.qgis_layer.minimumScale() > 0:
                layer_fromlevel = int(
                    round(
                        math.log((factor / self.qgis_layer.minimumScale()), 2),
                        0))
            if self.qgis_layer.maximumScale() > 0:
                layer_tolevel = int(
                    round(
                        math.log((factor / self.qgis_layer.maximumScale()), 2),
                        0))

            if not ISQGIS3:
                # QGis2 has oposite logic with min/max scales
                # so we need to switch them
                (layer_tolevel, layer_fromlevel) = \
                    (layer_fromlevel, layer_tolevel)

        styles = []
        tmp_dir = self.gc_api.qgis_api.tmp_dir

        if ISQGIS3:
            renderer = QgsRuleBasedRenderer.convertFromRenderer(
                self.qgis_layer.renderer())
        else:
            renderer = QgsRuleBasedRendererV2.convertFromRenderer(
                self.qgis_layer.rendererV2())

        for rule in renderer.rootRule().children():
            symbol = rule.symbol()
            sym_size = 0
            if self.layer.type[0] == "point":
                for layer_sym in symbol.symbolLayers():
                    temp_style = layer_sym.properties()
                    self.convert_units_to_px(temp_style)
                    if "size" in temp_style and \
                       float(temp_style["size"]) > sym_size:
                        sym_size = float(temp_style["size"])

            is_first_sym = True

            index = symbol.symbolLayerCount()
            while index > 0:
                index = index - 1
                layer_sym = symbol.symbolLayer(index)
                temp_style = layer_sym.properties()
                self.convert_units_to_px(temp_style)

                val_label = None
                # in case of multiple symbolLayers()
                # labels should be set only once
                if is_first_sym:
                    if ISQGIS3:
                        if self.qgis_layer.labelsEnabled():
                            val_label = self.qgis_layer.labeling().settings()
                    else:
                        val_label = QgsPalLayerSettings()
                        val_label.readFromLayer(self.qgis_layer)
                style = {}
                line_style = "line_style"
                line_width = 0
                if self.layer.type[0] == "point":
                    size = int(round(sym_size)) + 2
                    md5 = hashlib.md5()
                    properties = str(temp_style) + self.dump_symbol_properties(
                        layer_sym.subSymbol())
                    md5.update(properties.encode('utf-8'))
                    symbol_file = "{}_{}.png".format(self.layer.id,
                                                     md5.hexdigest())
                    style['iconsoverlap'] = 2
                    style['url'] = {
                        "full_path": tmp_dir + '/' + symbol_file,
                        "file": symbol_file,
                        "symbol": symbol.clone(),
                        "size": QSize(size, size)
                    }

                elif self.layer.type[0] == "line":
                    LOGGER.info('entered line_type part of function')
                    LOGGER.info(temp_style)
                    try:
                        if u'line_color' in temp_style:
                            style['color'] = ','.join(
                                temp_style[u'line_color'].split(',')[0:3])
                            style['bordercolor'] = style['color']
                        if u'line_width' in temp_style:
                            style['width'] = temp_style[u'line_width']
                        else:
                            style['width'] = '1'
                        line_width = float(style['width'])
                    except Exception:
                        LOGGER.info(
                            'Failed while mapping style for line vector layer',
                            exc_info=True)
                    if ('color' or 'bordercolor') not in style:
                        style['color'] = '0,0,0'
                        style['bordercolor'] = '0,0,0'
                    LOGGER.info('Style is{}'.format(style))
                # VectorPolygonLayer styles -> dashed line
                # and offset possibilities
                elif self.layer.type[0] == "polygon":
                    line_style = "outline_style"
                    has_border = not ("outline_style" in temp_style
                                      and temp_style["outline_style"] == "no")
                    if layer_sym.layerType() == 'SimpleFill':
                        if u'outline_color' in temp_style and has_border:
                            style['bordercolor'] = \
                                ','.join(
                                    temp_style[u'outline_color']
                                    .split(',')[0:3])
                        if u'outline_width' in temp_style and has_border:
                            style['borderwidth'] = temp_style[u'outline_width']
                        if u'color' in temp_style and \
                           "style" in temp_style and \
                           temp_style["style"] == "solid":
                            style['color'] = ','.join(
                                temp_style[u'color'].split(',')[0:3])
                    elif layer_sym.layerType() == 'SimpleLine':
                        if u'line_color' in temp_style:
                            style['bordercolor'] = \
                                ','.join(
                                    temp_style[u'line_color']
                                    .split(',')[0:3])
                        if u'line_width' in temp_style:
                            style['line_width'] = temp_style[u'line_width']
                    elif u'color1' in temp_style:
                        style['color'] = ','.join(
                            temp_style[u'color1'].split(',')[0:3])
                        style['borderwidth'] = '1'
                        if has_border:
                            style['bordercolor'] = '0,0,0'
                    else:
                        style['bordercolor'] = '0,0,0'
                        if has_border:
                            style['borderwidth'] = '1'
                        style['color'] = '0,0,0'

                    if "borderwidth" in style:
                        line_width = float(style['borderwidth'])

                    if (layer_sym.layerType() != "SimpleFill" and
                            layer_sym.layerType() != "SimpleLine") or \
                            ("style" in temp_style and
                             not temp_style["style"] in ["solid", "no"]):
                        if layer_sym.layerType() != "SimpleFill":
                            temp_symbol = symbol.clone()
                            tmp_sym_layer = temp_symbol.symbolLayer(index)
                            while temp_symbol.symbolLayerCount() > 1:
                                if temp_symbol.symbolLayer(0) == tmp_sym_layer:
                                    temp_symbol.deleteSymbolLayer(1)
                                else:
                                    temp_symbol.deleteSymbolLayer(0)
                        else:
                            temp_style_hatch = temp_style.copy()
                            temp_style_hatch["outline_style"] = "no"
                            if ISQGIS3:
                                temp_symbol = QgsFillSymbol.createSimple(
                                    temp_style_hatch)
                            else:
                                temp_symbol = QgsFillSymbolV2.createSimple(
                                    temp_style_hatch)
                        properties = self.dump_symbol_properties(temp_symbol)
                        md5 = hashlib.md5()
                        md5.update(properties.encode('utf-8'))
                        symbol_file = "{}_{}.png"\
                            .format(self.layer.id, md5.hexdigest())
                        style['hatchUrl'] = {
                            "full_path": tmp_dir + '/' + symbol_file,
                            "file": symbol_file,
                            "symbol": temp_symbol,
                            "size": QSize(64, 64)
                        }

                if "use_custom_dash" in temp_style and \
                        temp_style["use_custom_dash"] == '1':
                    style['dashed'] = temp_style[u'customdash'].replace(
                        ';', ',')

                if ("dashed" not in style and line_style in temp_style
                        and not temp_style[line_style] in ["solid", "no"]):
                    process_dash_param(temp_style[line_style], line_width,
                                       style)

                if ISQGIS3:
                    if val_label is not None:
                        label_format = val_label.format()
                        style['fontsize'] = label_format.size()
                        style['labelfield'] = val_label.fieldName.lower()
                        style['fontcolor'] = \
                            rgb_int2tuple(label_format.color().rgb())
                        if label_format.buffer().enabled():
                            style['outline'] = \
                                rgb_int2tuple(
                                    label_format.buffer().color().rgb())
                        if self.qgis_layer.geometryType() == 1:
                            style['labelfield'] = ''
                            style['textfield'] = val_label.fieldName.lower()
                        if str(label_format.font().family()) in \
                           self.supported_fonts:
                            style['fontname'] = label_format.font().family()
                        else:
                            style['fontname'] = 'Arial'
                            LOGGER.info(
                                ("Choosen font is not supported, " +
                                 "so every font style has been changed " +
                                 "to {0}").format(style['fontname']))
                        self.setup_label_offset(val_label, style)
                else:
                    if val_label is not None and val_label.enabled:
                        style['fontsize'] = val_label.textFont.pointSize()
                        style['labelfield'] = val_label.fieldName.lower()
                        style['fontcolor'] = rgb_int2tuple(
                            val_label.textColor.rgb())
                        if val_label.bufferDraw:
                            style['outline'] = rgb_int2tuple(
                                val_label.bufferColor.rgb())
                        if self.qgis_layer.geometryType() == 1:
                            style['labelfield'] = ''
                            style['textfield'] = val_label.fieldName.lower()
                        if str(val_label.textFont.family()) in \
                           self.supported_fonts:
                            style['fontname'] = val_label.textFont.family()
                        else:
                            style['fontname'] = 'Arial'
                            LOGGER.info("Choosen font is not supported, so " +
                                        "every font style has been changed " +
                                        " to {0}".format(style['fontname']))
                        self.setup_label_offset(val_label, style)

                if rule.filterExpression():
                    style['expression'] = rule.filterExpression().replace(
                        '"', '')
                expression = self.qgis_layer.subsetString().replace('"', '')
                if expression and expression != '':
                    if 'expression' in style and style['expression'] != '':
                        style['expression'] = "(" + \
                                              style['expression'] + \
                                              ") AND (" + expression + ")"
                    else:
                        style['expression'] = expression
                if rule.label():
                    style['label'] = rule.label()
                style['showlabel'] = 't' \
                                     if val_label is not None and \
                                     'labelfield' in style \
                                     else 'f'
                style['visible'] = '1'

                if self.qgis_layer.hasScaleBasedVisibility():
                    factor = dpi * inches_per_meter * max_scale_per_pixel
                    if ISQGIS3 and rule.minimumScale() > 0:
                        style['fromlevel'] = \
                            int(round(
                                math.log((factor / rule.minimumScale()), 2),
                                0))
                    elif layer_fromlevel > 0:
                        style['fromlevel'] = layer_fromlevel

                    if ISQGIS3 and rule.maximumScale() > 0:
                        style['tolevel'] = \
                            int(round(
                                math.log((factor / rule.maximumScale()), 2),
                                0))
                    elif layer_tolevel > 0:
                        style['tolevel'] = layer_tolevel

                if 'borderwidth' in styles and \
                   style['borderwidth'] and \
                   float(style['borderwidth']) < 1:
                    style['borderwidth'] = '1'

                key = "hatchUrl" if "hatchUrl" in style else "url"

                if key in style:
                    asset = style[key]
                    self.layer.assets.append(asset)
                    LOGGER.info('URL for image upload: {}'.format(
                        asset["file"]))
                    style[key] = '/{}/qgis/map{}/{}'.format(
                        self.gc_api.user.user_md5, self.gc_api.map.map_id,
                        asset["file"])

                styles.append(style)

                is_first_sym = False

                # all point styles are merged into one as we export the symbol
                # so it's not required to iterrate symbolLayers()
                if self.layer.type[0] == "point":
                    break

        LOGGER.info('Styles function output {}'.format(styles))
        LOGGER.debug('Finished map_styles function')
        return styles