當前位置: 首頁>>代碼示例>>Python>>正文


Python QgsSymbolLayerV2Utils.parseProperties方法代碼示例

本文整理匯總了Python中qgis.core.QgsSymbolLayerV2Utils.parseProperties方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsSymbolLayerV2Utils.parseProperties方法的具體用法?Python QgsSymbolLayerV2Utils.parseProperties怎麽用?Python QgsSymbolLayerV2Utils.parseProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qgis.core.QgsSymbolLayerV2Utils的用法示例。


在下文中一共展示了QgsSymbolLayerV2Utils.parseProperties方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create

# 需要導入模塊: from qgis.core import QgsSymbolLayerV2Utils [as 別名]
# 或者: from qgis.core.QgsSymbolLayerV2Utils import parseProperties [as 別名]
    def create(dom_document):
        """
        Create an instance of the 'SpatialFieldsConfiguration' object from a DOM document.
        Returns None if the dom_document is invalid.
        """
        from stdm.ui.composer import SpatialFieldMapping
        
        dataSourceElem = dom_document.documentElement().firstChildElement("DataSource")
        
        if dataSourceElem == None:
            return None
        
        spatialFieldsConfigElement = dataSourceElem.firstChildElement("SpatialFields") 
        spFieldsConfig = SpatialFieldsConfiguration()
        
        #Get spatial field mappings
        spatialFieldMappingList = spatialFieldsConfigElement.elementsByTagName("SpatialField")
        numItems = spatialFieldMappingList.length()
        
        for i in range(numItems):
            spatialFieldMappingElement = spatialFieldMappingList.item(i).toElement()
            labelField = spatialFieldMappingElement.attribute("labelField")
            spatialField = spatialFieldMappingElement.attribute("name")
            itemId = spatialFieldMappingElement.attribute("itemid") 
            srid = int(spatialFieldMappingElement.attribute("srid"))
            geomType = spatialFieldMappingElement.attribute("geomType") 
            zoom = float(spatialFieldMappingElement.attribute("zoom"))
            zoom_type = spatialFieldMappingElement.attribute('zoomType', 'RELATIVE')
            
            #Create spatial field mapping
            spFieldMapping = SpatialFieldMapping(spatialField,labelField) 
            spFieldMapping.setItemId(itemId)
            spFieldMapping.setSRID(srid)
            spFieldMapping.setGeometryType(geomType)
            spFieldMapping.setZoomLevel(zoom)
            spFieldMapping.zoom_type = zoom_type

            symbolElement = spatialFieldMappingElement.firstChildElement("Symbol")
            if not symbolElement is None:
                layerType = symbolElement.attribute("layerType")
                layerProps = QgsSymbolLayerV2Utils.parseProperties(symbolElement)
                symbolLayer =  QgsSymbolLayerV2Registry.instance().createSymbolLayer(layerType,layerProps)
                spFieldMapping.setSymbolLayer(symbolLayer)
            
            spFieldsConfig.addSpatialFieldMapping(spFieldMapping)
            
        return spFieldsConfig
開發者ID:gltn,項目名稱:stdm,代碼行數:49,代碼來源:spatial_fields_config.py


注:本文中的qgis.core.QgsSymbolLayerV2Utils.parseProperties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。