Skip to content

Commit

Permalink
Checks for long field names and warns when this will be a problem. Pa…
Browse files Browse the repository at this point in the history
…tch from Alex.

git-svn-id: http://svn.osgeo.org/qgis/trunk@13348 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed Apr 22, 2010
1 parent 0dcb259 commit 2949ffd
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions python/plugins/fTools/tools/doGeoprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def runFinishedFromThread( self, results ):
self.cancel_close.setText( self.tr("Close") )
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
out_text = ""
if results[3] is not None:
QMessageBox.warning( self, self.tr( "Geoprocessing" ),
self.tr( "No output created. File creation error:\n%1" )
.arg( results[3] ) )
return
if not results[2] or not results[1] or not results [0]:
out_text = self.tr( "\nWarnings:" )
end_text = self.tr( "\nSome output geometries may be missing or invalid.\n\nWould you like to add the new layer anyway?" )
Expand Down Expand Up @@ -240,6 +245,7 @@ def __init__( self, parentThread, parentObject, function, myLayerA, myLayerB,
def run( self ):
self.running = True
self.vlayerA = ftools_utils.getVectorLayerByName( self.myLayerA )
error = None
if self.myFunction == 1 or self.myFunction == 2 or self.myFunction == 4:
( self.myParam, useField ) = self.checkParameter( self.vlayerA, self.myParam )
if not self.myParam is None:
Expand All @@ -254,14 +260,14 @@ def run( self ):
if self.myFunction == 3:
geos, feature, match = self.difference()
elif self.myFunction == 5:
geos, feature, match = self.intersect()
geos, feature, match, error = self.intersect()
elif self.myFunction == 6:
geos, feature, match = self.union()
geos, feature, match, error = self.union()
elif self.myFunction == 7:
geos, feature, match = self.symetrical_difference()
geos, feature, match, error = self.symetrical_difference()
elif self.myFunction == 8:
geos, feature, match = self.clip()
self.emit( SIGNAL( "runFinished(PyQt_PyObject)" ), (geos, feature, match) )
self.emit( SIGNAL( "runFinished(PyQt_PyObject)" ), (geos, feature, match, error) )
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )

def stop(self):
Expand Down Expand Up @@ -836,8 +842,14 @@ def intersect( self ):
vproviderB.select( allAttrsB )
crs_match = vproviderA.crs() == vproviderB.crs()
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLenght( fields )
if not longNames.isEmpty():
message = QString( 'Following field names are longer then 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vproviderA.geometryType(), vproviderA.crs() )
if writer.hasError():
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage()
inFeatA = QgsFeature()
inFeatB = QgsFeature()
outFeat = QgsFeature()
Expand Down Expand Up @@ -979,7 +991,7 @@ def intersect( self ):
break
del writer
print crs_match
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None

def union( self ):
GEOS_EXCEPT = True
Expand All @@ -993,8 +1005,14 @@ def union( self ):
if vproviderA.crs() == vproviderB.crs(): crs_match = True
else: crs_match = False
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLenght( fields )
if not longNames.isEmpty():
message = QString( 'Following field names are longer then 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vproviderA.geometryType(), vproviderA.crs() )
if writer.hasError():
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage()
inFeatA = QgsFeature()
inFeatB = QgsFeature()
outFeat = QgsFeature()
Expand Down Expand Up @@ -1102,7 +1120,7 @@ def union( self ):
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
nElement += 1
del writer
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None

def symetrical_difference( self ):
GEOS_EXCEPT = True
Expand All @@ -1116,8 +1134,14 @@ def symetrical_difference( self ):
if vproviderA.crs() == vproviderB.crs(): crs_match = True
else: crs_match = False
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLenght( fields )
if not longNames.isEmpty():
message = QString( 'Following field names are longer then 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vproviderA.geometryType(), vproviderA.crs() )
if writer.hasError():
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage()
inFeatA = QgsFeature()
inFeatB = QgsFeature()
outFeat = QgsFeature()
Expand Down Expand Up @@ -1184,7 +1208,7 @@ def symetrical_difference( self ):
FEATURE_EXCEPT = False
continue
del writer
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None

def clip( self ):
GEOS_EXCEPT = True
Expand Down

0 comments on commit 2949ffd

Please sign in to comment.