コード例 #1
0
    def __getQgsLineSymbolLayer(self, msstyle):
        """docstring for __getLineSymbolLayer"""
        props = {}
        type_marker = ''

        symbol = msstyle.get('symbol', False)
        if symbol:
            (type_marker, symbolname, msSymbol,
             props) = self.__getMsSymbol(symbol, props)

        opacity = self.__getMsOpacity(msstyle)
        self.__getMsColor(msstyle, props, opacity, isline=True)
        self.__getMsOutlinecolor(msstyle, props, opacity, isline=True)
        self.__getMsLinecap(msstyle, props)
        self.__getMsLinejoin(msstyle, props)
        self.__getMsPattern(msstyle, props)
        self.__getMsWidth(msstyle, props)
        self.__getMsOutline(msstyle, props)
        self.__getMsScale(msstyle, props)
        offset = self.__getMsOffset(msstyle, props)

        if not type_marker:
            self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER)
            qgsSymbol = QgsSimpleLineSymbolLayerV2.create(props)
        else:
            props_parent = {}
            self.__setMsOffsetXY(offset, props)
            self.__getMsAngle(msstyle, props, props_parent)
            gap = self.__getMsGap(msstyle)

            if type_marker == _ms.MS_SYMBOL_ARROW:
                #El estilo de relleno de la flecha, no soportado por mapserver
                #[solid|horizontal|vertical|cross|b_diagonal|f_diagonal|diagonal_x|dense1|dense2|dense3|dense4|dense5|dense6|dense7|no]
                if QGis.QGIS_VERSION_INT >= 21600:
                    props['style'] = 'solid'
                    props_parent['head_type'] = _qgis.MARKERS_ARROW[
                        symbolname][0]
                    props_parent['arrow_type'] = _qgis.MARKERS_ARROW[
                        symbolname][1]
                    props_parent['is_repeated'] = '1' if gap else '0'
                    self.deleteProperties(props,
                                          _qgis.SIMPLE_FILL_SYMBOL_LAYER)
                    qgsSubSymbol = self.__getSubSymbol(
                        QgsFillSymbolV2, QgsSimpleFillSymbolLayerV2, QGis.Fill,
                        props)
                    self.deleteProperties(props_parent,
                                          _qgis.ARROW_SYMBOL_LAYER)
                    qgsSymbol = QgsArrowSymbolLayer.create(props_parent)
                else:
                    self.deleteProperties(props,
                                          _qgis.SIMPLE_MARKER_SYMBOL_LAYER)
                    qgsSubSymbol = self.__getSubSymbol(
                        QgsMarkerSymbolV2, QgsSimpleMarkerSymbolLayerV2,
                        QGis.Point, props)
                    self.deleteProperties(props_parent,
                                          _qgis.MARKER_LINE_SYMBOL_LAYER)
                    qgsSymbol = QgsMarkerLineSymbolLayerV2.create(props_parent)
                qgsSymbol.setSubSymbol(qgsSubSymbol)
            else:
                size = self.__getMsSize(msstyle, props)
                self.__getMarkerDisplacementAndRotate(msstyle, gap, size,
                                                      props_parent)
                self.__getMsInitialGap(msstyle, gap, props_parent)
                self.__getMsAnchorpoint(msSymbol, props)
                qgsSubSymbol = self.__getQgsMarkerSubSymbol(
                    type_marker, msSymbol, size, props)
                self.deleteProperties(props_parent,
                                      _qgis.MARKER_LINE_SYMBOL_LAYER)
                qgsSymbol = QgsMarkerLineSymbolLayerV2.create(props_parent)
                qgsSymbol.setSubSymbol(qgsSubSymbol)
        #print(props)
        return qgsSymbol
