本文整理匯總了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