Skip to content
Permalink
Browse files

fTools: fix MergeShapes and SpatialJoin

fix #7823
fix #7952
fix #8206
  • Loading branch information
minorua committed Jul 3, 2013
1 parent bc002f7 commit 7d75fcc38778cf0e1bb005124e69b4e30dd49821
Showing with 11 additions and 9 deletions.
  1. +10 −8 python/plugins/fTools/tools/doMergeShapes.py
  2. +1 −1 python/plugins/fTools/tools/doSpatialJoin.py
@@ -118,7 +118,7 @@ def accept( self ):
if self.inputFiles is None:
workDir = QDir( self.leInputDir.text() )
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
nameFilter = [ "*.shp" << "*.SHP" ]
nameFilter = [ "*.shp", "*.SHP" ]
workDir.setNameFilters( nameFilter )
self.inputFiles = workDir.entryList()
if len( self.inputFiles ) == 0:
@@ -251,22 +251,24 @@ def run( self ):
if not newLayer.isValid():
continue

newLayer.setProviderEncoding( self.inputEncoding )
vprovider = newLayer.dataProvider()

fieldMap[shapeIndex] = {}
fieldIndex = 0
for layerField in vprovider.fields():
fieldFound = False
for mergedField in mergedFields:
for mergedFieldIndex, mergedField in enumerate(mergedFields):
if mergedField.name() == layerField.name() and mergedField.type() == layerField.type():
fieldFound = True
fieldMap[shapeIndex][fieldIndex] = mergedFieldIndex

if mergedField.length() < layerField.length():
# suit the field size to the field of this layer
mergedField.setLength( layerField.length() )
break

if not fieldFound:
if not fieldMap.has_key(shapeIndex):
fieldMap[shapeIndex]={}

fieldMap[shapeIndex][fieldIndex] = len(mergedFields)

mergedFields.append( layerField )

fieldIndex += 1
@@ -295,8 +297,8 @@ def run( self ):
newLayer = QgsVectorLayer( layerPath, QFileInfo( layerPath ).baseName(), "ogr" )
if not newLayer.isValid():
continue
newLayer.setProviderEncoding( self.inputEncoding )
vprovider = newLayer.dataProvider()
vprovider.setEncoding( self.inputEncoding )
layerFields = vprovider.fields()
nFeat = vprovider.featureCount()
self.emit( SIGNAL( "rangeChanged( PyQt_PyObject )" ), nFeat )
@@ -123,7 +123,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
provider2 = layer2.dataProvider()

fieldList2 = ftools_utils.getFieldList(layer2)
fieldList = []
fieldList = QgsFields()
if provider1.crs() != provider2.crs():
QMessageBox.warning(self, self.tr("CRS warning!"), self.tr("Warning: Input layers have non-matching CRS.\nThis may cause unexpected results."))
if not summary:

0 comments on commit 7d75fcc

Please sign in to comment.
You can’t perform that action at this time.