Skip to content

Commit 02e5ac3

Browse files
author
cfarmer
committedMay 16, 2010
More specific warnings for geoprocessing tools when missing crs are detected. Addresses #2547.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13503 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed
 

‎python/plugins/fTools/tools/doGeoprocessing.py

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,17 @@ def runFinishedFromThread( self, results ):
207207
self.tr( "No output created. File creation error:\n%1" )
208208
.arg( results[3] ) )
209209
return
210-
if not results[2] or not results[1] or not results [0]:
210+
if (not results[2] is None and not results[2]) or not results[1] or not results [0]:
211211
out_text = self.tr( "\nWarnings:" )
212212
end_text = self.tr( "\nSome output geometries may be missing or invalid.\n\nWould you like to add the new layer anyway?" )
213213
else:
214214
out_text = "\n"
215215
end_text = self.tr( "\n\nWould you like to add the new layer to the TOC?" )
216-
if not results[2]:
217-
out_text = out_text + self.tr( "\nInput CRS error: Different input coordinate reference systems detected, results may not be as expected.")
216+
if not results[2] is None:
217+
if not results[2]:
218+
out_text = out_text + self.tr( "\nInput CRS error: Different input coordinate reference systems detected, results may not be as expected.")
219+
else:
220+
out_text = out_text + self.tr( "\nInput CRS error: One or more input layers missing coordinate reference information, results may not be as expected.")
218221
if not results[1]:
219222
out_text = out_text + self.tr( "\nFeature geometry error: One or more output features ignored due to invalid geometry.")
220223
if not results[0]:
@@ -693,8 +696,13 @@ def difference( self ):
693696
allAttrsB = vproviderB.attributeIndexes()
694697
vproviderB.select( allAttrsB )
695698
fields = vproviderA.fields()
696-
if vproviderA.crs() == vproviderB.crs(): crs_match = True
697-
else: crs_match = False
699+
# check for crs compatability
700+
crsA = vproviderA.crs()
701+
crsB = vproviderB.crs()
702+
if not crsA.isValid() or not crsB.isValid():
703+
crs_match = None
704+
else:
705+
crs_match = crsA == crsB
698706
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
699707
fields, vproviderA.geometryType(), vproviderA.crs() )
700708
inFeatA = QgsFeature()
@@ -844,7 +852,13 @@ def intersect( self ):
844852
vproviderB = self.vlayerB.dataProvider()
845853
allAttrsB = vproviderB.attributeIndexes()
846854
vproviderB.select( allAttrsB )
847-
crs_match = vproviderA.crs() == vproviderB.crs()
855+
# check for crs compatability
856+
crsA = vproviderA.crs()
857+
crsB = vproviderB.crs()
858+
if not crsA.isValid() or not crsB.isValid():
859+
crs_match = None
860+
else:
861+
crs_match = crsA == crsB
848862
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
849863
longNames = ftools_utils.checkFieldNameLength( fields )
850864
if not longNames.isEmpty():
@@ -1006,8 +1020,13 @@ def union( self ):
10061020
vproviderB = self.vlayerB.dataProvider()
10071021
allAttrsB = vproviderB.attributeIndexes()
10081022
vproviderB.select( allAttrsB )
1009-
if vproviderA.crs() == vproviderB.crs(): crs_match = True
1010-
else: crs_match = False
1023+
# check for crs compatability
1024+
crsA = vproviderA.crs()
1025+
crsB = vproviderB.crs()
1026+
if not crsA.isValid() or not crsB.isValid():
1027+
crs_match = None
1028+
else:
1029+
crs_match = crsA == crsB
10111030
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
10121031
longNames = ftools_utils.checkFieldNameLength( fields )
10131032
if not longNames.isEmpty():
@@ -1135,8 +1154,13 @@ def symetrical_difference( self ):
11351154
vproviderB = self.vlayerB.dataProvider()
11361155
allAttrsB = vproviderB.attributeIndexes()
11371156
vproviderB.select( allAttrsB )
1138-
if vproviderA.crs() == vproviderB.crs(): crs_match = True
1139-
else: crs_match = False
1157+
# check for crs compatability
1158+
crsA = vproviderA.crs()
1159+
crsB = vproviderB.crs()
1160+
if not crsA.isValid() or not crsB.isValid():
1161+
crs_match = None
1162+
else:
1163+
crs_match = crsA == crsB
11401164
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
11411165
longNames = ftools_utils.checkFieldNameLength( fields )
11421166
if not longNames.isEmpty():
@@ -1223,8 +1247,13 @@ def clip( self ):
12231247
vproviderB = self.vlayerB.dataProvider()
12241248
allAttrsB = vproviderB.attributeIndexes()
12251249
vproviderB.select( allAttrsB )
1226-
if vproviderA.crs() == vproviderB.crs(): crs_match = True
1227-
else: crs_match = False
1250+
# check for crs compatability
1251+
crsA = vproviderA.crs()
1252+
crsB = vproviderB.crs()
1253+
if not crsA.isValid() or not crsB.isValid():
1254+
crs_match = None
1255+
else:
1256+
crs_match = crsA == crsB
12281257
fields = vproviderA.fields()
12291258
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
12301259
fields, vproviderA.geometryType(), vproviderA.crs() )

0 commit comments

Comments
 (0)
Please sign in to comment.