[QGIS Commit] r13315 - trunk/qgis/python/plugins/fTools/tools
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Apr 14 20:45:39 EDT 2010
Author: cfarmer
Date: 2010-04-14 20:45:38 -0400 (Wed, 14 Apr 2010)
New Revision: 13315
Modified:
trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py
Log:
Restore previous version of dissolve function (previous changes should not have been commited yet.
Modified: trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py 2010-04-15 00:29:39 UTC (rev 13314)
+++ trunk/qgis/python/plugins/fTools/tools/doGeoprocessing.py 2010-04-15 00:45:38 UTC (rev 13315)
@@ -542,14 +542,12 @@
vproviderA = self.vlayerA.dataProvider()
allAttrsA = vproviderA.attributeIndexes()
fields = vproviderA.fields()
- writer = QgsVectorFileWriter( self.myName, self.myEncoding,
+ writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vproviderA.geometryType(), vproviderA.crs() )
inFeat = QgsFeature()
outFeat = QgsFeature()
vproviderA.rewind()
nElement = 0
- inGeom = QgsGeometry()
- geoms = []
# there is selection in input layer
if self.mySelectionA:
nFeat = self.vlayerA.selectedFeatureCount()
@@ -559,21 +557,24 @@
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
first = True
for inFeat in selectionA:
- nElement += 0.5
+ nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
if first:
attrs = inFeat.attributeMap()
- inGeom = QgsGeometry( inFeat.geometry() )
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ outFeat.setGeometry( tmpInGeom )
first = False
else:
- tmp_geom = QgsGeometry( inFeat.geometry() )
- geoms.append(tmp_geom)
- outGeom = QgsGeometry(inGeom.combineCascaded(geoms))
- nElement += nFeat/2
- self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
- outFeat.setGeometry(outGeom)
- outFeat.setAttributeMap(attrs)
- writer.addFeature(outFeat)
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ tmpOutGeom = QgsGeometry( outFeat.geometry() )
+ try:
+ tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+ outFeat.setGeometry( tmpOutGeom )
+ except:
+ GEOS_EXCEPT = False
+ continue
+ outFeat.setAttributeMap( attrs )
+ writer.addFeature( outFeat )
else:
unique = vproviderA.uniqueValues( int( self.myParam ) )
nFeat = nFeat * len( unique )
@@ -584,25 +585,31 @@
add = False
vproviderA.select( allAttrsA )
vproviderA.rewind()
- filtered = [feat for feat in selectionA if feat.attributeMap()[
- self.myParam].toString().trimmed() == item.toString().trimmed()]
- for inFeat in filtered:
- nElement += 0.5
+ for inFeat in selectionA:
+ nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
atMap = inFeat.attributeMap()
- if first:
- inGeom = QgsGeometry( inFeat.geometry() )
- first = False
- attrs = inFeat.attributeMap()
- else:
- tmp_geom = QgsGeometry( inFeat.geometry() )
- geoms.append(tmp_geom)
- outGeom = QgsGeometry(inGeom.combineCascaded(geoms))
- nElement += nFeat/2
- self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
- outFeat.setGeometry(outGeom)
- outFeat.setAttributeMap(attrs)
- writer.addFeature(outFeat)
+ tempItem = atMap[ self.myParam ]
+ if tempItem.toString().trimmed() == item.toString().trimmed():
+ add = True
+ if first:
+ QgsGeometry( inFeat.geometry() )
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ outFeat.setGeometry( tmpInGeom )
+ first = False
+ attrs = inFeat.attributeMap()
+ else:
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ tmpOutGeom = QgsGeometry( outFeat.geometry() )
+ try:
+ tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+ outFeat.setGeometry( tmpOutGeom )
+ except:
+ GEOS_EXCEPT = False
+ add = False
+ if add:
+ outFeat.setAttributeMap( attrs )
+ writer.addFeature( outFeat )
# there is no selection in input layer
else:
nFeat = vproviderA.featureCount()
@@ -611,51 +618,58 @@
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
first = True
while vproviderA.nextFeature( inFeat ):
- nElement += 0.5
+ nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
if first:
attrs = inFeat.attributeMap()
- inGeom = QgsGeometry( inFeat.geometry() )
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ outFeat.setGeometry( tmpInGeom )
first = False
else:
- tmp_geom = QgsGeometry( inFeat.geometry() )
- geoms.append(tmp_geom)
- outGeom = QgsGeometry(inGeom.combineCascaded(geoms))
- nElement += nFeat/2
- self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
- outFeat.setGeometry(outGeom)
- outFeat.setAttributeMap(attrs)
- writer.addFeature(outFeat)
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ tmpOutGeom = QgsGeometry( outFeat.geometry() )
+ try:
+ tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+ outFeat.setGeometry( tmpOutGeom )
+ except:
+ GEOS_EXCEPT = False
+ continue
+ outFeat.setAttributeMap( attrs )
+ writer.addFeature( outFeat )
else:
unique = vproviderA.uniqueValues( int( self.myParam ) )
nFeat = nFeat * len( unique )
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0)
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
for item in unique:
- geoms = []
first = True
add = True
vproviderA.select( allAttrsA )
vproviderA.rewind()
while vproviderA.nextFeature( inFeat ):
- nElement += 0.5
+ nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
atMap = inFeat.attributeMap()
tempItem = atMap[ self.myParam ]
if tempItem.toString().trimmed() == item.toString().trimmed():
if first:
- inGeom = QgsGeometry( inFeat.geometry() )
+ QgsGeometry( inFeat.geometry() )
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ outFeat.setGeometry( tmpInGeom )
first = False
attrs = inFeat.attributeMap()
else:
- tmp_geom = QgsGeometry( inFeat.geometry() )
- geoms.append(tmp_geoms)
- outGeom = QgsGeometry(inGeom.combineCascaded(geoms))
- nElement += nFeat/2
- self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
- outFeat.setGeometry(outGeom)
- outFeat.setAttributeMap(attrs)
- writer.addFeature(outFeat)
+ tmpInGeom = QgsGeometry( inFeat.geometry() )
+ tmpOutGeom = QgsGeometry( outFeat.geometry() )
+ try:
+ tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
+ outFeat.setGeometry( tmpOutGeom )
+ except:
+ GEOS_EXCEPT = False
+ add = False
+ if add:
+ outFeat.setAttributeMap( attrs )
+ writer.addFeature( outFeat )
del writer
return GEOS_EXCEPT, FEATURE_EXCEPT, True
More information about the QGIS-commit
mailing list