Graphics Reference
In-Depth Information
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.Line)
del self.capturedPoints[-1]
We now define the getCapturedPoints() method, which returns either the set of
points the user clicked on or None if the user didn't click on enough points to make a
LineString:
def getCapturedPoints(self):
points = self.capturedPoints
if len(points) < 2:
return None
else:
return points
Our final method is pointsCaptured() , which responds when the user finishes click-
ing on the points for a new track. Unlike the equivalent method in CaptureTool , we
have to set the various attributes for the new track:
def pointsCaptured(self, points):
fields = self.layer.dataProvider().fields()
feature = QgsFeature()
feature.setGeometry(QgsGeometry.fromPolyline(points))
feature.setFields(fields)
feature.setAttribute("type", TRACK_TYPE_ROAD)
Search WWH ::




Custom Search