本文整理汇总了Python中qgis.core.QgsFields.remove方法的典型用法代码示例。如果您正苦于以下问题:Python QgsFields.remove方法的具体用法?Python QgsFields.remove怎么用?Python QgsFields.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsFields
的用法示例。
在下文中一共展示了QgsFields.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyProvider
# 需要导入模块: from qgis.core import QgsFields [as 别名]
# 或者: from qgis.core.QgsFields import remove [as 别名]
#.........这里部分代码省略.........
def addFeatures(self, flist, flags=None):
added = False
f_added = []
for f in flist:
if f.hasGeometry() and (f.geometry().wkbType() != self.wkbType()):
return added, f_added
for f in flist:
_f = QgsFeature(self.fields())
_f.setGeometry(f.geometry())
attrs = [None for i in range(_f.fields().count())]
for i in range(min(len(attrs), len(f.attributes()))):
attrs[i] = f.attributes()[i]
_f.setAttributes(attrs)
_f.setId(self.next_feature_id)
self._features[self.next_feature_id] = _f
self.next_feature_id += 1
added = True
f_added.append(_f)
if self._spatialindex is not None:
self._spatialindex.insertFeature(_f)
if len(f_added):
self.clearMinMaxCache()
self.updateExtents()
return added, f_added
def deleteFeatures(self, ids):
if not ids:
return True
removed = False
for id in ids:
if id in self._features:
if self._spatialindex is not None:
self._spatialindex.deleteFeature(self._features[id])
del self._features[id]
removed = True
if removed:
self.clearMinMaxCache()
self.updateExtents()
return removed
def addAttributes(self, attrs):
try:
for new_f in attrs:
if new_f.type() not in (QVariant.Int, QVariant.Double, QVariant.String, QVariant.Date, QVariant.Time, QVariant.DateTime, QVariant.LongLong, QVariant.StringList, QVariant.List):
continue
self._fields.append(new_f)
for f in self._features.values():
old_attrs = f.attributes()
old_attrs.append(None)
f.setAttributes(old_attrs)
self.clearMinMaxCache()
return True
except Exception:
return False
def renameAttributes(self, renamedAttributes):
result = True
# We need to replace all fields because python bindings return a copy from [] and at()
new_fields = [self._fields.at(i) for i in range(self._fields.count())]
for fieldIndex, new_name in renamedAttributes.items():
if fieldIndex < 0 or fieldIndex >= self._fields.count():