add_warnings.diff

Proposed patch - Alexander Bruy, 2010-04-16 09:07 AM

Download (5.11 KB)

View differences:

python/plugins/fTools/tools/doGeoprocessing.py (working copy)
198 198
    self.cancel_close.setText( self.tr("Close") )
199 199
    QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
200 200
    out_text = ""
201
    if results[3] is not None:
202
      QMessageBox.warning( self, self.tr( "Geoprocessing" ),
203
                  self.tr( "No output created. File creation error:\n%1" )
204
                  .arg( results[3] ) )
205
      return
201 206
    if not results[2] or not results[1] or not results [0]:
202 207
      out_text = self.tr( "\nWarnings:" )
203 208
      end_text = self.tr( "\nSome output geometries may be missing or invalid.\n\nWould you like to add the new layer anyway?" )
......
240 245
  def run( self ):
241 246
    self.running = True
242 247
    self.vlayerA = ftools_utils.getVectorLayerByName( self.myLayerA )
248
    error = None
243 249
    if self.myFunction == 1 or self.myFunction == 2 or self.myFunction == 4:
244 250
      ( self.myParam, useField ) = self.checkParameter( self.vlayerA, self.myParam )
245 251
      if not self.myParam is None:
......
254 260
      if self.myFunction == 3:
255 261
        geos, feature, match = self.difference()
256 262
      elif self.myFunction == 5:
257
        geos, feature, match = self.intersect()
263
        geos, feature, match, error = self.intersect()
258 264
      elif self.myFunction == 6:
259
        geos, feature, match = self.union()
265
        geos, feature, match, error = self.union()
260 266
      elif self.myFunction == 7:
261
        geos, feature, match = self.symetrical_difference()
267
        geos, feature, match, error = self.symetrical_difference()
262 268
      elif self.myFunction == 8:
263 269
        geos, feature, match = self.clip()
264
    self.emit( SIGNAL( "runFinished(PyQt_PyObject)" ), (geos, feature, match) )
270
    self.emit( SIGNAL( "runFinished(PyQt_PyObject)" ), (geos, feature, match, error) )
265 271
    self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
266 272
  
267 273
  def stop(self):
......
836 842
    vproviderB.select( allAttrsB )
837 843
    crs_match = vproviderA.crs() == vproviderB.crs()
838 844
    fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
845
    longNames = ftools_utils.checkFieldNameLenght( fields )
846
    if not longNames.isEmpty():
847
      message = QString( 'Following field names are longer then 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
848
      return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
839 849
    writer = QgsVectorFileWriter( self.myName, self.myEncoding, 
840 850
    fields, vproviderA.geometryType(), vproviderA.crs() )
851
    if writer.hasError():
852
      return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage()
841 853
    inFeatA = QgsFeature()
842 854
    inFeatB = QgsFeature()
843 855
    outFeat = QgsFeature()
......
979 991
              break
980 992
    del writer
981 993
    print crs_match
982
    return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
994
    return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None
983 995
  
984 996
  def union( self ):
985 997
    GEOS_EXCEPT = True
......
993 1005
    if vproviderA.crs() == vproviderB.crs(): crs_match = True
994 1006
    else: crs_match = False
995 1007
    fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
1008
    longNames = ftools_utils.checkFieldNameLenght( fields )
1009
    if not longNames.isEmpty():
1010
      message = QString( 'Following field names are longer then 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
1011
      return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
996 1012
    writer = QgsVectorFileWriter( self.myName, self.myEncoding, 
997 1013
    fields, vproviderA.geometryType(), vproviderA.crs() )
1014
    if writer.hasError():
1015
      return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage()
998 1016
    inFeatA = QgsFeature()
999 1017
    inFeatB = QgsFeature()
1000 1018
    outFeat = QgsFeature()
......
1102 1120
      self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ),  nElement )
1103 1121
      nElement += 1
1104 1122
    del writer
1105
    return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
1123
    return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None
1106 1124
  
1107 1125
  def symetrical_difference( self ):
1108 1126
    GEOS_EXCEPT = True
......
1116 1134
    if vproviderA.crs() == vproviderB.crs(): crs_match = True
1117 1135
    else: crs_match = False
1118 1136
    fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
1137
    longNames = ftools_utils.checkFieldNameLenght( fields )
1138
    if not longNames.isEmpty():
1139
      message = QString( 'Following field names are longer then 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
1140
      return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
1119 1141
    writer = QgsVectorFileWriter( self.myName, self.myEncoding, 
1120 1142
    fields, vproviderA.geometryType(), vproviderA.crs() )
1143
    if writer.hasError():
1144
      return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, writer.errorMessage()
1121 1145
    inFeatA = QgsFeature()
1122 1146
    inFeatB = QgsFeature()
1123 1147
    outFeat = QgsFeature()
......
1184 1208
          FEATURE_EXCEPT = False
1185 1209
          continue
1186 1210
    del writer
1187
    return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match
1211
    return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, None
1188 1212
  
1189 1213
  def clip( self ):
1190 1214
    GEOS_EXCEPT = True