Skip to content

Commit 8f25bcf

Browse files
committed
fix #7172
1 parent 7275525 commit 8f25bcf

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

python/plugins/fTools/tools/doGeoprocessing.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,6 @@ def intersect( self ):
891891
crs_match = None
892892
else:
893893
crs_match = crsA == crsB
894-
895894
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
896895
longNames = ftools_utils.checkFieldNameLength( fields )
897896
if not longNames.isEmpty():
@@ -945,7 +944,8 @@ def intersect( self ):
945944
gList = ftools_utils.getGeomType( geom.wkbType() )
946945
if int_geom.wkbType() in gList:
947946
outFeat.setGeometry( int_geom )
948-
outFeat.setAttributes( atMapA.extend( atMapB ) )
947+
atMapA.extend( atMapB )
948+
outFeat.setAttributes( atMapA )
949949
writer.addFeature( outFeat )
950950
except:
951951
FEATURE_EXCEPT = False
@@ -976,7 +976,8 @@ def intersect( self ):
976976
gList = ftools_utils.getGeomType( geom.wkbType() )
977977
if int_geom.wkbType() in gList:
978978
outFeat.setGeometry( int_geom )
979-
outFeat.setAttributes( atMapA.extend( atMapB ) )
979+
atMapA.extend( atMapB )
980+
outFeat.setAttributes( atMapA )
980981
writer.addFeature( outFeat )
981982
except:
982983
EATURE_EXCEPT = False
@@ -1015,7 +1016,8 @@ def intersect( self ):
10151016
gList = ftools_utils.getGeomType( geom.wkbType() )
10161017
if int_geom.wkbType() in gList:
10171018
outFeat.setGeometry( int_geom )
1018-
outFeat.setAttributes( atMapA.extend( atMapB ) )
1019+
atMapA.extend( atMapB )
1020+
outFeat.setAttributes( atMapA )
10191021
writer.addFeature( outFeat )
10201022
except:
10211023
FEATURE_EXCEPT = False
@@ -1025,8 +1027,8 @@ def intersect( self ):
10251027
break
10261028
# we have no selection in overlay layer
10271029
else:
1028-
fitA = vproviderA.getFeatures()
1029-
while fita.nextFeature( inFeatA ):
1030+
fitA = vproviderA.getFeatures()
1031+
while fitA.nextFeature( inFeatA ):
10301032
nElement += 1
10311033
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
10321034
geom = QgsGeometry( inFeatA.geometry() )
@@ -1043,11 +1045,13 @@ def intersect( self ):
10431045
int_com = geom.combine( tmpGeom )
10441046
int_sym = geom.symDifference( tmpGeom )
10451047
int_geom = QgsGeometry( int_com.difference( int_sym ) )
1048+
10461049
try:
10471050
gList = ftools_utils.getGeomType( geom.wkbType() )
10481051
if int_geom.wkbType() in gList:
10491052
outFeat.setGeometry( int_geom )
1050-
outFeat.setAttributes( atMapA.extend( atMapB ) )
1053+
atMapA.extend( atMapB )
1054+
outFeat.setAttributes( atMapA )
10511055
writer.addFeature( outFeat )
10521056
except:
10531057
FEATURE_EXCEPT = False
@@ -1148,7 +1152,8 @@ def union( self ):
11481152
int_geom = QgsGeometry( i )
11491153
try:
11501154
outFeat.setGeometry( int_geom )
1151-
outFeat.setAttributes( atMapA.extend( atMapB ) )
1155+
atMapA.extend( atMapB )
1156+
outFeat.setAttributes( atMapA )
11521157
writer.addFeature( outFeat )
11531158
except Exception, err:
11541159
FEATURE_EXCEPT = False
@@ -1161,7 +1166,8 @@ def union( self ):
11611166
if int_geom.wkbType() in gList:
11621167
try:
11631168
outFeat.setGeometry( int_geom )
1164-
outFeat.setAttributes( atMapA.extend( atMapB ) )
1169+
atMapA.extend( atMapB )
1170+
outFeat.setAttributes( atMapA )
11651171
writer.addFeature( outFeat )
11661172
except Exception, err:
11671173
FEATURE_EXCEPT = False

python/plugins/fTools/tools/ftools_utils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def combineVectorFields( layerA, layerB ):
7676
fieldsA = layerA.dataProvider().fields()
7777
fieldsB = layerB.dataProvider().fields()
7878
fieldsB = testForUniqueness( fieldsA, fieldsB )
79-
fieldsA.extend( fieldsB )
79+
for f in fieldsB:
80+
fieldsA.append( f )
8081
return fieldsA
8182

8283
# Check if two input CRSs are identical
@@ -155,10 +156,10 @@ def testForUniqueness( fieldList1, fieldList2 ):
155156
changed = True
156157
while changed:
157158
changed = False
158-
for i in fieldList1:
159-
for j in fieldList2:
160-
if j.name() == i.name():
161-
j = createUniqueFieldName( j )
159+
for i in range(0,len(fieldList1)):
160+
for j in range(0,len(fieldList2)):
161+
if fieldList1[i].name() == fieldList2[j].name():
162+
fieldList2[j] = createUniqueFieldName( fieldList2[j] )
162163
changed = True
163164
return fieldList2
164165

@@ -265,7 +266,6 @@ def addShapeToCanvas( shapefile_path ):
265266
else:
266267
return False
267268
vlayer_new = QgsVectorLayer( shapefile_path, layer_name, "ogr" )
268-
print layer_name
269269
if vlayer_new.isValid():
270270
QgsMapLayerRegistry.instance().addMapLayers( [vlayer_new] )
271271
return True

0 commit comments

Comments
 (0)