Skip to content

Commit

Permalink
When loading GML layers in processing tests, FORCE detection of
Browse files Browse the repository at this point in the history
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 authored and 3nids committed Feb 2, 2021
1 parent add09d8 commit 69ec923
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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', {})
Expand Down

0 comments on commit 69ec923

Please sign in to comment.