Skip to content

Commit

Permalink
fix #7172
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 17, 2013
1 parent 7275525 commit 8f25bcf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
24 changes: 15 additions & 9 deletions python/plugins/fTools/tools/doGeoprocessing.py
Expand Up @@ -891,7 +891,6 @@ def intersect( self ):
crs_match = None
else:
crs_match = crsA == crsB

fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLength( fields )
if not longNames.isEmpty():
Expand Down Expand Up @@ -945,7 +944,8 @@ def intersect( self ):
gList = ftools_utils.getGeomType( geom.wkbType() )
if int_geom.wkbType() in gList:
outFeat.setGeometry( int_geom )
outFeat.setAttributes( atMapA.extend( atMapB ) )
atMapA.extend( atMapB )
outFeat.setAttributes( atMapA )
writer.addFeature( outFeat )
except:
FEATURE_EXCEPT = False
Expand Down Expand Up @@ -976,7 +976,8 @@ def intersect( self ):
gList = ftools_utils.getGeomType( geom.wkbType() )
if int_geom.wkbType() in gList:
outFeat.setGeometry( int_geom )
outFeat.setAttributes( atMapA.extend( atMapB ) )
atMapA.extend( atMapB )
outFeat.setAttributes( atMapA )
writer.addFeature( outFeat )
except:
EATURE_EXCEPT = False
Expand Down Expand Up @@ -1015,7 +1016,8 @@ def intersect( self ):
gList = ftools_utils.getGeomType( geom.wkbType() )
if int_geom.wkbType() in gList:
outFeat.setGeometry( int_geom )
outFeat.setAttributes( atMapA.extend( atMapB ) )
atMapA.extend( atMapB )
outFeat.setAttributes( atMapA )
writer.addFeature( outFeat )
except:
FEATURE_EXCEPT = False
Expand All @@ -1025,8 +1027,8 @@ def intersect( self ):
break
# we have no selection in overlay layer
else:
fitA = vproviderA.getFeatures()
while fita.nextFeature( inFeatA ):
fitA = vproviderA.getFeatures()
while fitA.nextFeature( inFeatA ):
nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
geom = QgsGeometry( inFeatA.geometry() )
Expand All @@ -1043,11 +1045,13 @@ def intersect( self ):
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )

try:
gList = ftools_utils.getGeomType( geom.wkbType() )
if int_geom.wkbType() in gList:
outFeat.setGeometry( int_geom )
outFeat.setAttributes( atMapA.extend( atMapB ) )
atMapA.extend( atMapB )
outFeat.setAttributes( atMapA )
writer.addFeature( outFeat )
except:
FEATURE_EXCEPT = False
Expand Down Expand Up @@ -1148,7 +1152,8 @@ def union( self ):
int_geom = QgsGeometry( i )
try:
outFeat.setGeometry( int_geom )
outFeat.setAttributes( atMapA.extend( atMapB ) )
atMapA.extend( atMapB )
outFeat.setAttributes( atMapA )
writer.addFeature( outFeat )
except Exception, err:
FEATURE_EXCEPT = False
Expand All @@ -1161,7 +1166,8 @@ def union( self ):
if int_geom.wkbType() in gList:
try:
outFeat.setGeometry( int_geom )
outFeat.setAttributes( atMapA.extend( atMapB ) )
atMapA.extend( atMapB )
outFeat.setAttributes( atMapA )
writer.addFeature( outFeat )
except Exception, err:
FEATURE_EXCEPT = False
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/fTools/tools/ftools_utils.py
Expand Up @@ -76,7 +76,8 @@ def combineVectorFields( layerA, layerB ):
fieldsA = layerA.dataProvider().fields()
fieldsB = layerB.dataProvider().fields()
fieldsB = testForUniqueness( fieldsA, fieldsB )
fieldsA.extend( fieldsB )
for f in fieldsB:
fieldsA.append( f )
return fieldsA

# Check if two input CRSs are identical
Expand Down Expand Up @@ -155,10 +156,10 @@ def testForUniqueness( fieldList1, fieldList2 ):
changed = True
while changed:
changed = False
for i in fieldList1:
for j in fieldList2:
if j.name() == i.name():
j = createUniqueFieldName( j )
for i in range(0,len(fieldList1)):
for j in range(0,len(fieldList2)):
if fieldList1[i].name() == fieldList2[j].name():
fieldList2[j] = createUniqueFieldName( fieldList2[j] )
changed = True
return fieldList2

Expand Down Expand Up @@ -265,7 +266,6 @@ def addShapeToCanvas( shapefile_path ):
else:
return False
vlayer_new = QgsVectorLayer( shapefile_path, layer_name, "ogr" )
print layer_name
if vlayer_new.isValid():
QgsMapLayerRegistry.instance().addMapLayers( [vlayer_new] )
return True
Expand Down

0 comments on commit 8f25bcf

Please sign in to comment.