Skip to content
Permalink
Browse files

When loading GML layers in processing tests, FORCE detection of

SRS. Newer GDAL versions won't do this by default, but we need
to determine the actual/expected CRS for these layers in order
to compare correctly.
  • Loading branch information
nyalldawson committed Feb 8, 2021
1 parent f14bd71 commit 19b4b1aa643dda744d8daa536f1d0a4a86019e59
Showing with 15 additions and 1 deletion.
  1. +15 −1 python/plugins/processing/tests/AlgorithmsTestBase.py
@@ -254,6 +254,12 @@ def load_layer(self, id, param):
if filepath in self.vector_layer_params:
return self.vector_layer_params[filepath]

gmlrex = r'\.gml\b'
if re.search(gmlrex, filepath, re.IGNORECASE):
# ewwwww - we have to force SRS detection for GML files, otherwise they'll be loaded
# with no srs
filepath += '|option:FORCE_SRS_DETECTION=YES'

options = QgsVectorLayer.LayerOptions()
options.loadDefaultStyle = False
lyr = QgsVectorLayer(filepath, param['name'], 'ogr', options)
@@ -320,7 +326,15 @@ def check_results(self, results, context, params, expected):
if isinstance(results[id], QgsMapLayer):
result_lyr = results[id]
else:
result_lyr = QgsProcessingUtils.mapLayerFromString(results[id], context)
string = results[id]

gmlrex = r'\.gml\b'
if re.search(gmlrex, string, re.IGNORECASE):
# ewwwww - we have to force SRS detection for GML files, otherwise they'll be loaded
# with no srs
string += '|option:FORCE_SRS_DETECTION=YES'

result_lyr = QgsProcessingUtils.mapLayerFromString(string, context)
self.assertTrue(result_lyr, results[id])

compare = expected_result.get('compare', {})

0 comments on commit 19b4b1a

Please sign in to comment.