mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
add new simplify tool to the fTools. Completed changes introduced in r14678
git-svn-id: http://svn.osgeo.org/qgis/trunk@14686 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
c1fbf4827c
commit
2f85efe477
@ -90,11 +90,6 @@ class GeometryDialog(QDialog, Ui_Dialog):
|
||||
self.lineEdit.setVisible(False)
|
||||
self.cmbField.setVisible(False)
|
||||
self.field_label.setVisible(False)
|
||||
elif self.myFunction == 6: # Simplify geometries
|
||||
self.setWindowTitle( self.tr( "Simplify geometries" ) )
|
||||
self.label_2.setText( self.tr( "Output shapefile" ) )
|
||||
self.cmbField.setVisible(False)
|
||||
self.field_label.setVisible(False)
|
||||
elif self.myFunction == 7: # Polygon centroids
|
||||
self.setWindowTitle( self.tr( "Polygon centroids" ) )
|
||||
self.label_2.setText( self.tr( "Output point shapefile" ) )
|
||||
@ -136,7 +131,7 @@ class GeometryDialog(QDialog, Ui_Dialog):
|
||||
#3: Extract nodes
|
||||
#4: Polygons to lines
|
||||
#5: Export/Add geometry columns
|
||||
#6: Simplify geometries
|
||||
#6: Simplify geometries (disabled)
|
||||
#7: Polygon centroids
|
||||
#8: Delaunay triangulation
|
||||
#9: Polygon from layer extent
|
||||
@ -218,8 +213,7 @@ class geometryThread( QThread ):
|
||||
success = self.polygons_to_lines()
|
||||
elif self.myFunction == 5: # Export/Add geometry columns
|
||||
success = self.export_geometry_info()
|
||||
elif self.myFunction == 6: # Simplify geometries
|
||||
success = self.simplify_geometry()
|
||||
# note that 6 used to be associated with simplify_geometry
|
||||
elif self.myFunction == 7: # Polygon centroids
|
||||
success = self.polygon_centroids()
|
||||
elif self.myFunction == 8: # Delaunay triangulation
|
||||
@ -401,35 +395,6 @@ class geometryThread( QThread ):
|
||||
del writer
|
||||
return True
|
||||
|
||||
def simplify_geometry( self ):
|
||||
vprovider = self.vlayer.dataProvider()
|
||||
tolerance = self.myParam
|
||||
allAttrs = vprovider.attributeIndexes()
|
||||
vprovider.select( allAttrs )
|
||||
fields = vprovider.fields()
|
||||
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
|
||||
fields, vprovider.geometryType(), vprovider.crs() )
|
||||
inFeat = QgsFeature()
|
||||
outFeat = QgsFeature()
|
||||
nFeat = vprovider.featureCount()
|
||||
nElement = 0
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||
self.measure = QgsDistanceArea()
|
||||
while vprovider.nextFeature( inFeat ):
|
||||
nElement += 1
|
||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||
inGeom = inFeat.geometry()
|
||||
atMap = inFeat.attributeMap()
|
||||
outGeom = QgsGeometry(inGeom.simplify(tolerance))
|
||||
if outGeom is None:
|
||||
return "math_error"
|
||||
outFeat.setAttributeMap( atMap )
|
||||
outFeat.setGeometry( outGeom )
|
||||
writer.addFeature( outFeat )
|
||||
del writer
|
||||
return True
|
||||
|
||||
def polygon_centroids( self ):
|
||||
vprovider = self.vlayer.dataProvider()
|
||||
allAttrs = vprovider.attributeIndexes()
|
||||
|
Loading…
x
Reference in New Issue
Block a user