本文整理汇总了Python中qgis.core.QgsGeometryValidator.start方法的典型用法代码示例。如果您正苦于以下问题:Python QgsGeometryValidator.start方法的具体用法?Python QgsGeometryValidator.start怎么用?Python QgsGeometryValidator.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsGeometryValidator
的用法示例。
在下文中一共展示了QgsGeometryValidator.start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MapToolCapture
# 需要导入模块: from qgis.core import QgsGeometryValidator [as 别名]
# 或者: from qgis.core.QgsGeometryValidator import start [as 别名]
#.........这里部分代码省略.........
def _undo(self):
if (self._rubberBand is not None):
rubberBandSize = self._rubberBand.numberOfVertices()
moveRubberBandSize = self._moveRubberBand.numberOfVertices()
if (rubberBandSize < 1 or len(self._mapPointList) < 1):
return
self._rubberBand.removePoint(-1)
if (rubberBandSize > 1):
if (moveRubberBandSize > 1):
point = self._rubberBand.getPoint(0, rubberBandSize - 2)
self._moveRubberBand.movePoint(moveRubberBandSize - 2, point)
else:
self._moveRubberBand.reset(self.geometryType())
self._mapPointList.pop()
self._validateGeometry()
def resetCapturing(self):
if (self._rubberBand is not None):
self._rubberBand.reset(self.geometryType())
if (self._moveRubberBand is not None):
self._moveRubberBand.reset(self.geometryType())
self._deleteGeometryValidation()
del self._mapPointList[:]
self.canvas().refresh()
def _deleteGeometryValidation(self):
if (self._validator is not None):
self._validator.errorFound.disconnect(self._addGeometryError)
self._validator.finished.disconnect(self.validationFinished)
self._validator.deleteLater()
self._validator = None
for errorMarker in self._geometryErrorMarkers:
self.canvas().scene().removeItem(errorMarker)
del self._geometryErrorMarkers[:]
self._geometryErrors[:]
self._tip = ''
def _validateGeometry(self):
geometryType = self.geometryType()
if (geometryType == QGis.Point
or geometryType == QGis.UnknownGeometry
or geometryType == QGis.NoGeometry
or len(self._mapPointList) < 2):
return
settings = QSettings()
if (settings.value('/qgis/digitizing/validate_geometries', 1) == 0):
return
self._deleteGeometryValidation()
geometry = None # QgsGeometry()
if (geometryType == QGis.Line):
geometry = QgsGeometry.fromPolyline(self._mapPointList)
elif (geometryType == QGis.Polygon):
if (len(self._mapPointList) < 3):
return
closed = list(self._mapPointList)
closed.append(self._mapPointList[0])
geometry = QgsGeometry.fromPolygon([closed])
if (geometry is None):
return
self._validator = QgsGeometryValidator(geometry)
self._validator.errorFound.connect(self._addGeometryError)
self._validator.finished.connect(self.validationFinished)
self._validator.start()
self._iface.mainWindow().statusBar().showMessage(self.tr('Geometry validation started.'))
def _addGeometryError(self, error):
self._geometryErrors.append(error)
if (self._tip != ''):
self._tip += '\n'
self._tip += error.what()
if (error.hasWhere()):
marker = QgsVertexMarker(self.canvas())
marker.setCenter(error.where())
marker.setIconType(QgsVertexMarker.ICON_X)
marker.setPenWidth(2)
marker.setToolTip(error.what())
marker.setColor(Qt.green)
marker.setZValue(marker.zValue() + 1)
self._geometryErrorMarkers.append(marker)
self._iface.mainWindow().statusBar().showMessage(error.what())
if (self._tip != ''):
self._iface.mainWindow().statusBar().setToolTip(self._tip)
def validationFinished(self):
self._iface.mainWindow().statusBar().showMessage(self.tr('Geometry validation finished.'))