本文整理汇总了Python中qgis.gui.QgsRubberBand.removePoint方法的典型用法代码示例。如果您正苦于以下问题:Python QgsRubberBand.removePoint方法的具体用法?Python QgsRubberBand.removePoint怎么用?Python QgsRubberBand.removePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.gui.QgsRubberBand
的用法示例。
在下文中一共展示了QgsRubberBand.removePoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ApisMapToolEmitPolygonAndPoint
# 需要导入模块: from qgis.gui import QgsRubberBand [as 别名]
# 或者: from qgis.gui.QgsRubberBand import removePoint [as 别名]
#.........这里部分代码省略.........
self.rubberBand = None
if self.tempRubberBand:
self.canvas.scene().removeItem(self.tempRubberBand)
self.tempRubberBand = None
self.capturing = False
self.capturedPoints = []
self.derivedPoint = None
self.canvas.refresh()
def addVertex(self, canvasPoint):
mapPt = self.transformCoordinates(canvasPoint)
self.rubberBand.addPoint(mapPt)
self.capturedPoints.append(mapPt)
bandSize = self.rubberBand.numberOfVertices()
if bandSize > 2:
rubGeom = self.rubberBand.asGeometry()
cpGeom = rubGeom.centroid()
if not rubGeom.contains(cpGeom):
cpGeom = rubGeom.pointOnSurface()
#nearestCp = rubGeom.nearestPoint(cpGeom)
self.vertexMarker.setCenter(cpGeom.asPoint())
self.derivedPoint = cpGeom.asPoint()
self.vertexMarker.show()
self.tempRubberBand.reset(QGis.Polygon)
firstPoint = self.rubberBand.getPoint(0, 0)
self.tempRubberBand.addPoint(firstPoint)
self.tempRubberBand.movePoint(mapPt)
self.tempRubberBand.addPoint(mapPt)
def removeLastVertex(self):
if not self.capturing:
return
bandSize = self.rubberBand.numberOfVertices()
tempBandSize = self.tempRubberBand.numberOfVertices()
numPoints = len(self.capturedPoints)
if bandSize < 1 or numPoints < 1:
return
self.rubberBand.removePoint(-1)
if bandSize > 1:
if tempBandSize > 1:
point = self.rubberBand.getPoint(0, bandSize - 2)
self.tempRubberBand.movePoint(tempBandSize - 2, point)
else:
self.tempRubberBand.reset(QGis.Polygon)
bandSize = self.rubberBand.numberOfVertices()
if bandSize < 3:
self.vertexMarker.hide()
else:
rubGeom = self.rubberBand.asGeometry()
cpGeom = rubGeom.centroid()
if not rubGeom.contains(cpGeom):
cpGeom = rubGeom.pointOnSurface()
#nearestCp = rubGeom.nearestPoint(cpGeom)
self.vertexMarker.setCenter(cpGeom.asPoint())
self.derivedPoint = cpGeom.asPoint()
self.vertexMarker.show()
del self.capturedPoints[-1]
def getCapturedPolygon(self):
polygon = self.capturedPoints
if len(polygon) < 3:
return None
else:
return polygon
def getDerivedPoint(self):
point = self.derivedPoint
if point == None:
return None
else:
return point
def getPointGeometry(self, geom):
p = QgsGeometry.fromPoint(geom)
if p.isGeosValid() and not p.isGeosEmpty():
return p
else:
return None
def getPolygonGeometry(self, geom):
p = QgsGeometry.fromPolygon([geom])
if p.isGeosValid() and not p.isGeosEmpty():
return p
else:
return None