Skip to content

Commit

Permalink
More specific warnings for geoprocessing tools when missing crs are d…
Browse files Browse the repository at this point in the history
…etected. Addresses #2547.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13503 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed May 16, 2010
1 parent 148f5b3 commit 02e5ac3
Showing 1 changed file with 41 additions and 12 deletions.
53 changes: 41 additions & 12 deletions python/plugins/fTools/tools/doGeoprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,17 @@ def runFinishedFromThread( self, results ):
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]:
if (not results[2] is None and 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?" )
else:
out_text = "\n"
end_text = self.tr( "\n\nWould you like to add the new layer to the TOC?" )
if not results[2]:
out_text = out_text + self.tr( "\nInput CRS error: Different input coordinate reference systems detected, results may not be as expected.")
if not results[2] is None:
if not results[2]:
out_text = out_text + self.tr( "\nInput CRS error: Different input coordinate reference systems detected, results may not be as expected.")
else:
out_text = out_text + self.tr( "\nInput CRS error: One or more input layers missing coordinate reference information, results may not be as expected.")
if not results[1]:
out_text = out_text + self.tr( "\nFeature geometry error: One or more output features ignored due to invalid geometry.")
if not results[0]:
Expand Down Expand Up @@ -693,8 +696,13 @@ def difference( self ):
allAttrsB = vproviderB.attributeIndexes()
vproviderB.select( allAttrsB )
fields = vproviderA.fields()
if vproviderA.crs() == vproviderB.crs(): crs_match = True
else: crs_match = False
# check for crs compatability
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
crs_match = None
else:
crs_match = crsA == crsB
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vproviderA.geometryType(), vproviderA.crs() )
inFeatA = QgsFeature()
Expand Down Expand Up @@ -844,7 +852,13 @@ def intersect( self ):
vproviderB = self.vlayerB.dataProvider()
allAttrsB = vproviderB.attributeIndexes()
vproviderB.select( allAttrsB )
crs_match = vproviderA.crs() == vproviderB.crs()
# check for crs compatability
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
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 @@ -1006,8 +1020,13 @@ def union( self ):
vproviderB = self.vlayerB.dataProvider()
allAttrsB = vproviderB.attributeIndexes()
vproviderB.select( allAttrsB )
if vproviderA.crs() == vproviderB.crs(): crs_match = True
else: crs_match = False
# check for crs compatability
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
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 @@ -1135,8 +1154,13 @@ def symetrical_difference( self ):
vproviderB = self.vlayerB.dataProvider()
allAttrsB = vproviderB.attributeIndexes()
vproviderB.select( allAttrsB )
if vproviderA.crs() == vproviderB.crs(): crs_match = True
else: crs_match = False
# check for crs compatability
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
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 @@ -1223,8 +1247,13 @@ def clip( self ):
vproviderB = self.vlayerB.dataProvider()
allAttrsB = vproviderB.attributeIndexes()
vproviderB.select( allAttrsB )
if vproviderA.crs() == vproviderB.crs(): crs_match = True
else: crs_match = False
# check for crs compatability
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
crs_match = None
else:
crs_match = crsA == crsB
fields = vproviderA.fields()
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vproviderA.geometryType(), vproviderA.crs() )
Expand Down

0 comments on commit 02e5ac3

Please sign in to comment.