本文整理汇总了Python中qgis.core.QgsTextBufferSettings.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python QgsTextBufferSettings.setColor方法的具体用法?Python QgsTextBufferSettings.setColor怎么用?Python QgsTextBufferSettings.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsTextBufferSettings
的用法示例。
在下文中一共展示了QgsTextBufferSettings.setColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createBufferSettings
# 需要导入模块: from qgis.core import QgsTextBufferSettings [as 别名]
# 或者: from qgis.core.QgsTextBufferSettings import setColor [as 别名]
def createBufferSettings(self):
s = QgsTextBufferSettings()
s.setEnabled(True)
s.setSize(5)
s.setSizeUnit(QgsUnitTypes.RenderPixels)
s.setSizeMapUnitScale(QgsMapUnitScale(1, 2))
s.setColor(QColor(255, 0, 0))
s.setFillBufferInterior(True)
s.setOpacity(0.5)
s.setJoinStyle(Qt.RoundJoin)
s.setBlendMode(QPainter.CompositionMode_Difference)
s.setPaintEffect(QgsBlurEffect.create({'blur_level': '2.0', 'blur_unit': QgsUnitTypes.encodeUnit(QgsUnitTypes.RenderMillimeters), 'enabled': '1'}))
return s
示例2: save_pois_points
# 需要导入模块: from qgis.core import QgsTextBufferSettings [as 别名]
# 或者: from qgis.core.QgsTextBufferSettings import setColor [as 别名]
#.........这里部分代码省略.........
email = point["email"]
else: email= ""
#address
if "address" in list(point['location'].keys()):
if "street" in list(point['location']["address"].keys()):
straat = point['location']["address"]["street"]
else: straat = ''
if "streetnumber" in list(point['location']["address"].keys()):
huisnr = point['location']["address"]["streetnumber"]
else: huisnr = ''
if "boxnumber" in list(point['location']["address"].keys()):
busnr = point['location']["address"]["boxnumber"]
else: boxnr = ''
postcode = point['location']["address"]["postalcode"]
gemeente = point['location']["address"]["municipality"]
else:
straat = ""
huisnr = ""
busnr = ""
postcode = ""
gemeente = ""
if "links" in point:
link = point["links"][0]['href']
else: link = ""
tijd = point["updated"]
if "authors" in point:
owner = point["authors"][0]["value"]
else: owner= ""
# add a feature
fet = QgsFeature(fields)
#set geometry
fromCrs = QgsCoordinateReferenceSystem(4326)
xform = QgsCoordinateTransform( fromCrs, self.poilayer.crs(), QgsProject.instance() )
prjPt = xform.transform( pt )
fet.setGeometry(QgsGeometry.fromPointXY(prjPt))
fet['id'] = int( poiId )
fet['thema'] = theme
fet['categorie'] = category
fet['type'] = poiType
fet['naam'] = name
fet["email"] = email
fet["telefoon"] = phone
#address
fet['straat'] = straat
fet['huisnr'] = huisnr
fet['busnr'] = busnr
fet['postcode'] = postcode
fet['gemeente'] = gemeente
fet['link'] = link
fet['lastupdate'] = tijd
fet['owner'] = owner
self.poiProvider.addFeatures([ fet ])
self.poilayer.updateExtents()
if saveToFile and not QgsProject.instance().mapLayer(self.poilayerid):
save = self._saveToFile( sender, startFolder )
if save:
fpath, flType = save
error, msg = QgsVectorFileWriter.writeAsVectorFormat(self.poilayer,fileName=fpath, fileEncoding="utf-8", driverName=flType )
if error == QgsVectorFileWriter.NoError:
self.poilayer = QgsVectorLayer( fpath , layername, "ogr")
self.poiProvider = self.poilayer.dataProvider()
else:
del self.poilayer, self.poiProvider
raise Exception( msg )
else:
del self.poilayer, self.poiProvider
return
# add Labels
text_format = QgsTextFormat()
text_format.setSize(12)
buffer_settings = QgsTextBufferSettings()
buffer_settings.setEnabled(True)
buffer_settings.setSize(1)
buffer_settings.setColor(QColor("white"))
palyr = QgsPalLayerSettings()
text_format.setBuffer(buffer_settings)
palyr.setFormat(text_format)
palyr.enabled = True
palyr.fieldName = 'naam'
palyr.placement = QgsPalLayerSettings.Free
self.poilayer.setLabelsEnabled(True)
self.poilayer.setLabeling( QgsVectorLayerSimpleLabeling(palyr) )
# add layer if not already
QgsProject.instance().addMapLayer(self.poilayer)
# store layer id and refresh
self.poilayerid = self.poilayer.id()
self.canvas.refresh()
示例3: save_adres_point
# 需要导入模块: from qgis.core import QgsTextBufferSettings [as 别名]
# 或者: from qgis.core.QgsTextBufferSettings import setColor [as 别名]
def save_adres_point(self, point, address, typeAddress='', layername="Geopunt_adres", saveToFile=False, sender=None, startFolder=None ):
attributes = [QgsField("adres", QVariant.String), QgsField("type", QVariant.String)]
mapcrs = self.getGetMapCrs(self.iface)
if not QgsProject.instance().mapLayer(self.adreslayerid):
self.adreslayer = QgsVectorLayer("Point", layername, "memory")
self.adresProvider = self.adreslayer.dataProvider()
self.adresProvider.addAttributes(attributes)
self.adreslayer.updateFields()
# add a feature
fields= self.adreslayer.fields()
fet = QgsFeature(fields)
#set geometry and project from mapCRS
xform = QgsCoordinateTransform( mapcrs, self.adreslayer.crs(), QgsProject.instance() )
prjPoint = xform.transform( point )
fet.setGeometry(QgsGeometry.fromPointXY(prjPoint))
#populate fields
fet['adres'] = address
fet['type'] = typeAddress
self.adresProvider.addFeatures([ fet ])
""
# update layer's extent when new features have been added
# because change of extent in provider is not propagated to the layer
self.adreslayer.updateExtents()
# save memoryLAYER to file and replace all references
if saveToFile and not QgsProject.instance().mapLayer(self.adreslayerid):
save = self._saveToFile( sender, startFolder )
if save:
fpath, flType = save
error, msg = QgsVectorFileWriter.writeAsVectorFormat(self.adreslayer, fileName=fpath, fileEncoding="utf-8", driverName=flType)
if error == QgsVectorFileWriter.NoError:
self.adreslayer = QgsVectorLayer( fpath, layername, "ogr")
self.adresProvider = self.adreslayer.dataProvider()
else:
del self.adreslayer, self.adresProvider
return
else:
del self.adreslayer, self.adresProvider
return
# add to map
QgsProject.instance().addMapLayer(self.adreslayer)
#labels
text_format = QgsTextFormat()
text_format.setSize(12)
buffer_settings = QgsTextBufferSettings()
buffer_settings.setEnabled(True)
buffer_settings.setSize(1)
buffer_settings.setColor(QColor("white"))
palyr = QgsPalLayerSettings()
text_format.setBuffer(buffer_settings)
palyr.setFormat(text_format)
palyr.enabled = True
palyr.fieldName = 'adres'
palyr.placement = QgsPalLayerSettings.Free
self.adreslayer.setLabelsEnabled(True)
self.adreslayer.setLabeling( QgsVectorLayerSimpleLabeling(palyr) )
# store layer id and refresh
self.adreslayerid = self.adreslayer.id()
self.canvas.refresh()