コード例 #2
0
    def __getQgsPolygonSymbolLayer(self, msstyle):
        props = {}
        type_marker = ''

        symbol = msstyle.get('symbol', False)
        if symbol:
            (type_marker, symbolname, msSymbol,
             props) = self.__getMsSymbol(symbol, props, True)

        opacity = self.__getMsOpacity(msstyle)
        color = self.__getMsColor(msstyle, props, opacity)
        self.__getMsOutlinecolor(msstyle, props, opacity)
        self.__getMsLinecap(msstyle, props)
        self.__getMsLinejoin(msstyle, props)
        self.__getMsPattern(msstyle, props)
        self.__getMsWidth(msstyle, props)
        self.__getMsOutline(msstyle, props)
        self.__getMsScale(msstyle, props)
        offset = self.__getMsOffset(msstyle, props)
        if not type_marker:
            #-linea sencilla exterior-#
            #-relleno simple (sin estilo de relleno preconfigurados)-#
            if not color:
                self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER)
                qgsSymbol = QgsSimpleLineSymbolLayerV2.create(props)
            else:
                self.deleteProperties(props, _qgis.SIMPLE_FILL_SYMBOL_LAYER)
                qgsSymbol = QgsSimpleFillSymbolLayerV2.create(props)
            #-relleno de gradientes-#
            #el gradiente es para renderer por categorias continuas
            #no aplica, porque aca es para gradiente de un simbolo
        else:
            props_parent = {}
            self.__setMsOffsetXY(offset, props)
            self.__getMsAngle(msstyle, props, props_parent)
            gap = self.__getMsGap(msstyle)
            size = self.__getMsSize(msstyle, props)
            self.__getMarkerDisplacementAndRotate(msstyle, gap, size,
                                                  props_parent)

            geomtransform = msstyle.get('geomtransform', '').lower()
            if geomtransform == 'centroid':
                #-relleno de centroides-#
                self.__getMsAnchorpoint(msSymbol, props)
                qgsSubSymbol = self.__getQgsMarkerSubSymbol(
                    type_marker, msSymbol, size, props)
                #self.deleteProperties(props_parent, _qgis.CENTROID_FILL_SYMBOL_LAYER)
                qgsSymbol = QgsCentroidFillSymbolLayerV2.create({})
                qgsSymbol.setSubSymbol(qgsSubSymbol)
            elif not color:
                #-Linea exterior:linea de marcador-#
                self.__getMsAnchorpoint(msSymbol, props)
                qgsSubSymbol = self.__getQgsMarkerSubSymbol(
                    type_marker, msSymbol, size, props)
                self.deleteProperties(props_parent,
                                      _qgis.MARKER_LINE_SYMBOL_LAYER)
                qgsSymbol = QgsMarkerLineSymbolLayerV2.create(props_parent)
                qgsSymbol.setSubSymbol(qgsSubSymbol)
            elif type_marker == _ms.MS_SYMBOL_HATCH:
                if not props['use_custom_dash']:
                    #-relleno simple (con estilo de relleno)-#
                    self.deleteProperties(props,
                                          _qgis.SIMPLE_LINE_SYMBOL_LAYER)
                    qgsSymbol = QgsSimpleLineSymbolLayerV2.create(props)
                else:
                    #-Patron de relleno de linea-#
                    self.deleteProperties(props,
                                          _qgis.SIMPLE_LINE_SYMBOL_LAYER)
                    qgsSubSymbol = self.__getSubSymbol(
                        QgsLineSymbolV2, QgsSimpleLineSymbolLayerV2, QGis.Line,
                        props)
                    self.deleteProperties(props_parent,
                                          _qgis.LINE_PATTERN_FILL_SYMBOL_LAYER)
                    qgsSymbol = QgsLinePatternFillSymbolLayer.create(
                        props_parent)
                    qgsSymbol.setSubSymbol(qgsSubSymbol)
            elif type_marker == _ms.MS_SYMBOL_PIXMAP:
                #-relleno de imagen raster-#
                self.deleteProperties(props, _qgis.RASTER_FILL_SYMBOL_LAYER)
                qgsSymbol = QgsRasterFillSymbolLayer.create(props)
            elif type_marker == _ms.MS_SYMBOL_SVG:
                #-relleno SVG-#
                self.deleteProperties(props, _qgis.SIMPLE_LINE_SYMBOL_LAYER)
                qgsSubSymbol = self.__getSubSymbol(QgsLineSymbolV2,
                                                   QgsSimpleLineSymbolLayerV2,
                                                   QGis.Line, props)
                self.deleteProperties(props_parent,
                                      _qgis.SVG_FILL_SYMBOL_LAYER)
                qgsSymbol = QgsSVGFillSymbolLayer.create(props_parent)
                qgsSymbol.setSubSymbol(qgsSubSymbol)
            else:
                #-patron de relleno de puntos-#
                self.__getMsAnchorpoint(msSymbol, props)
                qgsSubSymbol = self.__getQgsMarkerSubSymbol(
                    type_marker, msSymbol, size, props)
                self.deleteProperties(props_parent,
                                      _qgis.POINT_PATTERN_FILL_SYMBOL_LAYER)
                qgsSymbol = QgsPointPatternFillSymbolLayer.create(props_parent)
                qgsSymbol.setSubSymbol(qgsSubSymbol)

        #qgsSymbol.setAlpha((opacity*1.0)/100)
        #print(props)
        return qgsSymbol